Cancellation of CFDI

This service facilitates the cancellation of invoices through various available methods. It is crucial to note that, for cancellations in the testing environment, the use of test CSDs (Digital Seal Certificate) designated by the SAT (Tax Administration Service) is mandatory.

Before initiating the cancellation process, it is highly recommended to perform the following technical checks.

Firstly, verify the current status of the invoice to ensure it is eligible for cancellation. Secondly, conduct a thorough review of the associated CFDIs (Digital Fiscal Invoices over the Internet) to identify any dependencies or linked transactions.

These pre-cancellation steps are crucial to ensuring a seamless and error-free cancellation process.

Important

Some of the libraries are already updated and ready to test the new cancellation scheme.

🧰 Production URL : https://services.sw.com.mx

Cancellation by UUID

Cancellation method by UUID, for this method it is essential to previously upload the issuer’s certificates to the account

Endpoint

MethodPath
POST/cfdi33/cancel/{rfc}/{uuid}/{motivo}/{folioSustitucion}

Authentication and Headers

HeaderValue
AuthorizationBearer Token

Path Parameters

PropertyUseDescription
rfcRequiredTax ID (RFC) of the issuer
uuidRequiredUUID of the CFDI to cancel
motivoRequiredKey to express the reason for cancellation
folioSustitucionOptionalUUID of the CFDI replacing the previous one
The property ‘folioSustitucion’ will be required when ‘motivo’ is 01.

Example Request

curl --request POST \
  --url https://services.test.sw.com.mx/cfdi33/cancel/EKU9003173C9/f7392818-aca8-44b0-9942-120d862a71ea/02 \
  --header 'Authorization: Bearer $token'
Response Ok
{
    "data": {
        "acuse": "<!--?xml version=\"1.0\" encoding=\"utf-8\"?--><acuse xmlns:xsd="\&quot;http://www.w3.org/2001/XMLSchema\&quot;" xmlns:xsi="\&quot;http://www.w3.org/2001/XMLSchema-instance\&quot;" fecha="\&quot;2022-06-10T02:49:35.7057854\&quot;" rfcemisor="\&quot;EKU9003173C9\&quot;"><folios xmlns="\&quot;http://cancelacfd.sat.gob.mx\&quot;"><uuid>FE4E71B0-8959-4FB9-8091-F5AC4FB0FEF8</uuid><estatusuuid>202</estatusuuid></folios><signature id="\&quot;SelloSAT\&quot;" xmlns="\&quot;http://www.w3.org/2000/09/xmldsig#\&quot;"><signedinfo><canonicalizationmethod algorithm="\&quot;http://www.w3.org/TR/2001/REC-xml-c14n-20010315\&quot;"><signaturemethod algorithm="\&quot;http://www.w3.org/2001/04/xmldsig-more#hmac-sha512\&quot;"><reference uri="\&quot;\&quot;"><transforms><transform algorithm="\&quot;http://www.w3.org/TR/1999/REC-xpath-19991116\&quot;"><xpath>not(ancestor-or-self::*[local-name()='Signature'])</xpath></transform></transforms><digestmethod algorithm="\&quot;http://www.w3.org/2001/04/xmlenc#sha512\&quot;"><digestvalue>yQdDpQmr8EW3PvHBdGDiOfcO4hF3gXApv9ggW+x8pGb0Ox1inycuKKBo46RBozt8oWat4g2jLQEak2PyS/JbEg==</digestvalue></digestmethod></reference></signaturemethod></canonicalizationmethod></signedinfo><signaturevalue>xAzJW9WdeFYkxR7+NQXGCgRoGCFbnUMN4aQ81OIa6Nh/NfuRStIhA8s5V4amtaNimYNR3v6PKAOUjCDVxxnVMw==</signaturevalue><keyinfo><keyname>BF66E582888CC845</keyname><keyvalue><rsakeyvalue><modulus>n5YsGT0w5Z70ONPbqszhExfJU+KY3Bscftc2jxUn4wxpSjEUhnCuTd88OK5QbDW3Mupoc61jr83lRhUCjchFAmCigpC10rEntTfEU+7qtX8ud/jJJDB1a9lTIB6bhBN//X8IQDjhmHrfKvfen3p7RxLrFoxzWgpwKriuGI5wUlU=</modulus><exponent>AQAB</exponent></rsakeyvalue></keyvalue></keyinfo></signature></acuse>",
        "uuid": {
            "FE4E71B0-8959-4FB9-8091-F5AC4FB0FEF8": "201"
        }
    },
    "status": "success"
}
Response Error
{
    "message": "CACFDI33 - Problemas con el xml.",
    "messageDetail": "CA305 - Certificado Inválido.",
    "data": null,
    "status": "error"
}

