Documentation

Documentation/API reference/Endpoints/

POST /v1/cards

Register one of your cards, or update it

Registers a card your institution issued, or updates it, by its card_token (your card processor's token for the card). A card event (POST /v1/card-authorizations) is accepted only for a registered card, so register each card when it is issued, and send its status when you change it (see the Cards guide).

A card belongs to one of your customers (customer_ref, required for a new card): a card never creates a customer, and a card keeps its customer and its data_classification for good. Never send a full card number: a card_token or masked_pan that holds one (13 to 19 digits that pass the Luhn check, with or without spaces or hyphens) is refused and nothing is stored. masked_pan carries at most the first six or eight digits and the last four, the rest masked with *, • or X.

status is ACTIVE, SUSPENDED or TERMINATED; a terminated card stays terminated. A status you set is yours: it is recorded and audited, and Underlayer sends you no webhook for it. A status Underlayer sets (a rule suspends or terminates the card; a person or an AI closure reinstates it) is sent to your webhook (cardStatusChanged). Making active a card that a monitoring alert still open suspended is your decision: it is done, and the answer warns you (OPEN_ALERT_SUSPENDED_CARD).

The same card_token with the same values changes nothing and answers changed: false, so no Idempotency-Key is needed. A card_token or customer_ref beginning EXAMPLE- is refused. Card registrations share the customer events' back-pressure, never the decisions' capacity.

Request body

CardRequest

A JSON object, at most 64 000 characters.

Example: A new virtual card (example references are refused)

{
  "card_token": "EXAMPLE-CARD-0001",
  "customer_ref": "EXAMPLE-CUST-0001",
  "masked_pan": "411111******1111",
  "card_type": "VIRTUAL_CARD",
  "status": "ACTIVE",
  "data_classification": "TEST"
}

Example: You suspended the card in your own system

{
  "card_token": "EXAMPLE-CARD-0001",
  "status": "SUSPENDED",
  "data_classification": "TEST"
}

Request sample

curl -X POST "$UNDERLAYER_BASE_URL/v1/cards" \
  -H "X-API-Key: $UNDERLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "card_token": "EXAMPLE-CARD-0001",
  "customer_ref": "EXAMPLE-CUST-0001",
  "masked_pan": "411111******1111",
  "card_type": "VIRTUAL_CARD",
  "status": "ACTIVE",
  "data_classification": "TEST"
}
JSON
import os
import requests

response = requests.post(
    os.environ["UNDERLAYER_BASE_URL"] + "/v1/cards",
    headers={"X-API-Key": os.environ["UNDERLAYER_API_KEY"]},
    json={
      "card_token": "EXAMPLE-CARD-0001",
      "customer_ref": "EXAMPLE-CUST-0001",
      "masked_pan": "411111******1111",
      "card_type": "VIRTUAL_CARD",
      "status": "ACTIVE",
      "data_classification": "TEST"
    },
)
print(response.status_code, response.json())
const response = await fetch(process.env.UNDERLAYER_BASE_URL + "/v1/cards", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.UNDERLAYER_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "card_token": "EXAMPLE-CARD-0001",
    "customer_ref": "EXAMPLE-CUST-0001",
    "masked_pan": "411111******1111",
    "card_type": "VIRTUAL_CARD",
    "status": "ACTIVE",
    "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
200CardResult

The card existed: it was updated (changed: true), or nothing differed (changed: false).

201CardResult

The card was registered (created: true).

400ErrorBody

The body is not a JSON object, or the database refused the card with a VALIDATION: message, answered without its prefix. The messages are listed on the Errors page, "Card registration refusals (400)"; % stands for the field or its value:

  • a card must be a JSON object
  • institution is not active
  • a card takes only card_token, customer_ref, masked_pan, card_type, status and data_classification
  • % must be text
  • card_token is required
  • card_token holds a full card number: send your processor's token for the card, never its number
  • card_token must be 1 to 128 letters, digits or . _ : + / = -
  • references beginning EXAMPLE- come from the documentation and are refused: send your own references
  • masked_pan holds a full card number: send at most the first six or eight digits and the last four, the rest masked
  • masked_pan must be digits with the middle masked by *, • or X, such as 411111******1111
  • card_type must be PHYSICAL_CARD or VIRTUAL_CARD
  • status must be ACTIVE, SUSPENDED or TERMINATED
  • data_classification must be PRODUCTION, TEST, SCALE_TEST or DEMO
  • data_classification % is not accepted by this institution: a production institution takes PRODUCTION data only
  • customer_ref is required for a new card
  • customer_ref names no customer of this institution: register the customer first
  • a card keeps the data_classification it was registered with
  • a card keeps the customer it was registered for: register a new card for another customer
  • a terminated card stays terminated: register the replacement card under its own card_token

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.

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 card with something other than a validation message, a fault on our side; code is its error code. Retry once with the same body: the same card_token never makes a second card. Contact Underlayer with the code if it comes back.

503ErrorBody

The service cannot take the customer event or the card registration now; nothing was stored and your key was not judged. Service busy: every customer event and card registration this server instance records at once is taken (a pool of their own, never a payment's or a card event's), or your institution already holds its share of them (known once the key is checked). 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: a customer event's source_system + external_event_id never make a second event, and a card's card_token never makes a second card.

Examples of 201

Example: registered

{
  "created": true,
  "changed": true,
  "warnings": [],
  "card": {
    "card_id": "00000000-0000-4000-8000-000000000051",
    "card_token": "tok_7Hf2kQ9",
    "customer_ref": "C-1001",
    "masked_pan": "411111******1111",
    "card_type": "VIRTUAL_CARD",
    "status": "ACTIVE",
    "data_classification": "TEST",
    "updated_at": "2026-10-29T12:40:25.118402+00:00"
  }
}

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: fullCardNumber

{
  "error": "masked_pan holds a full card number: send at most the first six or eight digits and the last four, the rest masked",
  "error_code": "FULL_PAN"
}

Example: unknownCustomer

{
  "error": "customer_ref names no customer of this institution: register the customer first",
  "error_code": "UNKNOWN_CUSTOMER"
}

Example: An EXAMPLE- reference, as in the request examples 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 cards",
  "error_code": "CLASSIFICATION_NOT_ALLOWED_FOR_KEY"
}

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": "Card registration 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