Record a correction to a registered contract
Records a correction to something the client already asserted about a registered contract, and publishes the fact that names it.
This is NOT a Dataprev operation: no rail credential is used and no government boundary is crossed. Manual 005 revision 1.13 states the rail’s retification fields are no longer used and always return null, so the client is the only authority a correction can have — source_authority is always client.
NOTHING IS MUTATED. A correction is an append that names what it supersedes, and the record it corrects stays immutable in the database exactly as it was. Correcting the same thing twice appends a second correction that supersedes the first.
The gateway takes custody of the corrected resource and computes its SHA-256 itself; a client-declared digest is never accepted. The published fact carries a same-origin path back to this gateway plus that digest, and the consumer fetches and verifies it over authenticated M2M.
| correction_type | payment_reference | supersedes |
|---|---|---|
ccb | must be empty | the previous CCB correction, or nothing on the first |
disbursement | required | the confirmed payment it repairs, then the previous correction of that payment |
A disbursement correction naming a payment this deployment holds no confirmation for is refused with 404: a supersession pointing at nothing is worse than no correction.
X-Idempotency is mandatory, opaque, 1..128 bytes, and never defaulted. PostgreSQL is the authority: the same key replays the identical 202 body and publishes no second fact, and the same key carrying a different correction answers 422 without ever returning the earlier body.
Authorizations
JWT bearer token issued by the identity provider.
Headers
Mandatory opaque replay key, 1..128 bytes of valid UTF-8, preserved byte for byte. No default, no alias header, no case folding: two keys differing in one byte are two keys.
1 - 128"idem-correcao-0001"
Path Parameters
The rail contract number the correction is about. Exact, control-free UTF-8, bounded in BYTES: 2..15, which is the consumer's own bound for this field.
2 - 15"99999999999AN1"
Body
Media type of the corrected resource. Its media type must be application/pdf or application/zip — parameters are permitted — and the bytes are sniffed against it.
128"application/pdf"
What this correction corrects. Selects which fact is published; the payload shape is identical for both.
ccb, disbursement "ccb"
Original file name of the corrected resource.
255"ccb-corrigida.pdf"
The payment_reference of the confirmed disbursement this correction repairs. Required when correction_type is disbursement, and must be empty otherwise.
256"E32074986202608011200A1B2C3D4E5F"
Canonical base64 of the corrected resource. The gateway computes the SHA-256 itself; no client-declared digest is accepted.
8388608"JVBERi0xLjcKJSVFT0Y="
Response
The correction is durably recorded and its fact queued. A replay under the same key answers with the identical body.
The gateway's identity for this correction. It is also the published event id.
"1f5b9c26-6f5a-4f77-9c1c-5d1c0f0a9b21"
What was corrected.
"ccb"
When the gateway took custody, strict RFC 3339 UTC.
"2026-08-29T12:00:05Z"
The rail contract number, echoed from the path.
"99999999999AN1"
Lowercase hex SHA-256 the gateway computed over the corrected bytes.
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
Same-origin relative path serving the corrected resource under M2M bearer auth.
"/v1/consignado/contracts/99999999999AN1/corrections/1f5b9c26-6f5a-4f77-9c1c-5d1c0f0a9b21"
Who is authoritative for the corrected value. Always client on this gateway.
"client"
The event id this correction supersedes: the corrected disbursement confirmation, or the previous correction. ABSENT on a first CCB correction, meaning the original contract fact.
"7c2a1b40-11f4-4a1e-9a44-1f4d7cbb8e02"