Cancellation by CSD

For our electronic invoice cancellation service, you can use this method if you prefer to include your CSD in the request or if they are not stored in our ADT portal. This streamlined process ensures secure and efficient cancellation.

Endpoint,

MethodPath
POST/cfdi33/cancel/csd

Authentication and Headers

HeaderValue
AuthorizationBearer Token
Content-Type application/json

JSON Body parameters

PropertyUseTypeDescription
uuidRequiredstringUUID of the CFDI to cancel
rfcRequiredstringTax ID (RFC) of the issuer
motivoRequiredstringKey to express the reason for cancellation
folioSustitucionOptionalstringUUID of the CFDI replacing the previous one
b64CerRequiredstringIssuer’s certificate in Base64
b64KeyRequiredstringIssuer’s key in Base64
passwordRequiredstringCertificate password
The property ‘folioSustitucion’ will be required when ‘motivo’ is 01.

Example Request

curl --request POST \
  --url https://services.test.sw.com.mx/cfdi33/cancel/csd \
  --header 'Authorization: Bearer $token' \
  --header 'Content-Type: application/json' \
  --data '{
  "uuid": "059c8c06-af7e-4c8c-8085-51b631696de5",
  "password": "12345678a",
  "rfc": "EKU9003173C9",
  "motivo": "02",
  "b64Cer": "$cer",
  "b64Key": "$key"
}'
Response Ok
{
    "data": {
        "acuse": "<!--?xml version=\"1.0\" encoding=\"utf-8\"?--><acuse xmlns:xsd="\&quot;http://www.w3.org/2001/XMLSchema\&quot;" xmlns:xsi="\&quot;http://www.w3.org/2001/XMLSchema-instance\&quot;" fecha="\&quot;2022-09-08T10:42:56.2610824\&quot;" rfcemisor="\&quot;EKU9003173C9\&quot;"><folios xmlns="\&quot;http://cancelacfd.sat.gob.mx\&quot;"><uuid>24B927FF-E5FA-4662-9BA0-9176A4C218B1</uuid><estatusuuid>202</estatusuuid></folios><signature id="\&quot;SelloSAT\&quot;" xmlns="\&quot;http://www.w3.org/2000/09/xmldsig#\&quot;"><signedinfo><canonicalizationmethod algorithm="\&quot;http://www.w3.org/TR/2001/REC-xml-c14n-20010315\&quot;"><signaturemethod algorithm="\&quot;http://www.w3.org/2001/04/xmldsig-more#hmac-sha512\&quot;"><reference uri="\&quot;\&quot;"><transforms><transform algorithm="\&quot;http://www.w3.org/TR/1999/REC-xpath-19991116\&quot;"><xpath>not(ancestor-or-self::*[local-name()='Signature'])</xpath></transform></transforms><digestmethod algorithm="\&quot;http://www.w3.org/2001/04/xmlenc#sha512\&quot;"><digestvalue>5S+xTQEV6cO8ek7qdG2l3yAcepQ0kvQ9eakdiWDq9/2D6P20O48G6K8AUJ9C55fBVBYoj+sQ87YUF/dpGJZemA==</digestvalue></digestmethod></reference></signaturemethod></canonicalizationmethod></signedinfo><signaturevalue>W8JG7ypQmqfuOtFefK9HQwwI6BQHd9dojGhyo7YmDaG3RRGxMlGozQOJGYEHAR4XSvISKkCRnT9RodEdgnEfFw==</signaturevalue><keyinfo><keyname>BF66E582888CC845</keyname><keyvalue><rsakeyvalue><modulus>n5YsGT0w5Z70ONPbqszhExfJU+KY3Bscftc2jxUn4wxpSjEUhnCuTd88OK5QbDW3Mupoc61jr83lRhUCjchFAmCigpC10rEntTfEU+7qtX8ud/jJJDB1a9lTIB6bhBN//X8IQDjhmHrfKvfen3p7RxLrFoxzWgpwKriuGI5wUlU=</modulus><exponent>AQAB</exponent></rsakeyvalue></keyvalue></keyinfo></signature></acuse>",
        "uuid": {
            "24B927FF-E5FA-4662-9BA0-9176A4C218B1": "201"
        }
    },
    "status": "success"
}
Response Error
{
    "message": "CACFDI33 - Problemas con el xml.",
    "messageDetail": "CA305 - Certificado Inválido.",
    "data": null,
    "status": "error"
}

