Direct-API Card Enrollment Integration
For approved partners enrolling cards without the SDK: each request, response and error for card subscription, both 3DS paths and the consent record.
For: developers
Introduction
This page is the direct-API integration reference for partners who have been granted permission to enroll cards without using an Astrada enrollment SDK in the browser. If you are not sure whether your integration qualifies for direct-API access, talk to your Astrada contact before relying on this page. Most integrators should use an Astrada enrollment SDK, which handles every response path described below for you.
The page is the contract you need to implement: every request shape, every response shape, every status code, and the literal validation messages your error handler will see. It covers both verification paths a card can take:
- The Stripe path (
currentStepId: "stripe-3ds"and, atHIGHEST,"stripe-holds-pending"/"stripe-amount-confirm"): how Visa, and the Mastercard HIGHEST second factor, verify today. - The legacy network path (
currentStepId: "fingerprint"/"challenge"): the EMV 3DS fingerprint-and-challenge flow still used by Mastercard atLOW/MEDIUM/HIGHand by any subaccount with no tier set.
You do not choose the path per request. It is determined by the subaccount's verification risk tier and the card network. Your client handles both with one dispatcher, which routes on currentStepId (see How enrollment completes). Adopting the Stripe path is purely additive: keep your legacy branches, add the Stripe ones, and they only fire for subaccounts moved to a tier.
Customers with personal cards or business cards can add their cards individually. Cardholders are required to complete a verification process to ensure they own the card when they link it.
Drive every path (Stripe and legacy) deterministically before going live with Test Cards & Sandbox Testing.
Using a backend SDK
The backend SDKs have no card-enrollment methods: none for POST /card-subscriptions, POST /card-verifications/3ds or its steps. If your server already uses a backend SDK, send these calls through its request method for calls it does not wrap (RequestApi.send in TypeScript, client.request in Python and Java), so the SDK's login, environment, timeouts and error types still apply. Card data sent this way passes through your server, so your PCI scope applies, and an SDK's body logging or request middleware would see it: keep both off for these calls. This sends the card subscription request:
import { RequestApi } from '@astrada.co/ts-astrada-sdk';
import { astrada } from './astrada.js';
type CardSubscription = { id: string; state: string };
const api = new RequestApi(astrada.configuration);
const subscription = await api.send<CardSubscription>('POST', '/card-subscriptions', {
body: {
subaccountId: '<SUBACCOUNT_ID>',
country: '<ISO_3166_ALPHA3>',
expiryMonth: '<EXP_MONTH>',
expiryYear: '<EXP_YEAR>',
pan: '<CARD_NUMBER>',
cvc: '<CVC_NUMBER>',
cardholderName: '<HOLDER_NAME>',
customerReferenceId: '<CUSTOMER_REFERENCE_UUID>',
consent: { channel: 'api', text: '<CONSENT_TEXT_AS_SHOWN>' },
},
});
console.log(subscription?.id, subscription?.state); // reqSCA: start the verificationsubscription = client.request(
"POST",
"/card-subscriptions",
body={
"subaccountId": "<SUBACCOUNT_ID>",
"country": "<ISO_3166_ALPHA3>",
"expiryMonth": "<EXP_MONTH>",
"expiryYear": "<EXP_YEAR>",
"pan": "<CARD_NUMBER>",
"cvc": "<CVC_NUMBER>",
"cardholderName": "<HOLDER_NAME>",
"customerReferenceId": "<CUSTOMER_REFERENCE_UUID>",
"consent": {"channel": "api", "text": "<CONSENT_TEXT_AS_SHOWN>"},
},
)
print(subscription["id"], subscription["state"]) # reqSCA: start the verificationimport com.google.gson.JsonObject;
import java.util.LinkedHashMap;
import java.util.Map;
Map<String, Object> body = new LinkedHashMap<>();
body.put("subaccountId", "<SUBACCOUNT_ID>");
body.put("country", "<ISO_3166_ALPHA3>");
body.put("expiryMonth", "<EXP_MONTH>");
body.put("expiryYear", "<EXP_YEAR>");
body.put("pan", "<CARD_NUMBER>");
body.put("cvc", "<CVC_NUMBER>");
body.put("cardholderName", "<HOLDER_NAME>");
body.put("customerReferenceId", "<CUSTOMER_REFERENCE_UUID>");
body.put("consent", Map.of("channel", "api", "text", "<CONSENT_TEXT_AS_SHOWN>"));
JsonObject subscription = client.request("POST", "/card-subscriptions", null, body).getAsJsonObject();
System.out.println(subscription.get("id").getAsString() + " " + subscription.get("state").getAsString());astrada (TypeScript) and client (Python, Java) are made as in Log in. An answer outside 2xx raises the SDK's usual error, so a 409 is ConflictError in TypeScript and Python and ConflictException in Java.
The SDKs do not resend a POST after a timeout or a server error. Once a request has reached the API, the only automatic resend is after a 401: each SDK sends it once more with a new token. Python also resends a POST when it could not connect (nothing reached the API). If you get no answer, send it again; a 409 gives you the existing subscription's id in currentValue.
Authentication
Every request authenticates with a bearer token obtained from Astrada's OAuth2 token endpoint using the client-credentials grant. Request a token, then send it as Authorization: Bearer <token> on every call. Tokens are short-lived. Fetch a fresh one when it expires rather than caching indefinitely. Full token mechanics (endpoint, client id/secret, refresh) are in Authentication.
The token must carry the scope for each endpoint you call:
| Scope | Grants |
|---|---|
card-subscriptions:write | POST /card-subscriptions (create the subscription) |
card-subscriptions:read | GET /card-subscriptions/{id} (read subscription state) |
card-verifications:write | POST /card-verifications/3ds and every /steps/... POST |
card-verifications:read | GET /card-verifications/3ds/{id} (poll verification state) |
subaccounts:write | PATCH /subaccounts/{id} (set the tier) and POST /card-verifications/unlock |
A call whose token is missing the required scope is rejected with 403 before any business logic runs. Contact your Astrada representative for a reference client-credentials implementation.
How enrollment completes
The create call, the Stripe-path step calls and a GET of the verification return a verification body carrying a currentStepId field. /steps/fingerprint and /steps/challenge return a step body (it has verificationId and no currentStepId): its state is the step's own, so fetch the verification and dispatch that. One dispatcher handles every response in the flow until state flips to completed or failed.
// Call this on the create response AND on every step response.
function dispatch(response) {
// /steps/fingerprint and /steps/challenge return a step body (it carries
// verificationId). Its state is the step's own: fetch the verification.
// If it still shows the step you just completed, wait and fetch again: never post a step twice.
if ("verificationId" in response) return refetch(response.verificationId);
const verification = response;
if (verification.state === "completed") return showSuccess(verification);
if (verification.state === "failed") return showFailure(verification);
switch (verification.currentStepId) {
// Stripe path: fires for subaccounts on MEDIUM / HIGH / HIGHEST.
case "stripe-3ds": return run3DS(verification); // load Stripe.js, then /steps/stripe-callback
case "stripe-holds-pending": return runPlaceHolds(verification); // HIGHEST only
case "stripe-amount-confirm": return runConfirmAmounts(verification); // HIGHEST only
// Legacy network path: fires for no-tier subaccounts and Mastercard LOW/MEDIUM/HIGH.
case "fingerprint": return runFingerprint(verification);
case "challenge": return runChallenge(verification);
// currentStepId === null with state=completed is handled at the top (frictionless terminal).
default: throw new Error(`unexpected currentStepId: ${verification.currentStepId}`);
}
}
// GET /card-verifications/3ds/{id}, then dispatch what the verification says now.
async function refetch(verificationId) {
return dispatch(await getVerification(verificationId));
}currentStepId | state | What it means | Next action | Path |
|---|---|---|---|---|
null, or the last step's id | completed | Verification done. null when the create call completed it without a step; after a step, the field keeps that step's id. | Terminal. Do not call any /steps/... endpoint. | all |
"stripe-3ds" | in-progress | 3DS challenge required. Response also carries clientSecret + stripePublishableKey. | Run stripe.handleNextAction(clientSecret), then POST /steps/stripe-callback. | Stripe (MEDIUM/HIGH/HIGHEST) |
"stripe-holds-pending" | in-progress | Issuer went frictionless; HIGHEST falls back to the two-hold second factor. | Disclose, then POST /steps/place-holds. | HIGHEST only |
"stripe-amount-confirm" | in-progress | Two holds placed; cardholder enters both amounts. | Collect {amount1, amount2} (integer cents), then POST /steps/amount-confirm. | HIGHEST only |
"fingerprint" | in-progress | Legacy EMV 3DS device fingerprint. (Mastercard HIGHEST can also land here mid-flow, see Edge cases.) | Run the fingerprint step. | legacy + MC HIGHEST edge case |
"challenge" | in-progress | Legacy EMV 3DS challenge. | Run the challenge step. | legacy |
Which path will I get?The path is fixed by the subaccount's tier and the card network, not by your request. Visa with a tier set runs the Stripe path; Mastercard runs the legacy network path at every tier except the HIGHEST two-hold second factor; a subaccount with no tier set runs the legacy path. See Verification Risk Tiers for the full routing matrix and what each tier validates.
The key insight: not every enrollment needs an interactive step. If the issuer supports frictionless authentication you'll receive a creation response with state: "completed" and currentStepId: null. The enrollment is already finished, and calling a /steps/... endpoint would return 404 because no step row exists.
Failures are error envelopes, not astate: "failed"bodyA
/steps/...POST (and the create call) never returns200withstate: "failed". A failure comes back as a problem+json error envelope (4xx/5xx) carryingerrorCode/category. See Errors. The terminalstate: "failed"only appears on aGETpoll of the verification (for example after the abandon sweep). Branch on the HTTP status first; readstatefrom aGET.
Client-side branching rule
Run dispatch (above) on the POST /card-verifications/3ds creation response and again on every step response it leads to. Do not test state === "completed" before you know which body you hold: on a fingerprint step body it is true while a challenge is still owed.
Polling a verification
If a client abandons the flow mid-way (closed tab, hung iframe), the verification transitions to state: "failed" roughly one hour after creation (72 hours on HIGHEST) via a scheduled check (one per verification, cancelled on step completion). To detect this, call GET /card-verifications/3ds/{verificationId} and branch on the full state taxonomy:
state value | Meaning |
|---|---|
in-progress | Verification is still pending a step. Continue or wait. |
completed | Verification succeeded. Card is enrolled. |
failed | Verification failed (a step explicitly failed, or the flow was abandoned and expired). Start a new verification if the cardholder is still available. |
On the creation response, state is only ever in-progress or completed, never failed. failed appears only on subsequent reads.
When a GET returns state: "failed", the verification also carries a failureReason explaining why it failed: a normalized category, a cardholder-safe description, a retryable flag, and (when the issuer returns them) issuerMessage, code, and acsReferences. See Error States & Remediation for the field reference and the full category list.
To list every step recorded for a verification, follow _links.steps.href on the verification resource, equivalent to GET /card-verifications/3ds/{verificationId}/steps. Useful when reconciling state after a partial flow.
Response media typeSuccess responses are
application/hal+json: every verification body carries_links.selfand_links.steps. The examples below elide_linksfor brevity except where the link is the point. Error responses areapplication/problem+json.
Single Card Enrollment Walkthrough
1. Customer Introduction
The first stage we recommend in any card enrollment journey is to clearly outline to your customers the scope of the data sharing they are about to consent to and any important information about how their data will be used.
This step improves user conversion by providing a feeling of trust and security.
2. Create the card subscription
The second stage of the card-linking journey requires the collection of card data and consent. At this stage the user provides sensitive data and opts into the terms of the data-sharing arrangement explicitly.
Subscription request
POST https://api.astrada.co/card-subscriptions{
"subaccountId": "<SUBACCOUNT_ID>",
"country": "<ISO_3166_ALPHA3>",
"expiryMonth": "<EXP_MONTH>",
"expiryYear": "<EXP_YEAR>",
"pan": "<CARD_NUMBER>",
"cvc": "<CVC_NUMBER>",
"cardholderName": "<HOLDER_NAME>",
"customerReferenceId": "<CUSTOMER_REFERENCE_UUID>",
"consent": {
"channel": "api",
"text": "<CONSENT_TEXT_AS_SHOWN>"
}
}customerReferenceId is optional. When provided, it must be a UUID; use it to correlate this subscription with an entity in your own system. Requires the card-subscriptions:write scope.
consent carries the consent text your screen showed the cardholder. See Send the consent record.
Response states
The POST /card-subscriptions call can return one of two outcomes. Branch on the response before deciding your next step.
| Status | state | Meaning | Next action |
|---|---|---|---|
201 | reqSCA | The subscription was created and a 3DS verification is required. | Proceed to Start card verification. |
409 | none | An active subscription already exists for this card + subaccount. | GET /card-subscriptions/{id} for the existing subscription (its id is in currentValue) and branch on its current state. Do not retry the POST. |
The subscription is always created in reqSCA on success. It transitions to active only after the verification flow below completes.
3. Start card verification
For subscriptions that require SCA, start the verification:
Verification request
POST https://api.astrada.co/card-verifications/3ds{
"subaccountId": "<SUBACCOUNT_ID>",
"expiryMonth": "<EXP_MONTH>",
"expiryYear": "<EXP_YEAR>",
"pan": "<CARD_NUMBER>",
"cvc": "<CVC_NUMBER>",
"cardholderName": "<HOLDER_NAME>"
}Requires the card-verifications:write scope. The verification create body does not accept country or customerReferenceId. Both fields belong only to POST /card-subscriptions. Correlate the verification with your own records via the subscription's id (returned on the POST /card-subscriptions response).
Interpret the response
Run your dispatcher on the response. The creation response is one of three shapes:
Frictionless, verification complete, no further steps:
{
"id": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"cardId": "8309b5f8-d5d8-49bb-9001-38bf1bb0f1e4",
"type": "3DS",
"currentStepId": null,
"state": "completed",
"authenticationFlow": "frictionless",
"createdAt": "2024-01-04T18:53:32.000Z",
"updatedAt": "2024-01-04T18:53:32.000Z",
"_links": {
"self": { "href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b" },
"steps": { "href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps" }
}
}authenticationFlow reports how 3DS resolved: frictionless, challenge, or null (3DS did not run). When you see currentStepId: null the card is enrolled; do not follow with a /steps/... call.
Stripe 3DS required, drive with Stripe.js:
{
"id": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"cardId": "8309b5f8-d5d8-49bb-9001-38bf1bb0f1e4",
"type": "3DS",
"currentStepId": "stripe-3ds",
"state": "in-progress",
"authenticationFlow": null,
"clientSecret": "seti_1Abc…_secret_Xyz…",
"stripePublishableKey": "pk_live_…",
"createdAt": "2024-01-04T18:53:32.000Z",
"updatedAt": "2024-01-04T18:53:32.000Z",
"_links": {
"self": { "href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b" },
"steps": { "href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps" }
}
}Continue to 3.1 Stripe 3DS challenge.
HIGHEST frictionless, second factor required:
{
"id": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"cardId": "8309b5f8-d5d8-49bb-9001-38bf1bb0f1e4",
"type": "3DS",
"currentStepId": "stripe-holds-pending",
"state": "in-progress",
"createdAt": "2024-01-04T18:53:32.000Z",
"updatedAt": "2024-01-04T18:53:32.000Z"
}Continue to 3.2 HIGHEST two-hold second factor. A subaccount on the legacy path returns currentStepId: "fingerprint" here instead. Continue to 3.3 Device fingerprint (legacy path).
sequenceDiagram
autonumber
participant Browser as Cardholder browser
participant Backend as Your backend
participant Astrada as Astrada API
participant StripeJS as Stripe.js
participant ACS as Issuer (ACS)
Browser->>Backend: Ticks box, submits card
Backend->>Astrada: POST /card-subscriptions + consent (→ reqSCA)
Backend->>Astrada: POST /card-verifications/3ds
Astrada-->>Backend: verification body, branch on currentStepId
alt currentStepId = null (frictionless terminal)
Backend-->>Browser: Enrolled
else currentStepId = "stripe-3ds" (Visa / Stripe tiers)
Browser->>StripeJS: handleNextAction(clientSecret)
StripeJS->>ACS: Render 3DS challenge
ACS-->>StripeJS: Cardholder completes / cancels
Backend->>Astrada: POST /steps/stripe-callback
Astrada-->>Backend: completed | stripe-holds-pending | error
else currentStepId = "fingerprint" (legacy / Mastercard non-HIGHEST)
Backend->>Astrada: GET then POST /steps/fingerprint
Backend->>Astrada: GET then POST /steps/challenge (if requires-challenge)
end
opt HIGHEST frictionless second factor
Backend->>Astrada: POST /steps/place-holds
Backend->>Astrada: POST /steps/amount-confirm {amount1, amount2}
Astrada-->>Backend: completed | mismatch(attemptsRemaining) | locked
end
If you want to check verification status on an existing subscription, use
GET /card-verifications/3ds/{verificationId}. See Polling a verification for the fullstatetaxonomy.
3.1 Stripe 3DS challenge (Stripe path)
On currentStepId === "stripe-3ds", drive the 3DS challenge in the cardholder's browser. Load Stripe.js, initialize with the stripePublishableKey from the create response, and call handleNextAction with the clientSecret:
<script src="https://js.stripe.com/v3/"></script>const stripe = Stripe(verification.stripePublishableKey);
const result = await stripe.handleNextAction({ clientSecret: verification.clientSecret });
// On success: result.error is undefined → POST an empty body to stripe-callback.
// On failure: result.error is populated → forward {code, message} so the backend
// can transition the verification to FAILED correctly.
const sdkError = result.error && {
code: result.error.code ?? result.error.type,
message: result.error.message,
};Add these CSP directives if you don't already allow Stripe:
script-src https://js.stripe.com
frame-src https://js.stripe.com https://m.stripe.network
connect-src https://api.stripe.com
clientSecretis single-use and short-livedPass it to
handleNextActionpromptly; never cache or queue it. A cardholder retry needs a fresh verification, not a reused secret. The one exception is a challenge the cardholder left open: read the verification again and continue from theclientSecretit returns (see Restart and resume). If Stripe.js can't load at all (CSP block, ad-blocker, network failure),Stripe(...)returns no usable instance. Route the cardholder to a retry path; the Stripe path can't proceed without it.
Then tell the backend the challenge has settled. Send an empty body on success; include the captured sdkError on failure. The endpoint is idempotent: retry is safe.
POST https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/stripe-callback{}{ "sdkError": { "code": "canceled", "message": "Cardholder closed the modal" } }The response is a verification body. Dispatch on currentStepId again. The two success shapes:
{ "id": "9fab1bea-…", "type": "3DS", "state": "completed",
"currentStepId": "stripe-3ds", "authenticationFlow": "challenge" }{ "id": "9fab1bea-…", "type": "3DS", "state": "in-progress",
"currentStepId": "stripe-holds-pending" }On failure the call returns a problem+json error envelope (not a 200): a 500 carrying errorCode + category, for a decline (e.g. stripe.generic_decline) as for a 3DS authentication failure (e.g. stripe.auth_rejected_by_issuer). See Errors.
Presence ofsdkErroris authoritative for failureIf you forward an
sdkError, the backend forces the verification to FAILED even if the upstream re-check reports the intent assucceeded. This stops a cardholder who actively canceled the challenge from being enrolled because the underlying intent reached success through a parallel path. Omitting the body is treated as success.
The Stripe path has no separate "challenge complete" GET. handleNextAction owns the iframe lifecycle and stripe-callback settles it. If your subaccount is MEDIUM/HIGH, the stripe-callback response is terminal and you're done. HIGHEST subaccounts continue to the second factor below.
3.2 HIGHEST two-hold second factor (Stripe path)
HIGHEST adds a second factor only when the issuer goes frictionless (no real 3DS challenge). When you see currentStepId: "stripe-holds-pending" (on the create response or the stripe-callback response), the cardholder confirms two small temporary holds. The cardholder-facing UX, disclosure copy, and timing are in HIGHEST Verification; the wire calls are below.
Place the holds. Show a disclosure with an explicit "Place the holds" action and do not call place-holds until the cardholder taps it. Silent hold placement is not acceptable.
POST https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/place-holdsNo request body. Success advances to amount confirmation:
{ "id": "9fab1bea-…", "type": "3DS", "state": "in-progress",
"currentStepId": "stripe-amount-confirm" }The two hold amounts are never returned on this (or any) response: that round-trip is the second factor. If the bank declines a hold you get a 400 stripe.place_holds_declined (category: soft-decline, retryable: true).
Confirm the amounts. Show a two-input form. Amounts are integer cents ($0.57 → 57) and order-insensitive: {57, 89} and {89, 57} both match a stored {57, 89}.
POST https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/amount-confirm{ "amount1": 57, "amount2": 89 }On a match the response is terminal (state: "completed"). On a mismatch with attempts left (each session allows two tries) you get a 400 you can retry inline:
{
"title": "Bad Request",
"detail": "The amounts entered did not match the verification holds.",
"errorCode": "stripe.amount_confirm_mismatch",
"category": "auth-failed",
"retryable": true,
"metadata": { "attemptsRemaining": 1 }
}On the second wrong try the same code returns with metadata.attemptsRemaining: 0, retryable: false, and the verification is failed. If that final miss also crosses the per-card lockout threshold the code is stripe.amount_confirm_locked instead (category: verification-locked, cleared only by Astrada). See Errors and Error States & Remediation.
3.3 Device fingerprint (legacy path)
On currentStepId === "fingerprint", run the legacy EMV 3DS fingerprint flow. The first sub-step collects device and browser data for frictionless authentication. Retrieve the fingerprint step:
GET https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/fingerprint{
"id": "fingerprint",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"verificationId": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"type": "fingerprint",
"state": "in-progress",
"data": {
"threeDSMethodData": "<base64-encoded 3DS method data>",
"threeDSMethodURL": "https://acs-public.tp.mastercard.com/api/v1/3ds_method",
"threeDSMethodNotificationURL": "https://sandbox.api.mastercard.com/openapis/authentication/callbacks/threeDSMethodNotification",
"threeDSServerTransID": "93a7cc75-cb7c-4cd3-a053-b2c4c186be5f"
},
"createdAt": "2024-01-05T14:46:50.000Z",
"updatedAt": "2024-01-05T14:46:51.000Z",
"_links": {
"self": {
"href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps/fingerprint"
},
"nextStep": {
"href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps/challenge"
}
}
}Use the data properties to open an iframe and collect browser information. The hidden iframe POSTs to the ACS (Access Control System) and posts a message to the window (threeDSMethodNotificationURL) when complete.
A small number of Mastercard cards return the field as
threeDsMethodUrl(lowercasesandUrl) instead of the spec-canonicalthreeDSMethodURL. Consume both casings defensively if you support Mastercard.
<html>
<head>
<script src="/static/fingerprint.js"></script>
<script>
window.onload = function() {
doFingerprint(
'{{ threeDSMethodURL }}',
'{{ threeDSMethodNotificationURL }}',
'{{ threeDSMethodData }}',
'{{ threeDSServerTransID }}');
}
</script>
</head>
</html>// This listener receives events from the window.
// On the arrival of threeds-method-notification event, it forwards
// the required data to the server to start authentication.
function fingerprintCompleteListener(m) {
if (m.data.type === 'threeds-method-notification') {
console.log('fingerprintCompleteListener called');
proceedAfterFingerprint('complete');
}
};
// Next step after fingerprinting (either when it is completed or it was not needed)
function proceedAfterFingerprint(fingerprintStatus) {
const body = {
fingerprintStatus: fingerprintStatus,
browserData: {
challengeWindowSize: '04', // 600x400
acceptHeader: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
colorDepth: window.screen.colorDepth,
javaEnabled: true,
language: navigator.language,
screenHeight: window.screen.height,
screenWidth: window.screen.width,
timezone: new Date().getTimezoneOffset(),
userAgent: window.navigator.userAgent,
},
};
post("https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/fingerprint", body);
};
function doFingerprint(threeDSMethodURL, threeDSMethodNotificationURL, threeDSMethodData, threeDSServerTransID) {
if (threeDSMethodURL) {
const html = `<script>
document.addEventListener("DOMContentLoaded", function () {
var form = document.createElement("form");
form.method = "POST";
form.action = "${threeDSMethodURL}";
form.appendChild(createInput("threeDSMethodNotificationURL", "${threeDSMethodNotificationURL}"));
form.appendChild(createInput("threeDSMethodData", "${threeDSMethodData}"));
form.appendChild(createInput("threeDSServerTransID", "${threeDSServerTransID}"));
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
});
function createInput(name, value) {
var result = document.createElement("input");
result.name = name;
result.value = value;
return result;
}
</script>`
const iframe = document.createElement("iframe");
iframe.id = '3ds-fingerprint';
document.body.appendChild(iframe);
iframe.style.display = "none";
const win = iframe.contentWindow;
if (win != null) {
const doc = win.document;
win.name = "3DS Fingerprint";
doc.open();
doc.write(html);
doc.close();
}
window.addEventListener("message", fingerprintCompleteListener);
} else {
// No threeDSMethodURL so skip fingerprinting
proceedAfterFingerprint('unavailable');
}
};Once fingerprinting is complete, send the browser details to the ACS so the challenge iframe can be correctly sized:
POST https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/fingerprint{
"fingerprintStatus":"complete",
"browserData":{
"colorDepth":24,
"language":"en-US",
"timezone":-120,
"screenHeight":1080,
"screenWidth":1920,
"challengeWindowSize":"05",
"javaEnabled":false,
"acceptHeader":"application/json",
"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
}
}The server derives ip from the request (X-Forwarded-For or sourceIp); any value sent in the body is ignored.
Fingerprint step outcome values
outcome valuesAfter a successful POST, the fingerprint step's outcome field tells you whether a challenge is still needed:
outcome | Meaning | Next step |
|---|---|---|
authenticated | Frictionless success. Verification state becomes completed. | Done. Card is enrolled. |
requires-challenge | Additional cardholder interaction needed. | Follow _links.nextStep.href to the 3DS Challenge. |
A third value, null, exists in the schema but is never returned by the POST itself. It only appears on a GET of a step that was created and then never POST-completed (for example, an in-progress step or one that the scheduled check expired before completion).
outcome vs. state: outcome describes the 3DS result; state describes the step's lifecycle. To detect failure, branch on state === "failed", not on outcome. There is no failed outcome value.
Mastercard HIGHEST can return a verification body hereFor Mastercard HIGHEST, the bank can defer its frictionless decision until after fingerprint. When that happens,
POST /steps/fingerprintreturns a verification body withcurrentStepId: "stripe-holds-pending"instead of the usual step body. Hand it back to your dispatcher, which tells the two bodies apart. See Edge cases.
authenticated response:
{
"id": "fingerprint",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"verificationId": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"type": "fingerprint",
"state": "completed",
"outcome": "authenticated",
"createdAt": "2024-01-05T14:46:50.000Z",
"updatedAt": "2024-01-05T14:46:51.000Z",
"_links": {
"self": {
"href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps/fingerprint"
}
}
}requires-challenge response:
{
"id": "fingerprint",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"verificationId": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"type": "fingerprint",
"state": "completed",
"outcome": "requires-challenge",
"createdAt": "2024-01-05T14:46:50.000Z",
"updatedAt": "2024-01-05T14:46:51.000Z",
"_links": {
"self": {
"href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps/fingerprint"
},
"nextStep": {
"href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps/challenge"
}
}
}3.4 3DS Challenge (legacy path)
When the fingerprint response indicates outcome: "requires-challenge", the cardholder needs to complete a token-based challenge (typically a push notification from their bank's app or an SMS code).
The challenge is delivered to the registered cardholder by their issuer. The iframe is fully controlled by the card-verification provider, so use the URL they provide.
Retrieve the challenge step data:
GET https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/challenge{
"id": "challenge",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"verificationId": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"type": "challenge",
"state": "in-progress",
"data": {
"acsUrl": "https://acs-public.tp.mastercard.com/api/v1/browser_challenges",
"encodedCReq": "<base64url-encoded CReq>"
},
"createdAt": "2024-01-05T14:46:51.000Z",
"updatedAt": "2024-01-05T18:47:22.000Z",
"_links": {
"self": {
"href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps/challenge"
}
}
}Display the challenge iframe using the acsUrl and encodedCReq:
<html>
<head>
<script src="/static/challenge.js"></script>
<script>
window.onload = function() {
doChallenge('{{ acsUrl }}', '{{ encodedCReq }}');
}
</script>
</head>
<body>
Performing 3DS challenge.
</body>
</html>// This listener receives messages posted to the window. After listening
// threeds-challenge-notification message, the challenge results window will pop-up.
function challengeCompleteListener(m) {
if (m.data.type === 'threeds-challenge-notification') {
console.log("challengeCompleteListener called");
post("https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/challenge", {});
}
};
// Opens 3DS challenge iframe and listens to event completion.
function doChallenge(acsUrl, encodedCReq) {
const html = `<script>
document.addEventListener("DOMContentLoaded", function () {
var form = document.createElement("form");
form.method = "POST";
form.action = "${acsUrl}";
form.appendChild(createInput("creq", "${encodedCReq}"));
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
});
function createInput(name, value) {
var result = document.createElement("input");
result.name = name;
result.value = value;
return result;
}
</script>`
const iframe = document.createElement("iframe");
iframe.id = "3ds-challenge";
iframe.width = "600px";
iframe.height = "400px";
iframe.frameBorder = "0";
iframe.style.display = 'block';
iframe.style.position = 'absolute';
iframe.style.top = "100px";
iframe.style.left = "50%";
iframe.style.transform = "translate(-50%, 0%)";
iframe.style.background = "white";
document.body.appendChild(iframe);
const win = iframe.contentWindow;
if (win != null) {
const doc = win.document;
win.name = "3DS Challenge";
doc.open();
doc.write(html);
doc.close();
}
window.addEventListener("message", challengeCompleteListener);
};When the challenge iframe completes, it posts a message to the window. On that message, POST to the challenge step to finalize the verification:
POST https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/challenge{
"id": "challenge",
"subaccountId": "f297d659-c13d-4219-aeaa-e10a845140a5",
"verificationId": "9fab1bea-bc1e-4757-bd47-479422e5983b",
"type": "challenge",
"state": "completed",
"createdAt": "2024-01-05T14:46:51.000Z",
"updatedAt": "2024-01-05T18:47:22.000Z",
"_links": {
"self": {
"href": "/card-verifications/3ds/9fab1bea-bc1e-4757-bd47-479422e5983b/steps/challenge"
}
}
}409 on challenge POST
The challenge POST can return 409 Conflict for two reasons:
- The user abandoned the verification during the authentication process.
- The user did not complete the 3DS challenge during the authentication process.
In both cases the client should start a new verification rather than retrying the same one. The 409 response body carries a human-readable detail explaining which of the two occurred.
The challenge POST can also answer 403 when the issuer rejects 3DS (errorCode: "verification.issuer_rejected"). Start a new verification there too.
4. Check the final verification state
To verify the terminal state of a card verification, call:
GET https://api.astrada.co/card-verifications/3ds/{verificationId}state will be completed or failed. The exact meanings are in Polling a verification above. When the verification reaches completed, the card subscription transitions from reqSCA to active.
Edge cases
Restart and resume
A cardholder can abandon mid-flow or close the tab and come back later. Both are recoverable.
Start over (HIGHEST). When the cardholder abandons during the holds flow, post to the restart endpoint. This releases any placed holds and supersedes the verification, returning the superseded resource directly in the response. Verification state changes aren't webhook-notified, so there's nothing to listen for. Create a fresh verification next.
POST https://api.astrada.co/card-verifications/3ds/{verificationId}/steps/restartResume after a closed tab. When the cardholder re-creates a verification for the same card, POST /card-verifications/3ds returns 409 with the existing verification's id in currentValue. Fetch it with GET /card-verifications/3ds/{verificationId} and dispatch on currentStepId:
| Live step at close | What to do |
|---|---|
stripe-holds-pending | Re-show the disclosure/initiate screen. Nothing was placed yet. |
stripe-amount-confirm | Re-show amount entry. The attempts counter and the two holds are preserved server-side; the holds are still visible in the cardholder's banking app. |
stripe-3ds | dispatch the body this GET returned: at this step it carries clientSecret and stripePublishableKey again, and the challenge runs from them. Do it before the abandon check fails the verification (see Polling a verification). To give up instead, POST stripe-callback with an sdkError (the verification fails; the call answers 500), then create a fresh verification. restart does not apply at this step. |
fingerprint / challenge | Re-fetch the step (GET /steps/{id}) and continue the legacy flow. |
| Returned after 72 hours | Astrada fails the verification and releases its holds 72 hours after it was created. Create a fresh verification. |
Mastercard: frictionless decision after fingerprint
For Mastercard HIGHEST, the bank can defer its frictionless decision until after the fingerprint step. When that happens, POST /steps/fingerprint returns the verification body (with currentStepId: "stripe-holds-pending") instead of the usual step body. Same endpoint, two possible shapes. Detect by the presence of currentStepId:
const response = await postFingerprint(verificationId, browserData);
// With "currentStepId" in response: a verification body (the bank attested
// frictionless mid-flow). Otherwise a step body. dispatch() handles both.
return dispatch(response);The cardholder sees the same disclosure → initiate → amount-confirm screens as the create-time frictionless path; the UX does not fork.
Idempotency and retries
stripe-callback,place-holds: idempotent. Calling either twice returns the same result (current state, no new holds placed) rather than an error; if the network drops, retry directly.amount-confirm: GET before retrying, not idempotent. A retried call with the same wrong amounts burns another attempt. After an ambiguous network failure,GET /card-verifications/3ds/{verificationId}and route oncurrentStepIdinstead of blindly re-POSTing.- A bare
400with{ title, detail }and noerrorCodealways means "this step is no longer valid for the current state". Recover byGET-ing the verification and routing oncurrentStepId, not by retrying the same call.
Errors
All 4xx/5xx responses are application/problem+json with this envelope:
{
"title": "Bad Request",
"detail": "Card verification failed: card was declined.",
"errorCode": "stripe.generic_decline",
"category": "soft-decline",
"retryable": false
}title mirrors the HTTP status. detail is engineering-readable. Don't surface it to cardholders verbatim. On the Stripe path, declines and auth failures also carry:
errorCode: the namespaced key (e.g.stripe.cvc_fail) for cardholder-copy lookup.category: a small, stable remediation enum to branch on:cvc,bank-contact,hard-fraud,soft-decline,transient,infrastructure,auth-failed,auth-canceled,auth-rejected,auth-unsupported,verification-locked.retryable: a per-response UX hint (a few codes carry no flag, see the note below).metadata: present onstripe.amount_confirm_mismatchas{ attemptsRemaining }.
Branch oncategory, not on the fullerrorCodelistNew
stripe.*codes can be added at any time. Treat an unrecognizederrorCodeas "use a different card" and branch your cardholder copy on the stablecategoryenum. The exhaustive code list, per-code HTTP status, and the SDK's cardholder screens live in Error States & Remediation.
Where failures land:
- Decline (
stripe.cvc_fail,stripe.generic_decline,stripe.stolen_card,stripe.insufficient_funds,stripe.contact_issuer, …) → 400 onPOST /card-verifications/3ds; 500 when it is decided onPOST /steps/stripe-callback, after the challenge. - 3DS authentication failure (
stripe.auth_rejected_by_issuer,stripe.auth_canceled,stripe.auth_unsupported,stripe.try_again_later) → 500 onPOST /steps/stripe-callback, or 400 onPOST /card-verifications/3dswhenstripe.try_again_lateris decided at create (the detail is preserved;auth-*codes arrive without aretryableflag: treatauth-failed/auth-canceledas retry,auth-rejected/auth-unsupportedas use-another-card). - HIGHEST two-hold (
stripe.place_holds_declined,stripe.amount_confirm_mismatch,stripe.amount_confirm_locked) → 400 on the respective step.
The full stripe.* / verification.* reference, including the Mastercard/no-tier legacy-path failures that carry detail only (no errorCode, except an issuer rejection), is in Error States & Remediation.
Card enrollment (POST /card-subscriptions)
POST /card-subscriptions)| Validation | HTTP status | API message detail |
|---|---|---|
subaccountId is not a valid UUID | 400 | Invalid uuid |
customerReferenceId is provided but not a valid UUID | 400 | Invalid uuid |
country is not a valid ISO 3166 Alpha-3 code | 400 | Country code must be in ISO 3166 Alpha3 format |
| Card country of issuance blocked for the subaccount | 403 | The card country of issuance (XX) is not supported |
expiryMonth is not an integer in the range 1–12 | 400 | Number must be greater than or equal to 1 / Number must be less than or equal to 12 |
expiryYear is not a 4-digit year | 400 | expiryYear must be in YYYY format |
| Expiry date is in the past | 400 | Expiry date cannot be in the past |
pan failed validation (invalid PAN, unsupported network, or BIN check) | 400 | Invalid PAN |
cvc is not 3 or 4 digits | 400 | CVC must be 3 or 4 digits |
Consent is enforced and consent is missing or invalid, or its channel is not allowed | 400, 403 | See Consent errors (card_subscription.consent_*) |
| Card subscription already exists for this card + subaccount | 409 | There is already a card subscription for the specified card |
| Unhandled service error | 500 | An unexpected error happened while creating a card subscription |
400 validation responses come back as a
Bad Requestproblem+json envelope. Each per-field message in the table above appears inerrors[i].detail, witherrors[i].instancepointing at the failing path (for example/body/pan). Consent errors are the exception:detail,title,typeanderrorCodesit at the top level, with noerrors[].
Card verification: legacy path (POST /card-verifications/3ds/.../steps/challenge)
POST /card-verifications/3ds/.../steps/challenge)| Validation | HTTP status | API message detail |
|---|---|---|
| Verification abandoned by the user | 409 | Card verification with id=X was abandoned by the user during the authentication process. Please start a new verification. |
| 3DS challenge not completed by the user | 409 | The 3DS challenge for Card verification with id=X was not completed by the user during the authentication process. Please start a new verification. |
The issuer rejected 3DS (on /steps/fingerprint too) | 403 | The same detail as the next row, with errorCode: "verification.issuer_rejected". Start a new verification. This is not the missing-scope 403 in Authentication: tell them apart by the errorCode. |
| Challenge step failed (3DS provider returned an error) | 500 | Card verification step with id=challenge failed for card verification with id=X. 3DS details: '[reason]'. Please start a new verification. |
Attempt lockout: when the subaccount has failedAttemptLockout enabled, a card with too many recent hard failures is blocked at POST /card-verifications/3ds (before any provider call), across all networks:
errorCode | HTTP | API message detail |
|---|---|---|
verification.attempts_locked | 400 | Too many failed verification attempts for this card. Try again later. (carries metadata.lockedUntil) |
verification.attempts_locked_permanent | 400 | This card can no longer be used for verification. Please contact support. |
Clear either lock with POST /card-verifications/unlock (body { cardId }, scope subaccounts:write). This is distinct from the HIGHEST per-card lockout (stripe.amount_confirm_locked), which only Astrada can clear. Full rules: Verification Attempt Lockout.
End-to-end skeleton
A single dispatch function, called on the create response, drives the whole flow. Each branch handler either terminates or hands the next response back to dispatch: a verification body, or after a legacy step a step body (see How enrollment completes). api.* are your own HTTP wrappers (auth + JSON; a 4xx/5xx throws with errorCode/category/metadata). ui.* render cardholder screens.
async function startVerification(payload) {
return dispatch(await api.create(payload)); // POST /card-verifications/3ds
}
async function dispatch(v) {
// A step body (fingerprint or challenge): ask the verification.
// If it still shows the step you just completed, wait and ask again: never post a step twice.
if ("verificationId" in v) return dispatch(await api.get(v.verificationId));
if (v.state === "completed") return ui.showSuccess(v);
if (v.state === "failed") return ui.showFailure(v);
switch (v.currentStepId) {
case "stripe-3ds": return run3DS(v);
case "stripe-holds-pending": return runPlaceHolds(v); // HIGHEST
case "stripe-amount-confirm": return runConfirmAmounts(v); // HIGHEST
case "fingerprint": return runFingerprint(v); // legacy + MC HIGHEST mid-flow
case "challenge": return runChallenge(v); // legacy
default: throw new Error(`unexpected currentStepId: ${v.currentStepId}`);
}
}
async function run3DS(v) {
const result = await stripe.handleNextAction({ clientSecret: v.clientSecret });
const body = result.error
? { sdkError: { code: result.error.code ?? result.error.type, message: result.error.message } }
: {};
return dispatch(await api.stripeCallback(v.id, body)); // POST /steps/stripe-callback
}
async function runPlaceHolds(v) {
await ui.showDisclosureAndWaitForConfirm(); // explicit cardholder action required
return dispatch(await api.placeHolds(v.id)); // POST /steps/place-holds
}
async function runConfirmAmounts(v) {
while (true) {
const { amount1, amount2 } = await ui.collectAmounts(); // integer cents, order-insensitive
try {
return dispatch(await api.amountConfirm(v.id, { amount1, amount2 }));
} catch (err) {
if (err.errorCode === "stripe.amount_confirm_mismatch" && err.metadata?.attemptsRemaining > 0) {
ui.showInlineMismatch(err.metadata.attemptsRemaining);
continue; // inline retry on the same screen
}
throw err; // terminal: surfaced by your error handler
}
}
}
// POST /steps/fingerprint answers with a step body, or on Mastercard HIGHEST
// with a verification body (holds-pending). dispatch tells them apart.
async function runFingerprint(v) {
return dispatch(await api.postFingerprint(v.id, await ui.collectBrowserData()));
}
// Section 3.4: fetch the challenge step, show it, then settle it.
async function runChallenge(v) {
const step = await api.getStep(v.id, "challenge"); // GET /steps/challenge
await ui.showChallenge(step.data); // until the iframe reports back
return dispatch(await api.postChallenge(v.id)); // POST /steps/challenge
}Hosting architecture considerations
The Stripe path needs JavaScript running in the cardholder's browser to render the Stripe.js iframe. How hard adoption is depends on how your verification UI is hosted:
- Iframe embedded in your page: easiest. Drop
handleNextActioninto the same hook that triggers your existing iframe. - Popup window: workable. Load Stripe.js inside the popup and call
handleNextActionthere. - Full-page redirect that form-posts CReq: not supported on the Stripe path (
handleNextActionneeds the page to stay mounted). Leave these subaccounts on the legacy flow; escalate to your Astrada integration manager. - Pure server-rendered, no browser JavaScript: not supported. Keep on legacy; escalate.
Appendix: API quick reference
All requests carry Authorization: Bearer <token> and Content-Type: application/json. Success responses are application/hal+json (201 for create, 200 otherwise) returning a verification body { id, type, state, currentStepId, authenticationFlow, clientSecret?, stripePublishableKey?, _links }, or from /steps/fingerprint and /steps/challenge a step body { id, type, state, outcome, verificationId, _links }. Errors are application/problem+json { title, detail, errorCode?, category?, retryable?, metadata? }.
| Endpoint | Scope | Request body | Successful response |
|---|---|---|---|
POST /card-subscriptions | card-subscriptions:write | { subaccountId, country, expiryMonth, expiryYear, pan, cvc, cardholderName, customerReferenceId?, consent? } | 201 subscription in state: reqSCA. 409 if one already exists (currentValue = existing id). |
POST /card-verifications/3ds | card-verifications:write | { subaccountId, expiryMonth, expiryYear, pan, cvc, cardholderName } | currentStepId: "stripe-3ds" (+ clientSecret, stripePublishableKey), null (frictionless terminal), "stripe-holds-pending" (HIGHEST), or "fingerprint" (legacy). |
GET /card-verifications/3ds/{id} | card-verifications:read | (none) | Current verification body. Use after a 409 on re-create to resume. |
POST /steps/stripe-callback | card-verifications:write | {} on success; { sdkError: { code, message? } } on Stripe.js failure | Terminal for MEDIUM/HIGH; for HIGHEST either terminal or "stripe-holds-pending". Idempotent. |
POST /steps/place-holds (HIGHEST) | card-verifications:write | (none) | Advances to "stripe-amount-confirm". stripe.place_holds_declined on bank decline. |
POST /steps/amount-confirm (HIGHEST) | card-verifications:write | { amount1, amount2 } (integer cents, order-insensitive) | Terminal completed on match; stripe.amount_confirm_mismatch (metadata.attemptsRemaining) on miss; stripe.amount_confirm_locked on lockout. |
POST /steps/restart (HIGHEST) | card-verifications:write | (none) | Supersedes the verification and releases any placed holds. No webhook fires. |
GET /steps/fingerprint · POST /steps/fingerprint (legacy) | card-verifications:read · :write | POST: { fingerprintStatus, browserData } | Step body with outcome (authenticated / requires-challenge); MC HIGHEST may return a verification body. |
GET /steps/challenge · POST /steps/challenge (legacy) | card-verifications:read · :write | POST: {} | Step body state: completed; 409 if abandoned / not completed. |
Consent
Card networks require the cardholder's consent before Astrada can access their transaction data. What consent is and why Astrada collects it: Data Sharing Consent: Consent. With an Astrada enrollment SDK in the browser you have nothing to do, because the SDK sends the consent record for you. This section is for direct API integrations, where your own screens show the consent text.
Send the consent record
Send consent on every POST /card-subscriptions, once the cardholder has ticked your consent box. Show the network consent wording on Configuration for the card's network, with {{scheme}} filled in as Visa, Mastercard or American Express, unless Astrada agreed other wording with you. For American Express, show the Visa wording with American Express filled in, as the Unified Enrollment SDK does.
| Field | Required | Rules |
|---|---|---|
channel | Yes | api |
text | Yes | The words of your consent box, as your screen showed them. 1 to 20,000 characters. See the rules below. |
customerTermsText | No | Your own terms text, when it has its own box. Same rules as text. |
locale | No | BCP 47 tag of the texts, such as en-US, at most 35 characters. Astrada records und without it. |
variables | No | Values to keep with the record, such as the links in your text: at most 10 keys of up to 64 characters, string values of up to 500 characters. An entry that holds a card number is dropped. |
textVersionId, textHash, customerTermsVersionId, customerTermsHash, sdkVersion | No | Used only by Astrada's enrollment SDKs. Leave them out on api. |
A card number in text, customerTermsText or locale fails its rule (consent_invalid in enforce) and is never stored. A card number here is a Luhn-valid run of 13, 14, 15, 16 or 19 digits that starts with 2 to 6, written plain or in groups split by single spaces, hyphens, dots or no-break spaces, so a test card number in your legal text counts.
There is no registration step and no id or hash to compute. The rules for text and customerTermsText:
- One box, one field. If one checkbox covers both the network wording and your terms, send all of that box's words in
textand leave outcustomerTermsText. UsecustomerTermsTextonly when your terms have their own box. - Same words for the same network. Send the same text for every cardholder who sees the same network's wording. If your screen shows different wording per network, send the wording for the card's network.
- Values that change go in
variables. If the words name something that changes per cardholder or per company, such as the employer's name, write a placeholder like{{companyName}}intextand put the value invariables. Otherwise each name is a new stored text and a new review flag. - Nothing about the cardholder or card. Never put cardholder or card details in
text. - Not blank. A text that is blank once trimmed, or that contains a NUL character (U+0000), breaks its rule.
text holds the plain words the cardholder saw, with no markup: write a link as its visible words and put its URL in variables. Every variant of the markup is a new stored text and a new review flag. For the Mastercard wording, where "Privacy Policy" is a link:

