Skip to content

Issuer Sequentials

View and manually correct an issuer's sequential number counters. Sandbox and production are tracked independently (separate PostgreSQL schemas), so both are reported side by side.

Authentication

Authorization: Bearer <api-key>

Both endpoints below take the issuer id as a URL parameter and verify it belongs to your tenant before applying any change.


View current sequentials

GET /v1/issuers/:id/sequentials

Returns one row per active document type for the issuer, with the current counter value and the sequential each environment would produce next.

Path parameters

ParameterDescription
idIssuer UUID

Response

json
{
  "ok": true,
  "sequentials": [
    {
      "documentType": "01",
      "sandbox": { "current": 12, "next": 13 },
      "production": { "current": 104, "next": 105 }
    },
    {
      "documentType": "04",
      "sandbox": { "current": 0, "next": 1 },
      "production": { "current": 0, "next": 1 }
    }
  ]
}

A document type that has never issued a document in an environment reports current: 0, next: 1.

Errors

StatusCodeWhen
400VALIDATION_FAILEDid is not a positive integer
401UNAUTHORIZEDMissing or invalid API key
403ISSUER_FORBIDDENIssuer belongs to a different tenant
404ISSUER_NOT_FOUNDIssuer not found or inactive
429TOO_MANY_REQUESTSRate limit exceeded

Set the next sequential

PATCH /v1/issuers/:id/sequentials/:documentType

Manually sets the counter for one document type in one environment, so the next document created picks up nextSequential. Typically used to correct a counter after migrating from another invoicing system, or to skip past a block of numbers already used outside the API.

The write locks the counter row (SELECT ... FOR UPDATE) inside the same transaction that updates it, so it cannot race against a concurrent POST /v1/documents call and produce a duplicate sequential.

Path parameters

ParameterDescription
idIssuer UUID
documentTypeSRI document type code (e.g. 01)

Request body

json
{
  "environment": "production",
  "nextSequential": 200
}
FieldTypeRequiredDescription
environmentstringYessandbox or production
nextSequentialintegerYesThe sequential the next document of this type/environment should receive. Must be greater than the counter's current value.

Response

200 OK

json
{ "ok": true }

Errors

StatusCodeWhen
400VALIDATION_FAILEDdocumentType is not a supported type, environment is not sandbox/production, or nextSequential is not a positive integer
400SEQUENTIAL_CANNOT_DECREASEnextSequential does not exceed the counter's current value
401UNAUTHORIZEDMissing or invalid API key
403ISSUER_FORBIDDENIssuer belongs to a different tenant
404ISSUER_NOT_FOUNDIssuer not found or inactive
429TOO_MANY_REQUESTSRate limit exceeded

Comprobify API Documentation