Documentation

Documentation/API reference/Endpoints/

POST /v1/card-authorizations

Decide a card or ATM authorisation in real time

Records the card event, evaluates the institution's active real-time card rules and answers APPROVED or DECLINED at once; alerts, card actions (suspend, terminate) and the AI triage follow in the background and the answer never waits for them.

A refund (CARD_REFUND) or a reversal (CARD_REVERSAL) is recorded and evaluated by the same rules, and answered REFUNDED or REVERSED: it is never declined. A reversal names the approved authorisation or withdrawal of the same card it undoes (original_event_ref, the event_ref answered for it); a refund may. What is refunded and reversed against one event never exceeds its amount.

The card must already be registered for your institution under the same data classification (POST /v1/cards, or the card file on the Data imports screen); otherwise the event is refused with unknown card_token. A card a rule suspends or terminates on this event is reported to your webhook (card.suspended, card.terminated; the cardStatusChanged webhook), seconds after the answer.

The Idempotency-Key header is required: a card event is recognised only by it. Without it the event is refused (400) before anything else is read. Send a unique key for each event and the same key when you retry: a repeated key answers the card event's first decision with duplicate: true, and two requests with the same key wait for each other, so a concurrent repeat answers the card event's first decision too. A repeat must be the same event: one whose card_token, event_type, amount or currency differs from the first is refused 409 and nothing is stored.

Currencies, merchant_country and the card codes are upper-cased on arrival and checked before anything is stored (see CardAuthorizationRequest): a value of the wrong type or outside its values is a 400 naming the field. event_type and data_classification are compared exactly as sent. cvv_result or pin_result NO_MATCH declines the event. A card_token beginning EXAMPLE- is refused.

Parameters

NameInDescription
Idempotency-Key requiredheader

Required for card events: a card event is recognised only by this key. Send a unique key for each event (for example a UUID), at most 255 characters, and the same key when you retry it. Without it, or with a blank one, the event is refused (400) before anything else is read. A repeated key with the same card_token, event_type, amount and currency answers the card event's first decision with duplicate: true; with another of them it is refused 409. Requests with the same key wait for each other, so a concurrent repeat answers the card event's first decision too.

Request body

CardAuthorizationRequest

A JSON object, at most 64 000 characters.

Example: An e-commerce card payment (example references; an EXAMPLE- card token is refused)

{
  "event_type": "CARD_AUTHORIZATION",
  "card_token": "EXAMPLE-CARD-0001",
  "amount": 49.9,
  "currency": "EUR",
  "event_time": "2026-09-02T18:04:11Z",
  "merchant_name": "Example Shop UAB",
  "merchant_id": "EXAMPLE-MERCHANT-01",
  "mcc": "5732",
  "merchant_country": "LT",
  "entry_mode": "ECOMMERCE",
  "three_ds_result": "AUTHENTICATED",
  "data_classification": "TEST"
}

Example: A reversal of an approved authorisation (original_event_ref is the event_ref answered for it)

{
  "event_type": "CARD_REVERSAL",
  "card_token": "EXAMPLE-CARD-0001",
  "amount": 49.9,
  "currency": "EUR",
  "original_event_ref": "CAE-2026-000321",
  "data_classification": "TEST"
}

Request sample

curl -X POST "$UNDERLAYER_BASE_URL/v1/card-authorizations" \
  -H "X-API-Key: $UNDERLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <a unique key for this request>" \
  --data-binary @- <<'JSON'
{
  "event_type": "CARD_AUTHORIZATION",
  "card_token": "EXAMPLE-CARD-0001",
  "amount": 49.9,
  "currency": "EUR",
  "event_time": "2026-09-02T18:04:11Z",
  "merchant_name": "Example Shop UAB",
  "merchant_id": "EXAMPLE-MERCHANT-01",
  "mcc": "5732",
  "merchant_country": "LT",
  "entry_mode": "ECOMMERCE",
  "three_ds_result": "AUTHENTICATED",
  "data_classification": "TEST"
}
JSON
import os
import requests