Which words go in which field.
"consent": {
"channel": "api",
"text": "By submitting your card information and checking this box, you authorize Mastercard to access, monitor and share transaction data (e.g., amount, time, date, and merchant name) according to its Privacy Policy, with Astrada (our service provider) for the purposes of identifying relevant transactions and carrying out related spend management services. You also affirm that the card being monitored is used primarily for business purposes.",
"variables": {
"mastercardPrivacyUrl": "https://www.mastercard.us/en-us/vision/corp-responsibility/commitment-to-privacy/privacy.html"
}
}Example
POST https://api.astrada.co/card-subscriptions HTTP/1.1
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json
{
"subaccountId": "24c4f90d-ab3b-4f6e-8a1d-d251a4fcf34c",
"country": "USA",
"expiryMonth": 12,
"expiryYear": 2031,
"pan": "4242424242424242",
"cvc": "123",
"cardholderName": "Sandbox Test",
"consent": {
"channel": "api",
"text": "By submitting your card information and checking this box, you authorize Visa to access, monitor and share transaction data (e.g., amount, time, date, and merchant name) with Astrada (our service provider) for the purposes of identifying relevant transactions and carrying out related spend management services. You also affirm that the card being monitored is used primarily for business purposes.",
"customerTermsText": "I agree to the Example Inc. Terms of Service and Privacy Policy.",
"locale": "en-US"
}
}The text above is the legacy Card Enrollment SDK's Visa wording with the network name filled in. The response does not echo consent. Abbreviated 201 body:
{
"id": "75ea3c99-6bf5-4b16-8f68-0cdc43d75806",
"subaccountId": "24c4f90d-ab3b-4f6e-8a1d-d251a4fcf34c",
"cardId": "5dec2c49-0aa5-4683-a317-427eb5d115f3",
"enrollmentType": "cardholder-single",
"state": "reqSCA"
}In enforce, the same request with a card number inside text is refused, and nothing is stored:
{
"detail": "consent.text is invalid: Must not contain a card number",
"title": "Consent record invalid",
"type": "https://docs.astrada.co/reference/errors-consent_invalid",
"errorCode": "card_subscription.consent_invalid"
}How Astrada stores your text
sequenceDiagram
autonumber
participant Cardholder
participant Backend as Your backend
participant Astrada as Astrada API
Cardholder->>Backend: Ticks box, submits card
Backend->>Astrada: POST /card-subscriptions + consent.text
Astrada->>Astrada: Read policy
Astrada->>Astrada: Check shape and channel
alt New text for this subaccount
Astrada->>Astrada: Store text, flag for review
else Seen before
Astrada->>Astrada: Reuse stored text
end
Astrada->>Astrada: Write the record
Astrada-->>Backend: 201, reqSCA
- Astrada stores each distinct text once per subaccount, the first time it sees it, and links every consent record to it. Texts are compared after Unicode NFC normalization, line endings converted to
\nand outer whitespace trimmed; any other difference is a new text. - A text Astrada has not seen before for your subaccount is stored and flagged for Astrada's next review, never refused.
- Per-network variants (for example a Visa and a Mastercard wording) are separate texts: each is flagged once, the first time it is seen, and switching between them later flags nothing.
- Earlier records keep pointing at the text the cardholder saw then.
- Astrada reviews your consent text during onboarding and in its periodic reviews. If a review objects to a text, Astrada contacts you to change it.
- Sandbox and production keep separate records. To get a record for an audit or a dispute, see The consent record.
When consent is required
Astrada sets each subaccount's consent policy; you read it as consentPolicy on GET /subaccounts/{subaccountId}. New accounts start in enforce with every channel allowed, in sandbox and production. Accounts that existed before consent recording went live have no consentPolicy, which behaves as log, until the enforcement date Astrada agrees with you. In enforce, a consent on any channel in allowedChannels is accepted; if you integrate only through Astrada's SDKs, ask Astrada to narrow allowedChannels to sdk-unified and sdk-legacy so a direct API consent is refused.
| Request | log, or no consentPolicy | enforce |
|---|---|---|
No consent | 201, logged, no record | 400 consent_required |
Valid consent | 201, recorded | 201, recorded |
A field breaks its rule (for example a card number in text) | 201, recorded with the failure; the text is not stored | 400 consent_invalid |
channel not allowed | 201, recorded with the failure | 403 consent_channel_not_allowed |
In off, every request gets 201 and nothing is recorded.
In enforce, a refused request creates no card subscription; when Astrada cannot check or store the record, see Consent errors for the 500. The consent check runs before the duplicate check, so in enforce a retry of an enrolled card without consent answers 400, not 409. Send consent on retries too.
Test in sandbox
- Read
consentPolicyonGET /subaccounts/{subaccountId}for your sandbox subaccount. - Enroll a test card with
consent. A valid consent gets the usual201in every mode. A changed text on a second card gets201too. - If the subaccount is in
log, ask Astrada to set it toenforce. Then send a request withoutconsent(consent_required) and one with a blanktext(consent_invalid), and check that your integration shows the cardholder an error and does not retry in a loop.
Consent errors
Every consent code, its exact detail, which integrations can get it and its fix: Error States & Remediation: Consent errors.
Updated 4 days ago
