HYBRID-CHAINDEVELOPERS
DOCUMENTATIONv2
POST

Merchant commerce

Cancel invoice

/api/v2/commerce/invoices/{invoice_uuid}/cancellations
AUTHENTICATIONBearer token · commerce:writeAUTHORITATIVE OWNERcommerce-serviceCONTRACT AUTHORITYGenerated Rust OpenAPISTATUSSource ready · production listed

PURPOSE + BUSINESS CONTEXT

Cancel an unpaid eligible invoice.

WHEN THIS CALL IS USEFUL

Cancel one exact unpaid OPEN or PAYMENT_PENDING invoice after reconciling the latest invoice version and linked Payments V2 request.

OUTCOME · Create or advance

What changes

Records CANCELLED and cancels an eligible linked OPEN payment request. It does not reverse payment, refund value, cancel a fulfilled order, return inventory, or settle a wallet.

WHY IT MATTERS

  • Gives people and agents a contract-backed way to advance invoice.
  • Connects catalog and invoice operations to payment collection and treasury reconciliation without making presentation state or a reserved address proof of payment.

ISOLATION + AUTHORITY

Tenant, workspace, merchant, product, customer, invoice, checkout, collection wallet, payment, custody, treasury settlement, tax or compliance policy, and finality remain distinct. Merchant configuration or invoice state cannot authorize wallet signing, move funds, prove settlement, or grant publisher, matching, or trading authority.

BEFORE YOU CALL

  • Authenticate at the documented boundary: bearer+scope.
  • Supply the required invoice_uuid (path), expected_invoice_version (body), expected_status (body), reason_code (body), step_up_token (body) exactly as defined by the live contract.
  • Use one Idempotency-Key only for retries of the same byte-equivalent logical mutation.

WHAT TO DO NEXT

  • Re-read invoice using the canonical identifier returned by this operation.
  • Reconcile an ambiguous response with the same idempotency key before attempting another mutation.
  • Open the canonical merchant, invoice, payment, or rotational-wallet record for the next stage and verify settlement independently before marking the commercial obligation complete.

AGENT GUIDANCE

  • Use invoice only for the purpose and lifecycle stage described by this operation; do not treat it as authority for an adjacent action.
  • Supply the required invoice_uuid (path), expected_invoice_version (body), expected_status (body), reason_code (body), step_up_token (body) exactly as defined by the live contract.
  • Distinguish merchant readiness, product availability, invoice issuance, checkout presentation, payment observation, wallet synchronization, treasury settlement, cancellation, and reconciliation.
  • After a timeout or conflict, read authoritative state before deciding whether an equivalent retry is safe.
MACHINE CONTRACT

The exact deployed parameters, schemas, responses, security requirements, and Hybrid-Chain agent metadata are authoritative at this operation's production OpenAPI JSON Pointer. The readable tables below add integration guidance; the deployed OpenAPI controls if guidance and the machine contract ever differ.

Open the authoritative production contract

EXTENDED INTEGRATION GUIDANCE

Readable request and response reference

Examples illustrate integration intent; the referenced OpenAPI operation and component schemas define the executable shape.

PARAMETERS

Headers, path, query, and body

NAMELOCATIONPRESENCETYPE / RULES / PURPOSE
AuthorizationheaderRequired

Bearer tokenCredential containing commerce:write authority.EXAMPLEBearer hc_live_…

invoice_uuidpathRequired

identifierStable invoice uuid selecting the exact resource addressed by this route.EXAMPLEinvoice-uuid-01

Idempotency-KeyheaderRequired

ASCII string · 1–128Caller-generated stable key reused for retries of the same logical mutation.EXAMPLEpost-api-v2-commerce-invoices-invoice-uuid-cancellations-request-001

X-Request-IDheaderOptional

stringOptional caller correlation identifier. The gateway emits the effective value on the response.

Content-DigestheaderRequired

