Skip to content

Create Invoice

Creates, validates, and signs a new electronic invoice.

POST /v1/documents

Authentication

Authorization: Bearer <api-key>

Headers

HeaderRequiredDescription
AuthorizationYesBearer API key
X-Issuer-IdYesNumeric id 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": "01",
  "issueDate": "15/03/2026",
  "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" }
  ]
}

Field reference

FieldTypeRequiredDescription
documentTypestringYesDocument type code. Currently only "01" (factura) is supported
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)
guiaRemisionstringNoDelivery note number in NNN-NNN-NNNNNNNNN format (e.g. 001-001-000000001)
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
paymentsarrayYesAt least one payment required
payments[].methodstringYes2-digit SRI payment method code
payments[].totalstringYesNumeric payment amount
payments[].termnumberNoPayment term length — maps to SRI plazo
payments[].termUnitstringNoPayment term unit code — maps to SRI unidadTiempo. Must be one of the values returned by GET /v1/catalogs/term-units (e.g. "dias", "meses")
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": "1503202601179234567800110010010000000011234567810",
    "documentType": "01",
    "sequential": "000000001",
    "status": "SIGNED",
    "issueDate": "15/03/2026",
    "total": "115.00",
    "email": {
      "status": "PENDING"
    }
  }
}

Idempotency

Include an Idempotency-Key header to make creation idempotent. Generate the key once per intended invoice 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
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