Cancellation by PFX

Our electronic invoice cancellation service allows secure and convenient authentication using PFX files, consolidating both the digital certificate and private key into a single password-protected file for an integrated and efficient solution. This service is particularly useful if you haven’t uploaded your CSD to our ADT portal.

Endpoint

MethodPath
POST/cfdi33/cancel/pfx

Authentication and Headers

HeaderValue
AuthorizationBearer Token
Content-Type application/json

JSON Body parameters

PropertyUseTypeDescription
uuidRequiredstringUUID of the CFDI to cancel
rfcRequiredstringTax ID (RFC) of the issuer
motivoRequiredstringKey to express the reason for cancellation
folioSustitucionOptionalstringUUID of the CFDI replacing the previous one
b64PfxRequiredstringPFX file in Base64
passwordRequiredstringPFX password
The property ‘folioSustitucion’ will be required when ‘motivo’ is 01.

Example Request

curl --request POST \
  --url https://services.test.sw.com.mx/cfdi33/cancel/pfx \
  --header 'Authorization: Bearer $token' \
  --header 'Content-Type: application/json' \
  --data '{
  "uuid": "15b0cdf5-7cc6-4f6f-815a-5f101402f185",
  "password": "12345678a",
  "rfc": "EKU9003173C9",
  "motivo": "01",
  "folioSustitucion":"fe4e71b0-8959-4fb9-8091-f5ac4fb0fef8"
  "b64Pfx": "$Pfx"
}'
Response Ok
{
    "data": {
        "acuse": "<!--?xml version=\"1.0\" encoding=\"utf-8\"?--><acuse xmlns:xsd="\&quot;http://www.w3.org/2001/XMLSchema\&quot;" xmlns:xsi="\&quot;http://www.w3.org/2001/XMLSchema-instance\&quot;" fecha="\&quot;2022-06-10T02:49:35.7057854\&quot;" rfcemisor="\&quot;EKU9003173C9\&quot;"><folios xmlns="\&quot;http://cancelacfd.sat.gob.mx\&quot;"><uuid>FE4E71B0-8959-4FB9-8091-F5AC4FB0FEF8</uuid><estatusuuid>202</estatusuuid></folios><signature id="\&quot;SelloSAT\&quot;" xmlns="\&quot;http://www.w3.org/2000/09/xmldsig#\&quot;"><signedinfo><canonicalizationmethod algorithm="\&quot;http://www.w3.org/TR/2001/REC-xml-c14n-20010315\&quot;"><signaturemethod algorithm="\&quot;http://www.w3.org/2001/04/xmldsig-more#hmac-sha512\&quot;"><reference uri="\&quot;\&quot;"><transforms><transform algorithm="\&quot;http://www.w3.org/TR/1999/REC-xpath-19991116\&quot;"><xpath>not(ancestor-or-self::*[local-name()='Signature'])</xpath></transform></transforms><digestmethod algorithm="\&quot;http://www.w3.org/2001/04/xmlenc#sha512\&quot;"><digestvalue>yQdDpQmr8EW3PvHBdGDiOfcO4hF3gXApv9ggW+x8pGb0Ox1inycuKKBo46RBozt8oWat4g2jLQEak2PyS/JbEg==</digestvalue></digestmethod></reference></signaturemethod></canonicalizationmethod></signedinfo><signaturevalue>xAzJW9WdeFYkxR7+NQXGCgRoGCFbnUMN4aQ81OIa6Nh/NfuRStIhA8s5V4amtaNimYNR3v6PKAOUjCDVxxnVMw==</signaturevalue><keyinfo><keyname>BF66E582888CC845</keyname><keyvalue><rsakeyvalue><modulus>n5YsGT0w5Z70ONPbqszhExfJU+KY3Bscftc2jxUn4wxpSjEUhnCuTd88OK5QbDW3Mupoc61jr83lRhUCjchFAmCigpC10rEntTfEU+7qtX8ud/jJJDB1a9lTIB6bhBN//X8IQDjhmHrfKvfen3p7RxLrFoxzWgpwKriuGI5wUlU=</modulus><exponent>AQAB</exponent></rsakeyvalue></keyvalue></keyinfo></signature></acuse>",
        "uuid": {
            "FE4E71B0-8959-4FB9-8091-F5AC4FB0FEF8": "201"
        }
    },
    "status": "success"
}
Response Error
{
    "message": "CACFDI33 - Problemas con el xml.",
    "messageDetail": "CA305 - Certificado Inválido.",
    "data": null,
    "status": "error"
}