stringRFC 9530 sha-256 digest of the exact transmitted request-body bytes.

Signature-InputheaderRequired

stringRFC 9421 sig1 input covering @method, @path, content-digest, content-type, and idempotency-key, with created, expires, nonce, keyid, and alg=ed25519.

SignatureheaderRequired

stringRFC 9421 sig1 Ed25519 signature made by an active key registered to the bearer client.

expected_invoice_versionbodyRequired

integer · ≥1Current invoice version used for optimistic concurrency.Schema range: 0 to unboundedEXAMPLE5

expected_statusbodyRequired

DRAFT | OPEN | PAYMENT_PENDINGLast merchant-visible status. Any authoritative final payment evidence makes cancellation ineligible.EXAMPLEOPEN

reason_codebodyRequired

MERCHANT_CANCELLED | CUSTOMER_REQUEST | ORDER_UNAVAILABLE | COMPLIANCE_HOLDStructured cancellation reason retained with invoice and checkout evidence.EXAMPLEMERCHANT_CANCELLED

reason_detailbodyOptional

string · 8–500 · nullableOptional non-secret explanation without payment credentials or regulated customer evidence.Explicit null acceptedEXAMPLEThe underlying order is no longer available.

step_up_tokenbodyRequired

purpose-bound tokenFresh COMMERCE_INVOICE_CANCELLATION authorization bound to invoice version and reason.EXAMPLEhcsu_…

REQUEST

JSON body example

{
  "expected_invoice_version": 0,
  "expected_status": "example-expected-status",
  "reason_code": "example-reason-code",
  "reason_detail": "example-reason-detail",
  "step_up_token": "example-step-up-token"
}

RESPONSES

Status and payload examples

