heruAPI
Batches

Cancel a batch

BuildingIn development for the v1 API. The contract is set; the route is not served yet.

POST
/batches/{id}/cancel

Stops what is pending. It never cancels a CFDI: documents already stamped stay stamped and appear in the report; to cancel one, use its own DELETE endpoint.

What is on its way to the PAC finishes, and every document not yet sent becomes cancelled with BATCH_CANCELLED. The batch goes cancelling, which can last tens of minutes on a very large file, and then cancelled. The exception is awaiting_upload: it goes straight to cancelled, with no report. A later batch can take the same file: what was stamped comes back duplicate and only the rest is stamped. If everything was already stamped, the new batch ends done with its report and stamps nothing. A batch still unfinished 20 days after it was created is cancelled in the same way.

Allowed in awaiting_upload, validating, ready, processing and paused. From ready on, the batch ends with report_url; before that it has no report. batch.done fires with status cancelled only if the batch had reached POST /batches/{id}/process. Cancelling a batch that is cancelling or cancelled answers 202 with no change. done and invalid answer 409 BATCH_INVALID_STATE, and so does a batch in processing whose documents have all finished, because its report is being written and it is about to be done.

Needs the batches:write scope. It takes no body and no Idempotency-Key: repeating it is safe.

Authorization

oauth2 batches:write
headerAuthorizationBearer <token>

OAuth 2.0 client credentials. Exchange your client_id and client_secret at /oauth/token of the environment for a bearer token valid for one hour. The playground of every operation asks for your own client and keeps it in your browser tab only.

Scope: batches:write

Path parameters

id*string

The batch id.

Match^bat_[0-7][0-9a-hjkmnp-tv-z]{25}$

Response body

Accepted

application/json
  1. response
id?string
Match^bat_[0-7][0-9a-hjkmnp-tv-z]{25}$
type?string

What the rows of the CSV are: invoice or retention_certificate. Each type has its own columns, listed in the batches guide.

Value in"invoice""retention_certificate"
status?string

awaiting_upload until the whole file arrives at upload_url; validating while heru checks every row; ready when at least one document is valid; done when no document is invalid and every document is a duplicate, so nothing is stamped and the batch closes with its report and fires batch.done, without going through POST /batches/{id}/process; invalid when no document is valid and at least one failed validation, the file itself has an error or the upload window ended; processing after POST /batches/{id}/process; paused after POST /batches/{id}/pause; cancelling after POST /batches/{id}/cancel, or when the batch reaches 20 days unfinished, while heru stops what is pending and writes the report, then cancelled; done when every valid document has its outcome. invalid, cancelled and done are final.

Value in"awaiting_upload""validating""invalid""ready""processing""paused""cancelling""cancelled""done"
created_at?string

When the batch was created with POST /batches. The 20 days of the batch's life count from here: see processing pace.

Formatdate-time
defaults?

The defaults of the request, normalized: 16% comes back as 0.16.

upload_url?|null
upload_expires_at?|null
upload_max_bytes?integer

The largest file upload_url takes, in bytes, compressed or not: 34359738368 (32 GiB).

Formatint64
total_rows?integer

Data rows in the file. Final once heru has read the whole file.

validated_rows?integer

Rows checked so far. Compare it with total_rows while the batch is validating.

valid_rows?integer

Rows that passed their own checks. A valid row can belong to an invalid document, which is not processed: progress is counted in documents.

invalid_rows?integer

Rows with at least one problem.

total_documents?integer

Documents in the file: rows that share external_id are one document. Final once heru has read the whole file.

valid_documents?integer

Documents with every row valid and not stamped before. Only these are processed. It does not change after ready.

invalid_documents?integer

Documents with at least one invalid row. None of their rows is processed.

duplicates?integer

Documents whose external_id was already stamped. They are not stamped again and the report gives their id and uuid. A document already stamped wins over its own validation errors: it counts here, not in invalid_documents.

processed_documents?integer

Valid documents with an outcome so far: succeeded + failed + cancelled + pending_review. Compare it with valid_documents while the batch is processing.

in_flight_documents?integer

Documents already prepared and on their way to the PAC. They keep moving while the batch is paused, so this says how much is left before the counters stop.

succeeded?integer

Documents stamped.

failed?integer

Valid documents that failed when processed, e.g. refused by the stamping authority. The reason is in the report. A failed document can go again in a new batch.

cancelled?integer

Valid documents never processed because the batch was cancelled.

pending_review?integer

Documents with no outcome when the batch closed. They are not lost: if one gets stamped later, its webhook arrives.

estimated_completion_at?|null
fits_lifetime?|null
receiver_overrides?integer

Documents whose receiver data in the file differs from the data registered in heru, which is what gets stamped. Estimated during validation and final when the batch closes; the report names the columns.

errors?array<>

The first 100 problems, in row order. error_count has the total and errors_url all of them. Final when the batch leaves validating.

error_count?integer

Total problems found, which can be more than errors shows.

errors_url?|null
report_url?|null
curl -X POST 'https://api.dev.b2b.heru.app/v1/batches/bat_01m4ra8wpbev7sf851m6pn6gm7/cancel'
{  "id": "bat_01m4ra8wpbev7sf851m6pn6gm7",  "type": "invoice",  "status": "cancelling",  "created_at": "2026-10-28T15:04:05Z",  "defaults": {    "payment_form": "03",    "quantity": "1",    "unit_code": "E48",    "tax_object": "02",    "vat_rate": "0.16"  },  "upload_url": null,  "upload_expires_at": null,  "upload_max_bytes": 34359738368,  "total_rows": 1250,  "validated_rows": 1250,  "valid_rows": 1247,  "invalid_rows": 3,  "total_documents": 1100,  "valid_documents": 1092,  "invalid_documents": 3,  "duplicates": 5,  "processed_documents": 800,  "in_flight_documents": 40,  "succeeded": 640,  "failed": 1,  "cancelled": 159,  "pending_review": 0,  "estimated_completion_at": "2026-11-09T18:00:00Z",  "fits_lifetime": true,  "receiver_overrides": 2,  "errors": [    {      "row": 18,      "column": "receiver_rfc",      "code": "INVALID_RFC",      "reason": "Does not have the format of an RFC"    },    {      "row": 402,      "column": "unit_price",      "code": "NEGATIVE_AMOUNT",      "reason": "Must not be negative"    },    {      "row": 977,      "column": "product_code",      "code": "INVALID_CODE",      "reason": "Not in the SAT catalog c_ClaveProdServ"    }  ],  "error_count": 3,  "errors_url": "https://files.heru.app/batches/bat_01m4ra8wpbev7sf851m6pn6gm7-errors.csv.gz",  "report_url": null}
© 2026 Kuarto Inc. (heru)heru.appQuestions about your integration? Contact your heru account team.