Assign cardholder to card
POST /v1/api-gateway/card/{card_id}/assign-cardholder
Links the card to a cardholder identified by exactly one of external_ (your end-customer id) or cardholder_ (the Moon cardholder id). Replaces any existing link.
Request
Authentication: your API key in the x-api-key header.
Path parameters
| Field | Type | Description |
|---|---|---|
card_ required | string, uuid | Card UUID (the card id returned by the card endpoints). |
Headers
| Field | Type | Description |
|---|---|---|
Idempotency-Key | string | A unique string you choose, up to 255 characters, that makes this request safe to retry. If a request times out or fails in transit, send it again with the same key: the status code and body of the first attempt are returned and the operation is not performed a second time. Stored replies — including failures — are replayed for 24 hours, after which the same key starts a fresh request. Reusing a key for a different request, or sending it while the first request is still running, returns 409. Omit the header and the request behaves exactly as before. Document upload endpoints do not accept it. |
Body
| Field | Type | Description |
|---|---|---|
external_ | string | Your identifier for the cardholder. Provide exactly one of external_ or cardholder_. Canonical name for the value this route also accepts as end_. Send one or the other; sending both with different values is rejected. |
end_ | string | Deprecated alias of external_, kept working for existing integrations. Send one or the other; sending both with different values is rejected. |
cardholder_ | string, uuid | The Moon cardholder id (id, a UUID). Provide exactly one of external_ or cardholder_. |
Example request
cURL
curl --request POST \
--url 'https://api.themooncard.com/v1/api-gateway/card/7c9e6679-7425-40de-944b-e07fc1f90ae7/assign-cardholder' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'content-type: application/json' \
--data '{
"external_id": "customer_123",
"end_customer_id": "customer_123",
"cardholder_id": "3f5b1c2e-8d4a-4b6f-9e2a-1c7d8e9f0a1b"
}'Responses
200 Success
{ "message": "Cardholder assigned to card" }.
| Field | Type | Description |
|---|---|---|
message required | string | Human-readable confirmation of what happened. The wording is fixed per route — the response description on each operation quotes it — but it is not a stable machine key: branch on the 2xx status, not on this text. |
JSON
{
"message": "Cardholder assigned to card"
}400 Error
Validation failed: provide exactly one of external_ or cardholder_ (cardholder_ must be a UUID).
The body is the standard error object: see Errors.
401 Error
Missing or invalid credentials, e.g. { "message": "Invalid API Key", "code": "UNAUTHORIZED" }.
The body is the standard error object: see Errors.
404 Error
Card not found or not owned by this organization (CARD_), or no cardholder matches (CARDHOLDER_).
The body is the standard error object: see Errors.
409 Error
The Idempotency-Key you sent is already in use. IDEMPOTENCY_ — the key was used for a different request; send a new key, or repeat the original request exactly to receive its stored response. IDEMPOTENCY_ — the first request with this key has not finished yet; retry in a few seconds.
The body is the standard error object: see Errors.
500 Error
Unexpected server error. Body is { message: "Internal server error", code: "INTERNAL_.
The body is the standard error object: see Errors.
Last updated August 16, 2026