Skip to main content

The Spanish version is the authoritative reference. View in Spanish

Method to Send a Cancellation Request (ChangeDocumentStatus)

To start the cancellation process through the API, you must use the POST ChangeDocumentStatus method, whose purpose in MX is to send the document's cancellation request to SAT, using the URL according to the environment to be consumed. The document must be in approved status and must not have a pending cancellation request.

PRODUCTIONhttps://developers.gosocket.net/api/v1/Document/ChangeDocumentStatus
SANDBOXhttps://developers-sbx.gosocket.net/api/v1/Document/ChangeDocumentStatus

The method has the following parameters:

ChangeDocumentStatus for cancellation (request)
ParameterTypeDescriptionAllowed values
countryDocumentId*StringTax identifier (UUID) of the approved document.UUID (36 alphanumeric characters)
accountCode*StringTax ID of the issuing companyAlphanumeric characters
status*StringCancellation code: 4Numeric characters, always 4
reason*StringCancellation reason code* 01: Receipt issued with errors, with relation * 02: Receipt issued with errors, without relation * 03: The operation was not carried out * 04: Nominative operation related to the global invoice
stampNumberStringTax folio of the replacing document. *Required when reason = 01UUID

* Required


Request example

image-20250827-150102.png

For this method we use Postman's Body tab.

  1. Select the method type. In this case, you must select POST.
  2. Enter the method URL.
  3. Enter the parameters shown in the table above with their corresponding values.
{
"countryDocumentId":"451EF0DC-A8C9-5E09-AAC8-FF0466DE3FB7", 
"accountCode": "ANJ235103JM8", 
"status":4, 
"reason":"01",
"stampNumber": "239EF8DC-A6C7-3E87-AAC6-FF8244DE1FB5"
}
  1. Press Send.

Note: Remember that before using the method, you must authenticate within the Authorization tab and enable the company to consume it.

If the event is generated successfully, it is then sent to the Tax Authority for validation and acceptance


Response example

The Tax Authority responds through the API as follows.

{
"Success": true,
"GlobalDocumentId": "00000000-0000-0000-0000-000000000000",
"CountryDocumentId": null,
"OtherData": {
"Country": "mx",
"Certifier": "SAT",
"AuthorityTimeStamp": "17/06/2025 11:40:47"
},
"Messages": [],
"ResponseValue": null,
"Code": "201",
"Description": "Solicitud de Cancelación enviado correctamente",
"ErrorException": null
}

If the sending result is NOT successful, the Inbox API will respond with an error message:

{
"Success": false,
"GlobalDocumentId": "00000000-0000-0000-0000-000000000000",
"CountryDocumentId": "3EAAFBAB-89B5-47AF-A204-E5502346461A",
"OtherData": null,
"Messages": null,
"ResponseValue": null,
"Code": "400",
"Description": "Document Not Found",
"ErrorException": null
}

If the document has been previously canceled, the following response will be shown:

{
"Success": true,
"GlobalDocumentId": "00000000-0000-0000-0000-000000000000",
"CountryDocumentId": null,
"OtherData": {
"Country": "mx",
"Certifier": "SAT",
"AuthorityTimeStamp": "17/06/2025 11:40:47"
},
"Messages": [],
"ResponseValue": null,
"Code": "202",
"Description": "Folio Fiscal Previamente Cancelado",
"ErrorException": null
}

To correctly interpret the response, take into account the following criteria:

ChangeDocumentStatus (response)
ParameterTypeDescriptionAllowed values
SuccessBooleanIndicates whether the request executed successfully.true: The request executed successfully. false: The request executed with some inconsistency.
GlobalDocumentIdStringDocument identification in Gosocket.00000000-0000-0000-0000-000000000000
CountryDocumentIdStringTax identifier (UUID) of the approved document.null When the document is not found, the response will be a UUID (36 alphanumeric characters).
OtherDataStringAdditional properties depending on the country.Example: "Country": "mx", "Certifier": "SAT", "AuthorityTimeStamp": "17/06/2025 11:40:47"
MessagesStringRules validated for the document according to SATExample: " Regla: Evento no puede ser registrado ya que el documento no se encuentra en estado aprobado."
ResponseValueStringResponse from the authority, base64 encoded.
CodeStringResponse code for the processSee the SAT Response Codes table
DescriptionStringDescription of the response of the process performedExample: "Solicitud de Cancelación enviado correctamente"
ErrorExceptionStringDescription of the exception when an error occurs.
SAT Response Codes
CodeDescription
201Cancellation request received.
202The receipt has already been previously canceled.
203The issuer's RFC does not match.
204Tax Folio Not Applicable for Cancellation
205Tax Folio Does Not Exist
206UUID does not correspond to a Primary Sector CFDI
207No cancellation reason was specified or the reason is not valid
208Invalid Substitution Folio
209Substitution Folio Not Required
210The cancellation request date is later than the filing date
211The cancellation request deadline for global invoices
212Invalid or nonexistent relation
300Invalid User
301Malformed XML: This error code is returned when the request has invalid information, e.g., an invalid receiver RFC
302Malformed Seal
304Revoked or Expired Certificate: The certificate may be invalid for multiple reasons such as type, validity, etc.
305Invalid Certificate: The certificate may be invalid for multiple reasons such as type, validity, etc.
309Invalid Certificate: The certificate may be invalid for multiple reasons such as type, validity, etc.
310Invalid CSD

How is the cancellation of a document shown in Inbox?

Once the cancellation request has been sent, the following data will be shown within the document preview in Inbox:

image-20240417-181111.png

  1. Within Notes we can see the date and time when the Tax Authority received the document's cancellation request.
  2. In this case, since it is a document that is cancelable without acceptance, it shows that the document has already been canceled.
  3. Within Attachments two files are shown. The first of these is the json of the document status query.
  4. Additionally, the SAT response json is shown.

Once the document has been canceled, it is shown as voided in the Inbox query screen:

image-20250617-210053.png

Example notes for:

  • Request received:

    image-20250617-201630.png

  • Cancelable without acceptance:

    image-20250617-201200.png

  • Cancelable with acceptance - waiting for a response to the request:

    image-20250617-204436.png

  • Cancelable with acceptance - Request Rejected:

    image-20250617-201407.png

  • Cancelable with acceptance - Request Accepted:

    image-20250617-201659.png

  • Cancelable with acceptance - Deadline expired:

    image-20250617-202638.png

  • Non-cancelable Document:

    image-20250617-204914.png