response = requests.post(
    os.environ["UNDERLAYER_BASE_URL"] + "/v1/card-authorizations",
    headers={"X-API-Key": os.environ["UNDERLAYER_API_KEY"], "Idempotency-Key": "<a unique key for this request>"},
    json={
      "event_type": "CARD_AUTHORIZATION",
      "card_token": "EXAMPLE-CARD-0001",
      "amount": 49.9,
      "currency": "EUR",
      "event_time": "2026-09-02T18:04:11Z",
      "merchant_name": "Example Shop UAB",
      "merchant_id": "EXAMPLE-MERCHANT-01",
      "mcc": "5732",
      "merchant_country": "LT",
      "entry_mode": "ECOMMERCE",
      "three_ds_result": "AUTHENTICATED",
      "data_classification": "TEST"
    },
)
print(response.status_code, response.json())
const response = await fetch(process.env.UNDERLAYER_BASE_URL + "/v1/card-authorizations", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.UNDERLAYER_API_KEY,
    "Content-Type": "application/json",
    "Idempotency-Key": "<a unique key for this request>",
  },
  body: JSON.stringify({
    "event_type": "CARD_AUTHORIZATION",
    "card_token": "EXAMPLE-CARD-0001",
    "amount": 49.9,
    "currency": "EUR",
    "event_time": "2026-09-02T18:04:11Z",
    "merchant_name": "Example Shop UAB",
    "merchant_id": "EXAMPLE-MERCHANT-01",
    "mcc": "5732",
    "merchant_country": "LT",
    "entry_mode": "ECOMMERCE",
    "three_ds_result": "AUTHENTICATED",
    "data_classification": "TEST"
  }),
});
console.log(response.status, await response.json());

Written from the example on this page. UNDERLAYER_BASE_URL is https://api.underlayer.eu; UNDERLAYER_API_KEY is yours, given at onboarding.

Responses

StatusBodyDescription
200CardAuthorizationResult

The decision (APPROVED or DECLINED; REFUNDED or REVERSED for a refund or reversal), or a replayed duplicate (duplicate: true).

400ErrorBody

The body is not a JSON object, or the database refused the event with a VALIDATION: message, answered without its prefix. A missing Idempotency-Key and a value of the wrong type are refused this way. The messages are listed on the Errors page, "Card refusals (400)"; % stands for the field or its values:

  • the Idempotency-Key header is required for card events: send a unique key for each event and the same key when you retry it
  • the Idempotency-Key may be at most 255 characters
  • data_classification % is not accepted by the decisioning engine
  • data_classification % is accepted only by a sandbox institution: a production institution takes PRODUCTION data only
  • event_type must be CARD_AUTHORIZATION, ATM_WITHDRAWAL, CARD_REFUND or CARD_REVERSAL
  • % is required
  • % must be a number
  • % must be a decimal number such as 125.50 (no exponent, NaN or Infinity)
  • % may have at most two decimals
  • % exceeds the largest supported amount, 999999999999.99
  • % must be greater than zero
  • % must be a three-letter ISO 4217 currency code such as EUR
  • % must be a two-letter ISO 3166-1 alpha-2 country code such as LT
  • % must be one of %
  • card_token is required
  • references beginning EXAMPLE- come from the documentation and are refused: send your own references
  • event_time must be a date YYYY-MM-DD or a date-time YYYY-MM-DDThh:mm[:ss[.ffffff]] with an optional zone Z, +hh:mm or -hh:mm (no zone = UTC), such as 2026-09-01T14:30:00Z
  • unknown card_token
  • card_txn_type of a refund must be REFUND
  • original_event_ref is required for a reversal: send the event_ref of the authorisation or withdrawal it reverses
  • original_event_ref must name an approved authorisation or withdrawal of this card
  • currency must be the currency of the original event
  • event_time cannot be before the original event
  • amount exceeds what is left of the original event to refund or reverse
  • billing_amount is required when billing_currency is not the billing currency of the original event

Correct the request; do not send it again unchanged.

401ErrorBody

The key is missing, malformed (not <key_id>.<secret>), unknown, revoked or wrong. Check the key; do not retry the same request.

403ErrorBody

The key is limited to allowed addresses and the request came from another one, the institution is not active, or this key may not send this data classification.

409ErrorBody

The request repeats an earlier card event's Idempotency-Key but is not the same event; nothing was stored. this Idempotency-Key was already used for a card event with a different %: retry with the same body, or send a new event with a new Idempotency-Key (% names the fields that differ: card_token, event_type, amount, currency; never a value).

413ErrorBody

The body is larger than the limit (64 000 bytes for payments, card events and customer events, 2 000 000 for a CDD import); a larger Content-Length is refused before the body is read and before the key is checked. Split it.

429ErrorBody

Rate limited. Wait the seconds in Retry-After, then retry the same request. Limits are per server instance: 3 000 requests a minute per key (bursts of 1 000), 120 a minute per address for keys not yet seen, and 20 failed authentications per address within 10 minutes, after which the address is refused for 10 minutes, the right key included.

500ErrorBody

The database refused the event with something other than a validation message, a fault on our side; code is its error code. A value of the wrong type is never answered here (it is a 400), and neither is a concurrent request with the same Idempotency-Key (it waits for the first). Retry once with the same Idempotency-Key; contact Underlayer with the code if it comes back.

