Errors#

Errors return a non-2xx status with a JSON body containing a human-readable error and a stable machine-readable code. Validation failures add a details object keyed by field.

{
  "error": "Validation failed.",
  "code": "VALIDATION_ERROR",
  "details": {
    "cover_amount": ["The cover amount may not be greater than 15000."]
  }
}

Always branch on code, never on the error text - the wording may change, the codes will not.

Status codes#

StatusMeaning
200Success.
201Resource created (sessions, agreements, invoices).
400The request is understood but not allowed in the current state.
401Missing or invalid API key.
403Gateway not enabled for the entity.
404Resource not found, or not owned by your entity.
422Validation failed.
429Rate limit exceeded.
500Unexpected server error.

Common codes#

CodeStatusMeaning
VALIDATION_ERROR422One or more fields failed validation. See details.
SESSION_NOT_FOUND404No session with that ID for your entity.
SESSION_CREATION_FAILED500Session could not be created.
AGREEMENT_NOT_FOUND404No agreement with that ID for your entity.
AGREEMENT_NOT_ACTIVE400Agreement exists but is not active.
AGREEMENT_NO_TENANT400Agreement has no tenant attached.
AGREEMENT_CREATION_FAILED500Agreement could not be created.
CANCEL_FAILED400Session cannot be cancelled - already terminal, or already paid.
INVALID_API_KEY401Key not recognised or revoked.
GATEWAY_NOT_ENABLED403Gateway disabled for the entity.

Business-rule errors#

Some 4xx responses reject an otherwise well-formed request because of a domain rule:

MessageRule
deposit_mode is required when cover_amount is greater than 0.A guarantee needs an explicit deposit decision.
payment_link agreements cannot have cover_amount.Payment links carry no guarantee.
Either amount, cover_amount, or first_payment_amount is required.A session must charge something.
Session payment has already completed and cannot be cancelled.Paid sessions are immutable.

See Amounts and pricing for the full set of amount rules.