Skip to Content
API reference

Errors

The error response of the Altruon API, every documented error code and HTTP status, and what to do about each one.

When a request fails, the API responds with a 4xx or 5xx HTTP status and a JSON body with one error object. Branch on error.code. Show or log error.message.

Error response

{
  "error": {
    "code": "invalid_request",
    "message": "Missing required field: paymentData.currency",
    "details": {}
  }
}
errorobject

Present on every failed request.

codestring

Machine-readable error code. One of the codes below.

messagestring

What went wrong, in plain English, for example Missing required field: paymentData.currency.

detailsobject

Additional detail about the error. An empty object in the example above.

Error codes

CodeMeaningWhat to do
invalid_requestA request parameter is missing or invalid.Read error.message, then compare your body with the request fields.
unauthorizedThe secret key is missing or invalid.Send your secret key in the x-secret-key header. See Authentication.
invalid_line_itemA line item ID was not found or is not valid.Check that every billingData.lineItems[].id exists on the billing platform behind billingPlatformId.
invalid_billing_platformThe billing platform is not configured.Connect the billing platform in the backoffice under Settings > Billing Platforms and send its ID in billingData.billingPlatformId. See Billing platforms.
rate_limit_exceededToo many requests.Retry with a backoff: wait before each retry, and wait longer each time.

HTTP statuses

StatusWhenReturned by
200The request succeeded.Create a session
400billingData.forceTrialPeriodDays is outside 1 to 730, or is combined with hostedPageConfigId.Create a session
401The secret key is missing or invalid.Get transaction details
404No transaction has the ID in the path.Get transaction details
Other 4xx, 5xxThe request failed. Read the error object.Both endpoints

Tell errors apart by error.code, not by the status alone.

Rejections at session creation

These requests are also rejected when you create a session:

RequestResultWhat to do
A trial with nothing due today, on an acquirer and payment method that does not support trialsAn unsupported errorUse a combination from the trial matrix in Trials, or leave paymentMethod out so hosted checkout shows only the methods that support trials.
A key in billingData.customerCustomFields that does not start with cf_The key is rejectedPrefix every key with cf_.
A coupon in billingData.couponCodes that the billing platform does not knowThe billing platform rejects itSend coupon IDs or codes that exist on the billing platform. See Coupons.

A forceTrialPeriodDays at the top level of the body is not an error. It is ignored, and no trial is forced. Nest it inside billingData.

Payment failures are not API errors

A declined or failed payment does not produce an error object. You learn about it in other places:

Handle errors in code

server.js
const response = await fetch(url, options);
const data = await response.json();

if (!response.ok) {
  switch (data.error.code) {
    case 'rate_limit_exceeded':
      // Wait, then retry.
      break;
    case 'unauthorized':
      // Wrong or missing secret key. Fix the configuration.
      break;
    case 'invalid_request':
    case 'invalid_line_item':
    case 'invalid_billing_platform':
    default:
      // The request cannot succeed as sent.
      throw new Error(`${data.error.code}: ${data.error.message}`);
  }
}