? Supporting articles:

How to create a PFX file?

Cancellation by XML

Service for canceling by sending an XML with the information and folios of the invoices to be canceled. This method can be used for mass cancellation of CFDI.

Endpoint

MethodPath
POST/cfdi33/cancel/xml

Authentication and Headers

HeaderValue
AuthorizationBearer Token
Content-Typemultipart/form-data

Form Parameters

PropertyUseDescription
xmlRequiredXML structured according to the Anexo 20 (Technical Documentation page 62, on the official SAT portal), containing information about the invoices to be canceled.

Example Request

curl --request POST \
  --url http://services.test.sw.com.mx/cfdi33/cancel/xml \
  --header 'Authorization: Bearer $token' \
  --header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
  --form 'xml=@C:\Users\SW sapien\cancelacionMasiva.xml'
Response Ok
{
    "data": {
        "acuse": "<!--?xml version=\"1.0\" encoding=\"utf-8\"?--><acuse xmlns:xsd="\&quot;http://www.w3.org/2001/XMLSchema\&quot;" xmlns:xsi="\&quot;http://www.w3.org/2001/XMLSchema-instance\&quot;" fecha="\&quot;2022-06-10T02:49:35.7057854\&quot;" rfcemisor="\&quot;EKU9003173C9\&quot;"><folios xmlns="\&quot;http://cancelacfd.sat.gob.mx\&quot;"><uuid>FE4E71B0-8959-4FB9-8091-F5AC4FB0FEF8</uuid><estatusuuid>202</estatusuuid></folios><signature id="\&quot;SelloSAT\&quot;" xmlns="\&quot;http://www.w3.org/2000/09/xmldsig#\&quot;"><signedinfo><canonicalizationmethod algorithm="\&quot;http://www.w3.org/TR/2001/REC-xml-c14n-20010315\&quot;"><signaturemethod algorithm="\&quot;http://www.w3.org/2001/04/xmldsig-more#hmac-sha512\&quot;"><reference uri="\&quot;\&quot;"><transforms><transform algorithm="\&quot;http://www.w3.org/TR/1999/REC-xpath-19991116\&quot;"><xpath>not(ancestor-or-self::*[local-name()='Signature'])</xpath></transform></transforms><digestmethod algorithm="\&quot;http://www.w3.org/2001/04/xmlenc#sha512\&quot;"><digestvalue>yQdDpQmr8EW3PvHBdGDiOfcO4hF3gXApv9ggW+x8pGb0Ox1inycuKKBo46RBozt8oWat4g2jLQEak2PyS/JbEg==</digestvalue></digestmethod></reference></signaturemethod></canonicalizationmethod></signedinfo><signaturevalue>xAzJW9WdeFYkxR7+NQXGCgRoGCFbnUMN4aQ81OIa6Nh/NfuRStIhA8s5V4amtaNimYNR3v6PKAOUjCDVxxnVMw==</signaturevalue><keyinfo><keyname>BF66E582888CC845</keyname><keyvalue><rsakeyvalue><modulus>n5YsGT0w5Z70ONPbqszhExfJU+KY3Bscftc2jxUn4wxpSjEUhnCuTd88OK5QbDW3Mupoc61jr83lRhUCjchFAmCigpC10rEntTfEU+7qtX8ud/jJJDB1a9lTIB6bhBN//X8IQDjhmHrfKvfen3p7RxLrFoxzWgpwKriuGI5wUlU=</modulus><exponent>AQAB</exponent></rsakeyvalue></keyvalue></keyinfo></signature></acuse>",
        "uuid": {
            "FE4E71B0-8959-4FB9-8091-F5AC4FB0FEF8": "201"
        }
    },
    "status": "success"
}
Response Error
{
    "message": "CACFDI33 - Problemas con el xml.",
    "messageDetail": "CA305 - Certificado Inválido.",
    "data": null,
    "status": "error"
}