200An eligible unpaid invoice becomes CANCELLED, its linked OPEN payment request is cancelled, and immutable cancellation evidence is returned.Mutation completed · JSON RESPONSE+
{}
INTEGRATION DECISION
CALLER ACTION
Accept the returned representation or receipt, then re-read invoice using the canonical identifier returned by this operation.
RETRY SAFETY
Do not repeat a successful mutation merely to confirm it. For one logical mutation, retain the same Idempotency-Key and byte-equivalent request. Never reuse that key for changed instructions.
STATE RECONCILIATION
Persist returned identifiers, versions, commitments, and receipts. Re-read the merchant or product version, invoice and linked payment-request state, and the exact network-scoped wallet projection before retrying with the same idempotency key and byte-equivalent request. Invoice state alone is not payment, settlement, or fulfillment finality.
400The version, status, reason, detail, step-up token, signature, or idempotency key is malformed.Request must change · JSON RESPONSE+
{
  "code": "invalid_credentials",
  "message": "the supplied Hybrid credential is invalid"
}
INTEGRATION DECISIONinvalid_credentials
CALLER ACTION
Rebuild the request from the live OpenAPI operation and correct the rejected method, media type, header, parameter, or body field.
RETRY SAFETY
Do not retry the same invalid request. For one logical mutation, retain the same Idempotency-Key and byte-equivalent request. Never reuse that key for changed instructions.
STATE RECONCILIATION
Compare the submitted values with the documented constraints before another call. Re-read the merchant or product version, invoice and linked payment-request state, and the exact network-scoped wallet projection before retrying with the same idempotency key and byte-equivalent request. Invoice state alone is not payment, settlement, or fulfillment finality.
ESCALATE WHEN
Escalate when a protected transition remains ambiguous after authoritative Commerce, Payments, and operational-wallet reconciliation. Commerce settlement execution remains frozen; never manufacture value movement by combining invoice, payment, or wallet calls.
404The invoice does not exist in the authenticated merchant boundary.Resource not visible · JSON RESPONSE+
{
  "code": "invalid_credentials",
  "message": "the supplied Hybrid credential is invalid"
}
INTEGRATION DECISIONinvalid_credentials
CALLER ACTION
Verify the canonical identifier and authenticated owner boundary. A 404 may intentionally conceal a resource outside the caller's authority.
RETRY SAFETY
Do not retry the unchanged identifier repeatedly. Refresh the relevant collection or lookup before choosing another identifier.
STATE RECONCILIATION
Re-read the merchant or product version, invoice and linked payment-request state, and the exact network-scoped wallet projection before retrying with the same idempotency key and byte-equivalent request. Invoice state alone is not payment, settlement, or fulfillment finality.
ESCALATE WHEN
Escalate when a protected transition remains ambiguous after authoritative Commerce, Payments, and operational-wallet reconciliation. Commerce settlement execution remains frozen; never manufacture value movement by combining invoice, payment, or wallet calls.
409The invoice version or state is stale, final payment evidence exists, fulfillment is committed, cancellation is terminal, or the Idempotency-Key conflicts.State reconciliation required · JSON RESPONSE+
{
  "code": "invalid_credentials",
  "message": "the supplied Hybrid credential is invalid"
}
INTEGRATION DECISIONinvalid_credentials
CALLER ACTION
Stop the mutation sequence and fetch the latest authoritative resource, lifecycle state, version, ETag, reservation, or existing idempotency result.
RETRY SAFETY
Retry only after reconciling the conflict. For one logical mutation, retain the same Idempotency-Key and byte-equivalent request. Never reuse that key for changed instructions.
STATE RECONCILIATION
Re-read the merchant or product version, invoice and linked payment-request state, and the exact network-scoped wallet projection before retrying with the same idempotency key and byte-equivalent request. Invoice state alone is not payment, settlement, or fulfillment finality.
ESCALATE WHEN
Escalate when a protected transition remains ambiguous after authoritative Commerce, Payments, and operational-wallet reconciliation. Commerce settlement execution remains frozen; never manufacture value movement by combining invoice, payment, or wallet calls.
503Commerce, Payments, checkout, order, or evidence ownership is unavailable; invoice and checkout state remain unchanged.Dependency unavailable or outcome uncertain · JSON RESPONSE+
{
  "code": "invalid_credentials",
  "message": "the supplied Hybrid credential is invalid"
}
INTEGRATION DECISIONinvalid_credentials
CALLER ACTION
Preserve the exact request and treat the outcome as uncertain until authoritative state proves whether it committed.
RETRY SAFETY
Reconcile before retrying. For one logical mutation, retain the same Idempotency-Key and byte-equivalent request. Never reuse that key for changed instructions. Use bounded backoff with jitter.
STATE RECONCILIATION
Re-read the merchant or product version, invoice and linked payment-request state, and the exact network-scoped wallet projection before retrying with the same idempotency key and byte-equivalent request. Invoice state alone is not payment, settlement, or fulfillment finality.
ESCALATE WHEN
Escalate when a protected transition remains ambiguous after authoritative Commerce, Payments, and operational-wallet reconciliation. Commerce settlement execution remains frozen; never manufacture value movement by combining invoice, payment, or wallet calls.

OPERATIONAL NOTES

Security and lifecycle guarantees

  • Cancel an unpaid eligible invoice. Authoritative owner: commerce-service.
  • The Rust gateway validates the public contract and routes only to the authoritative owner; clients never address internal services directly.
  • Mutations are retry-safe only when the same Idempotency-Key and canonical request body are reused.
  • The tables and examples are derived from the current gateway source OpenAPI. Re-fetch the deployed OpenAPI before execution; deployment status is shown separately on this page.
  • Only parameters present in the OpenAPI operation are accepted; undocumented query keys fail closed with HTTP 422.
DOCUMENTATION STATUS

This route is implemented in canonical gateway source and appears in the production OpenAPI snapshot observed 2026-09-11T06:35:11.572Z. Authentication, tenant, feature, venue, and market policy still apply.

Verify the exact production OpenAPI operation Return to the V2 directory