Skip to content

Create Credit Note

Creates, validates, and signs a new electronic credit note (nota de crédito) referencing a previously authorized invoice.

POST /v1/documents

This is the same endpoint as Create Invoice — the request body shape is selected by documentType. A credit note's body has no payments block and instead requires originalDocument (the invoice being credited) plus a motivo (reason).

The issuer must have document type 04 enabled — see Document Types.

Before submitting, check Get Credit Notes against the original document's access key to see how much of its total has already been credited — the API does not reject a credit note for exceeding the original's remaining balance, since SRI itself doesn't enforce that; it's a client-side guard.

Authentication

Authorization: Bearer <api-key>

Headers

HeaderRequiredDescription
AuthorizationYesBearer API key
X-Issuer-IdYesUUID of the issuing branch (from GET /v1/issuers). Identifies which branch and certificate to use.
Content-TypeYesapplication/json
Idempotency-KeyNoUnique string (max 255 chars) — see idempotency

Request body

json
{
  "documentType": "04",
  "issueDate": "05/04/2026",
  "buyer": {
    "idType": "05",
    "id": "1234567890",
    "name": "John Doe",
    "email": "[email protected]",
    "address": "Av. Amazonas 123"
  },
  "originalDocument": {
    "documentType": "01",
    "number": "001-001-000000027",
    "issueDate": "03/04/2026"
  },
  "motivo": "Devolución de mercadería por defecto de fabricación",
  "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"
        }
      ]
    }
  ],
  "additionalInfo": [
    { "name": "Contract", "value": "CTR-2026-001" }
  ]
}

Field reference

FieldTypeRequiredDescription
documentTypestringYesMust be "04" for this body shape
issueDatestringNoDate in DD/MM/YYYY format. Must be today's date — SRI rejects past and future dates. Defaults to today if omitted
buyer.idTypestringYes2-digit SRI identification type code (e.g. "05" = cedula, "04" = RUC)
buyer.idstringYesBuyer identification number (max 20 chars)
buyer.namestringYesBuyer full name or business name (max 300 chars)
buyer.emailstringYesBuyer email — RIDE and XML are sent here on authorization
buyer.addressstringNoBuyer address (max 300 chars)
originalDocument.documentTypestringYesSRI document type code of the document being credited (e.g. "01" for a factura)
originalDocument.numberstringYesAccess-key-style number of the original document, format NNN-NNN-NNNNNNNNN
originalDocument.issueDatestringYesIssue date of the original document, DD/MM/YYYY
motivostringYesReason for the credit note (max 300 chars)
itemsarrayYesAt least one item required
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
additionalInfoarrayNoKey-value pairs included in the XML as campoAdicional

Response

201 Created — new document created. 200 OK — returned when the same Idempotency-Key + identical payload was already processed.

json
{
  "ok": true,
  "document": {
    "accessKey": "0504202604179234567800110010010000000271234567810",
    "documentType": "04",
    "sequential": "000000027",
    "status": "SIGNED",
    "issueDate": "05/04/2026",
    "total": "115.00",
    "email": {
      "status": "PENDING"
    }
  }
}

Idempotency

Include an Idempotency-Key header to make creation idempotent. Generate the key once per intended credit note and reuse it across retries:

  • Same key + same payload → returns the existing document (no duplicate created)
  • Same key + different payload → 409 Conflict

Errors

CodeStatusWhen
VALIDATION_FAILED400Request body fails field validation
DOCUMENT_TYPE_NOT_ENABLED400The issuer does not have document type 04 enabled — see Document Types
BAD_REQUEST400X-Issuer-Id header missing or malformed
UNAUTHORIZED401Missing or invalid API key, or environment mismatch (sandbox key targeting a production issuer or vice versa)
FORBIDDEN403The X-Issuer-Id issuer belongs to a different tenant
NOT_FOUND404The X-Issuer-Id issuer does not exist
CONFLICT409Idempotency key reused with a different payload
INTERNAL_ERROR500Unexpected server error

Comprobify API Documentation