Cancellation responses

All cancellation responses return the same structure in case of an error or a successful request, which are as follows:

Types of responses

In case of a successful response, a 200 will be returned. In the case of an unsuccessful response, a code other than 200 will be returned; the code may vary depending on the given issue.

Successful response

{
	"data": {
		"acuse": "<?xml version=\"1.0\" encoding=\"utf-8\"?><Acuse xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Fecha=\"2017-06-27T11:00:54.8788503\" RfcEmisor=\"LAN7008173R5\"><Folios xmlns=\"http://cancelacfd.sat.gob.mx\"><UUID>3EAEABC9-EA41-4627-9609-C6856B78E2B1</UUID><EstatusUUID>202</EstatusUUID></Folios><Signature Id=\"SelloSAT\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#hmac-sha512\" /><Reference URI=\"\"><Transforms><Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\"><XPath>not(ancestor-or-self::*[local-name()='Signature'])</XPath></Transform></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#sha512\" /><DigestValue>yoO1MKUhUcokwUgyKt5GJbcXvSzZhMKOp2pGhtuwBVrk35Y8HW8s6gJ04liSamflJFNWwUzaFOIf7KpS0SKkaw==</DigestValue></Reference></SignedInfo><SignatureValue>7ZKbUqUVSXkd9Xo9Dm4xOzrqd+j8v3NQWH8HeIPH+opnTOTGNSlVu+a2cqKKB7vmbt2ZTyfsaNsZ+d7up0zEIw==</SignatureValue><KeyInfo><KeyName>00001088888810000001</KeyName><KeyValue><RSAKeyValue><Modulus>vAr6QLmcvW6auTg7a+Ogm0veNvqJ30rD3j0iSAHxGzGVrg1d0xl0Fj5l+JX9EivD+qhkSY7pfLnJoObLpQ3GGZZOOihJVS2tbJDmnn9TW8fKUOVg+jGhcnpCHaUPq/Poj8I2OVb3g7hiaREORm6tLtzOIjkOv9INXxIpRMx54cw46D5F1+0M7ECEVO8Jg+3yoI6OvDNBH+jABsj7SutmSnL1Tov/omIlSWausdbXqykcl10BLu2XiQAc6KLnl0+Ntzxoxk+dPUSdRyR7f3Vls6yUlK/+C/4FacbR+fszT0XIaJNWkHaTOoqz76Ax9XgTv9UuT67j7rdTVzTvAN363w==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo></Signature></Acuse>",
		"uuid": {
			"3EAEABC9-EA41-4627-9609-C6856B78E2B1": "202"
		}
	},
	"status": "success"
}

In this case, a JSON message is received, which contains the following data:

  • Acuse: XML of the acknowledgment returned by SAT. It is considered a successful cancellation request; however, this does not guarantee its cancellation.
  • UUID: UUID of the request and its status.. 

Unsuccessful responses

