Skip to content

Rebuild Invoice

Corrects and re-signs a rejected document. The rebuilt document keeps the same accessKey, sequential, and issueDate as the original — only the invoice content is replaced.

POST /v1/documents/:accessKey/rebuild

Use this when a document is in RETURNED or NOT_AUTHORIZED status. After rebuilding, send it again with Send to SRI.

Works for any document type — the body shape must match the document's existing documentType. The example below is for an invoice (01); for a credit note (04), use the Create Credit Note body shape instead (no payments, requires originalDocument + motivo).

Authentication

Authorization: Bearer <api-key> and X-Issuer-Id: <issuer-id> (UUID from GET /v1/issuers)

Path parameters

ParameterDescription
accessKeyThe 49-digit access key of the document to rebuild

Request body

json
{
  "documentType": "01",
  "buyer": {
    "idType": "05",
    "id": "1234567890",
    "name": "John Doe",
    "email": "[email protected]",
    "address": "Av. Amazonas 123"
  },
  "items": [
    {
      "mainCode": "PROD-001",
      "auxiliaryCode": "AUX-001",
      "description": "Web development service",
      "quantity": "1.00",
      "unitPrice": "100.00",
      "discount": "0.00",
      "taxes": [
        {
          "code": "2",
          "rateCode": "2",
          "rate": "15.00",
          "taxableBase": "100.00",
          "taxAmount": "15.00"
        }
      ]
    }
  ],
  "payments": [
    {
      "method": "01",
      "total": "115.00",
      "term": 30,
      "termUnit": "dias"
    }
  ],
  "additionalInfo": [
    { "name": "Contract", "value": "CTR-2026-001" }
  ]
}

What is preserved from the original document

The following fields are always taken from the original document and cannot be changed via rebuild:

FieldReason
accessKeySRI ties all subsequent status checks to this key
sequentialSequential numbers are assigned once and not recycled
issueDateSRI validates the date embedded in the access key
documentTypeCannot change the type of an existing document

The documentType field is still required by validation, but must match the original document's type — the value supplied in the body is ignored at the service level.

What can be corrected

All invoice content fields are replaced atomically:

FieldTypeRequiredDescription
documentTypestringYesMust match the original document type (e.g. "01")
buyer.idTypestringYes2-digit SRI identification type code
buyer.idstringYesBuyer identification number (max 20 chars)
buyer.namestringYesBuyer full name or business name (max 300 chars)
buyer.emailstringYesBuyer email — used when the authorization email is sent
buyer.addressstringNoBuyer address (max 300 chars)
guiaRemisionstringNoDelivery note number in NNN-NNN-NNNNNNNNN format
itemsarrayYesReplaces all existing line items, including taxes
items[].mainCodestringYesProduct/service main code
items[].auxiliaryCodestringNoSecondary code
items[].descriptionstringYesDescription (max 300 chars)
items[].quantitystringYesNumeric quantity
items[].unitPricestringYesNumeric unit price
items[].discountstringNoNumeric discount amount
items[].taxesarrayYesAt least one tax per item
items[].taxes[].codestringYesSRI tax type code
items[].taxes[].rateCodestringYesSRI tax rate code
items[].taxes[].ratestringYesTax rate percentage
items[].taxes[].taxableBasestringYesAmount the tax is applied to
items[].taxes[].taxAmountstringYesCalculated tax amount
paymentsarrayYesReplaces all existing payment entries. Sum of total must equal the invoice total
payments[].methodstringYes2-digit SRI payment method code
payments[].totalstringYesNumeric payment amount
payments[].termnumberNoPayment term length
payments[].termUnitstringNoPayment term unit (e.g. "dias", "meses")
additionalInfoarrayNoReplaces all existing campoAdicional entries

The original payload is available in the requestPayload field on the Get Document response — use it to pre-fill the corrected request.

Response

200 OK

json
{
  "ok": true,
  "document": {
    "accessKey": "1503202601179234567800110010010000000011234567810",
    "documentType": "01",
    "sequential": "000000001",
    "status": "SIGNED",
    "issueDate": "15/03/2026",
    "total": "120.00",
    "buyer": {
      "id": "1234567890",
      "idType": "05",
      "name": "John Doe",
      "email": "[email protected]"
    },
    "email": {
      "status": "PENDING"
    }
  }
}

Errors

CodeStatusWhen
VALIDATION_FAILED400Request body fails field validation
VALIDATION_FAILED400Sum of payments[].total does not match the calculated invoice total
BAD_REQUEST400X-Issuer-Id header missing or malformed
INVALID_STATE_TRANSITION400Document is not in RETURNED or NOT_AUTHORIZED status
UNAUTHORIZED401Missing or invalid API key, or environment mismatch
FORBIDDEN403X-Issuer-Id issuer belongs to a different tenant
NOT_FOUND404X-Issuer-Id issuer does not exist
NOT_FOUND404Document not found

Comprobify API Documentation