503ErrorBody

The service cannot take the payment or card event now; nothing was stored and your key was not judged. Service busy: every decision this server instance runs at once is taken, your institution already holds its share of them (known once the key is checked), or a request with the same API key and Idempotency-Key is still being decided here. It is answered at once, before anything is stored; wait the seconds in Retry-After (1). Service unavailable: the key could not be checked (the database did not answer three tries); wait Retry-After (5). Service temporarily unavailable: a setting of the service is unusable (no Retry-After). Retry the same request with back-off (for example 1 s, 2 s, 4 s ... up to a minute): a payment's source_system + external_transaction_id (and Idempotency-Key), and a card event's Idempotency-Key, make the retry safe: it never creates a second payment or card event (what a repeat answers is in the Idempotency and retries guide).

Examples of 200

Example: approved

{
  "duplicate": false,
  "event_id": "00000000-0000-4000-8000-000000000031",
  "event_ref": "CAE-2026-000321",
  "authorization_result": "APPROVED",
  "decline_reason": null,
  "flagged": false,
  "rules_fired": [],
  "alerts_generated": 0,
  "correlation_id": "6f1c2f9e-0000-4000-8000-000000000033",
  "latency_ms": 18
}

Examples of 400

Example: notJson

{
  "error": "Body must be valid JSON",
  "error_code": "BODY_NOT_JSON"
}

Example: notObject

{
  "error": "Body must be a JSON object",
  "error_code": "BODY_NOT_OBJECT"
}

Example: validation

{
  "error": "unknown card_token",
  "error_code": "UNKNOWN_CARD"
}

Example: No Idempotency-Key header

{
  "error": "the Idempotency-Key header is required for card events: send a unique key for each event and the same key when you retry it",
  "error_code": "MISSING_IDEMPOTENCY_KEY"
}

Example: cvv_result FAIL is refused with the message % must be one of %

{
  "error": "cvv_result must be one of MATCH, NO_MATCH, NOT_PROVIDED",
  "error_code": "INVALID_OPTION"
}

Example: A card_token beginning EXAMPLE-, as in the request example above

{
  "error": "references beginning EXAMPLE- come from the documentation and are refused: send your own references",
  "error_code": "EXAMPLE_ROW"
}

Examples of 401

Example: missing

{
  "error": "Missing or malformed API key",
  "error_code": "API_KEY_MISSING"
}

Example: invalid

{
  "error": "Invalid or revoked API key",
  "error_code": "API_KEY_INVALID"
}

Examples of 403

Example: addressNotAllowed

{
  "error": "API key not allowed from this address",
  "error_code": "API_KEY_ADDRESS_NOT_ALLOWED"
}

Example: institutionInactive

{
  "error": "Institution is not active",
  "error_code": "INSTITUTION_NOT_ACTIVE"
}

Example: classification

{
  "error": "This API key may not submit TEST events",
  "error_code": "CLASSIFICATION_NOT_ALLOWED_FOR_KEY"
}

Examples of 409

Example: differentBody

{
  "error": "this Idempotency-Key was already used for a card event with a different amount: retry with the same body, or send a new event with a new Idempotency-Key",
  "error_code": "IDEMPOTENCY_CONFLICT"
}

Examples of 413

Example: tooLarge

{
  "error": "Request body too large",
  "error_code": "BODY_TOO_LARGE"
}

Examples of 429

Example: failedAuthentications

{
  "error": "Too many failed authentication attempts from this address; retry after the number of seconds in Retry-After",
  "error_code": "TOO_MANY_FAILED_AUTHENTICATIONS"
}

Example: perKey

{
  "error": "Too many requests for this API key; retry after the number of seconds in Retry-After",
  "error_code": "RATE_LIMITED_KEY"
}

Example: perAddress

{
  "error": "Too many requests from this address; retry after the number of seconds in Retry-After",
  "error_code": "RATE_LIMITED_ADDRESS"
}

Examples of 500

Example: engine

{
  "error": "Authorization engine error",
  "error_code": "ENGINE_ERROR",
  "code": "P0001"
}

Examples of 503

Example: busy

{
  "error": "Service busy",
  "error_code": "SERVICE_BUSY"
}

Example: keyCheck

{
  "error": "Service unavailable",
  "error_code": "SERVICE_UNAVAILABLE"
}

Example: settings

{
  "error": "Service temporarily unavailable",
  "error_code": "SERVICE_SETTINGS_UNUSABLE"
}

© 2026 Underlayer, Lithuania. info@underlayer.eu System status Privacy notice