Unsuccessful responses/Cancellation by CSD
{
	"message": "CASD - Acuse sin descripción específica.",
	"messageDetail": "El uuid proporcionado es inválido. Favor de verificar.",
	"data": null,
	"status": "error"
}
{
	"message": "CACFDI33 - Problemas con los campos.",
	"messageDetail": "El certificado no pertenece a la llave privada.",
	"data": null,
	"status": "error"
}
{
	"message": "CASD - Acuse sin descripción específica.",
	"messageDetail": "El Rfc proporcionado es inválido. Favor de verificar.",
	"data": null,
	"status": "error"
}
{
	"message": "CASD - Acuse sin descripción específica.",
	"messageDetail": "Invalid length for a Base-64 char array or string.",
	"data": null,
	"status": "error"
}
Unsuccessful responses/Cancellation by PFX
{
  "message": "CASD - Acuse sin descripción específica.",
  "messageDetail": "El uuid proporcionado es inválido. Favor de verificar.",
  "data": null,
  "status": "error"
}
{
    "message": "CACFDI33 - Problemas con los CSD.",
    "messageDetail": "Error con los CSD. Error: Cannot Read PFX......",
    "data": null,
    "status": "error"
}
{
  "message": "CASD - Acuse sin descripción específica.",
  "messageDetail": "El Rfc proporcionado es inválido. Favor de verificar.",
  "data": null,
  "status": "error"
}
{
  "message": "CASD - Acuse sin descripción específica.",
  "messageDetail": "Invalid length for a Base-64 char array or string.",
  "data": null,
  "status": "error"
}
Unsuccessful responses/Cancellation by UUID
{
  "message": "CACFDI33",
  "messageDetail": "El UUID proporcionado es invalido. Favor de verificar.",
  "data": null,
  "status": "error"
}
{
  "message": "CACFDI33",
  "messageDetail": "El Rfc proporcionado es invalido. Favor de verificar.",
  "data": null,
  "status": "error"
}
Unsuccessful responses/Cancellation by XML
{
  "message": "CACFDI33 - Problemas con el xml.",
  "messageDetail": "CA305 - La fecha de emisión no esta dentro de la vigencia del CSD del Emisor.",
  "data": null,
  "status": "error"
}
{
  "message": "CACFDI33 - Problemas con el xml.",
  "messageDetail": "CA302 - Sello mal formado o inválido.",
  "data": null,
  "status": "error"
}

Response codes for cancellation folios

Code
Message
Description

201

Solicitud de cancelación exitosa It is considered a successful cancellation request; however, this does not guarantee its cancellation.

202

Folio Fiscal Previamente Cancelado It is considered a previously submitted cancellation request. Status: Canceled with the SAT.

203

Folio Fiscal No Correspondiente al Emisor  

204

Folio Fiscal No Aplicable a Cancelación  

205

Folio Fiscal No Existente The SAT grants a 48-hour extension for the invoice to appear with a Valid status after being sent by the CFDI Certification Provider. It is possible that some invoices may not appear immediately; it is necessary to wait for at least 48 hours.

206

UUID no corresponde a un CFDI del Sector Primario  

207

No se especificó el motivo de cancelación o el motivo no es valido The replacement UUID does not exist, is canceled, or has an issuance date earlier than the issuance date of the original invoice.

208

Folio Sustitución invalido  

209

Folio Sustitución no requerido  

210

La fecha de solicitud de cancelación es mayor a la fecha de declaración .

211

La fecha de solicitud de cancelación límite para factura global  

212

Relación no valida o inexistente  

300

Usuario No Válido  

301

XML Mal Formado This error code is returned when the request contains invalid information, for example: an invalid recipient RFC.

302

Sello Mal Formado  

304

Certificado Revocado o Caduco The certificate can be invalid for multiple reasons such as type, validity, etc.

305

Certificado Inválido The certificate can be invalid for multiple reasons such as type, validity, etc.

309

Certificado Inválido The certificate can be invalid for multiple reasons such as type, validity, etc.

310

CSD Inválido  

311

Motivo inválido Invalid cancellation reason code.

312

UUID no relacionado Unrelated UUID according to the cancellation reason code.

In SW® we strive to be the best for You, wich is why your opinion is very important. Please help us by rating this article and leaving your comments.

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Updated on agosto 9, 2024

Related Articles