Getting Started
From sandbox sign-up to your first transaction, and the webhooks a finance agent or close tool reads: token, subaccount, webhook, card, simulated purchase.
For: developers
The fastest path from zero to your first transaction, in sandbox, and a map of how each business event becomes an API call and a webhook. Every step links out to the guide with the detail.
How enrollment works
However a card is enrolled, it becomes the same thing: a durable cardId, a card subscription announced by cardsubscription.created, and transactions that carry that cardId. A card is enrolled in one of three ways (card number, bank connection, or network bulk feed), and the subscription's enrollmentType records which one. The same webhook handlers work for all three; enrollmentType only tells you which way the card came in. The full model is Unified Card & Bank Feeds.
Steps
1. Get sandbox credentials
Enter your work email at astrada.co/sandbox and open the single-use link we email you (it expires in 24 hours). The page shows your client ID and secret, your account ID and a subaccount ID. The secret is shown once, so store it straight away.
In sandbox this one client holds every scope, so it works for both the API and the SDK. For production, contact your Astrada representative; during onboarding Astrada gives you separate API credentials (server-to-server, OAuth 2.0 client-credentials) and SDK credentials (if you enroll cards client-side), your account ID, and a Postman collection. For the token mechanics, see Authentication.
2. Get a token
Exchange the client ID and secret for an access token at the sandbox token endpoint, and keep it in TOKEN for the next steps:
TOKEN=$(curl -s -X POST "https://api.sandbox.astrada.co/auth/realms/$ACCOUNT_ID/protocol/openid-connect/token" \
-d grant_type=client_credentials \
-d client_id="$CLIENT_ID" \
-d client_secret="$CLIENT_SECRET" \
| sed -E 's/.*"access_token":"([^"]+)".*/\1/')import { Configuration } from '@astrada.co/ts-astrada-sdk';
const config = new Configuration({
environment: 'sandbox',
accountId: process.env.ASTRADA_ACCOUNT_ID!,
clientId: process.env.ASTRADA_CLIENT_ID!,
clientSecret: process.env.ASTRADA_CLIENT_SECRET!,
});import os
import astrada
client = astrada.Astrada(
account_id=os.environ["ASTRADA_ACCOUNT_ID"],
client_id=os.environ["ASTRADA_CLIENT_ID"],
client_secret=os.environ["ASTRADA_CLIENT_SECRET"],
environment="sandbox",
)import co.astrada.client.ApiClient;
import co.astrada.client.Astrada;
import co.astrada.client.Environment;
ApiClient client = Astrada.builder()
.environment(Environment.SANDBOX)
.credentials(System.getenv("ASTRADA_ACCOUNT_ID"), System.getenv("ASTRADA_CLIENT_ID"),
System.getenv("ASTRADA_CLIENT_SECRET"))
.build();Set ACCOUNT_ID, CLIENT_ID and CLIENT_SECRET from step 1 first. A token lasts five minutes; run the command again when it expires.
The TypeScript, Python and Java tabs use the backend SDKs instead of HTTP. They read the same three values from ASTRADA_ACCOUNT_ID, ASTRADA_CLIENT_ID and ASTRADA_CLIENT_SECRET and make a client that gets the token itself, and a new one when it expires. The SDK tabs in the next steps use that client.
3. Create a subaccount
Cards and transactions are segmented under a subaccount, which is also where enrollment controls and verification policy apply. Your sandbox already has one; create one for each business customer you serve:
POST /subaccounts HTTP/1.1
Host: api.sandbox.astrada.co
Authorization: Bearer <TOKEN>
Content-Type: application/json
{
"name": "Acme Corp",
"configurations": { "VISA": { "countries": "*" }, "MASTERCARD": { "countries": "*" } }
}curl -X POST https://api.sandbox.astrada.co/subaccounts \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "Acme Corp", "configurations": { "VISA": { "countries": "*" }, "MASTERCARD": { "countries": "*" } } }'import { SubaccountsApi } from '@astrada.co/ts-astrada-sdk';
const subaccount = await new SubaccountsApi(config).createSubaccount({
subaccountCreateParams: {
name: 'Acme Corp',
configurations: { VISA: { countries: '*' }, MASTERCARD: { countries: '*' } },
},
});
console.log(subaccount.id);subaccount = client.subaccounts.create_subaccount(
astrada.SubaccountCreateParams(
name="Acme Corp",
configurations={"VISA": {"countries": "*"}, "MASTERCARD": {"countries": "*"}},
)
)
print(subaccount.id)import co.astrada.client.api.SubaccountsApi;
import co.astrada.client.model.CreateSubaccountConfigurations;
import co.astrada.client.model.CreateSubaccountConfigurationsMASTERCARD;
import co.astrada.client.model.CreateSubaccountConfigurationsVISA;
import co.astrada.client.model.Subaccount;
import co.astrada.client.model.SubaccountCreateParams;
Subaccount subaccount = new SubaccountsApi(client).createSubaccount(new SubaccountCreateParams()
.name("Acme Corp")
.configurations(new CreateSubaccountConfigurations()
.VISA(new CreateSubaccountConfigurationsVISA().countries("*"))
.MASTERCARD(new CreateSubaccountConfigurationsMASTERCARD().countries("*"))));
System.out.println(subaccount.getId());configurations sets, per network, which card-issuing countries are eligible. "*" inherits your account's own capabilities and is the safer default. For the full rules, see Account & Subaccount Configuration.
4. Register a webhook
Nothing reaches you until you register an endpoint for the event types you want:
POST /webhooks HTTP/1.1
Host: api.sandbox.astrada.co
Authorization: Bearer <TOKEN>
Content-Type: application/json
{
"url": "https://example-api.com/webhooks",
"eventTypes": ["cardsubscription.created", "cardsubscription.updated", "banklink.completed", "transactionmessage.created", "transaction.created", "transaction.updated"],
"subaccountId": "<SUBACCOUNT_ID>"
}curl -X POST https://api.sandbox.astrada.co/webhooks \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example-api.com/webhooks", "eventTypes": ["cardsubscription.created", "cardsubscription.updated", "banklink.completed", "transactionmessage.created", "transaction.created", "transaction.updated"], "subaccountId": "<SUBACCOUNT_ID>" }'import { WebhooksApi } from '@astrada.co/ts-astrada-sdk';
const webhook = await new WebhooksApi(config).createWebhook({
webhookCreateParams: {
url: 'https://example-api.com/webhooks',
eventTypes: [
'cardsubscription.created', 'cardsubscription.updated', 'banklink.completed',
'transactionmessage.created', 'transaction.created', 'transaction.updated',
],
subaccountId: subaccount.id, // from step 3
},
});
const webhookSecret = webhook.secret; // store it now: it is returned only herewebhook = client.webhooks.create_webhook(
astrada.WebhookCreateParams(
url="https://example-api.com/webhooks",
event_types=[
"cardsubscription.created", "cardsubscription.updated", "banklink.completed",
"transactionmessage.created", "transaction.created", "transaction.updated",
],
subaccount_id=subaccount.id, # from step 3
)
)
webhook_secret = webhook.secret # store it now: it is returned only hereimport co.astrada.client.api.WebhooksApi;
import co.astrada.client.model.WebhookCreateParams;
import co.astrada.client.model.WebhookCreateParams.EventTypesEnum;
import co.astrada.client.model.WebhookCreateResult;
import java.net.URI;
import java.util.Arrays;
WebhookCreateResult webhook = new WebhooksApi(client).createWebhook(new WebhookCreateParams()
.url(URI.create("https://example-api.com/webhooks"))
.eventTypes(Arrays.asList(EventTypesEnum.CARDSUBSCRIPTION_CREATED,
EventTypesEnum.CARDSUBSCRIPTION_UPDATED, EventTypesEnum.BANKLINK_COMPLETED,
EventTypesEnum.TRANSACTIONMESSAGE_CREATED, EventTypesEnum.TRANSACTION_CREATED,
EventTypesEnum.TRANSACTION_UPDATED))
.subaccountId(subaccount.getId())); // from step 3
String webhookSecret = webhook.getSecret(); // store it now: it is returned only herebanklink.completed matters only if you connect a bank (step 5); Bank Linking Webhooks & Events lists the other bank events, such as bankaccount.state_changed.
The response's secret is returned once, at creation, so save it for signature verification. See Webhooks for retries and the (required) signature-verification step; the backend SDKs include a helper that checks the signature.
5. Connect a bank (optional)
Connecting a bank adds bank-only transactions (fees, transfers, payroll), earlier settlement for card spend, and American Express enrollment through the cardholder's Amex sign-in. It is independent of card enrollment, so connect it early: every card enrolled afterward then benefits from its first transaction, because auto-detected card-to-account links do not backfill history. Remember to keep banklink.completed in the eventTypes from step 4. For the full walkthrough, see Quick Start: Bank Linking.
6. Enroll a card
Choose the way that fits your product:
- SDK v2: Quick Start: start here. The Unified Enrollment SDK v2 in sandbox: one embedded flow that routes each card to the card form, a bank sign-in or the company program. Its guide is Unified Enrollment SDK v2.
- Enrollment Links: no page of your own. Your backend creates a link, you send it to the person, and they connect their own cards on a page Astrada hosts.
- Direct API Card Enrollment: server-to-server, no SDK. Only for partners Astrada has granted permission; ask your Astrada contact first.
Already on the legacy Card Enrollment SDK or Unified v1? Their pages stay under Enrolling Cards: Unified Enrollment SDK v1 and the Card Enrollment SDK.
cardsubscription.created fires when the subscription is created; a card entered by number is connected when cardsubscription.updated reports active. A failed verification sends no webhook and leaves the subscription at reqSCA: see Triage a failed verification. Re-enrolling reuses the same cardId and creates a new subscriptionId.
7. Receive transactions
Card and bank activity arrives as transaction.created / transaction.updated, each carrying the cardId you match against your records. In sandbox nobody makes a real purchase, so send one yourself against the card from step 6 with Simulate a transaction scenario:
curl -X POST https://api.sandbox.astrada.co/simulate/transaction/scenario \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "scenario": "simple_purchase", "cardId": "<CARD_ID>", "subaccountId": "<SUBACCOUNT_ID>" }'import { sandbox } from '@astrada.co/ts-astrada-sdk';
await new sandbox.SandboxSimulationApi(config).simulateTransactionScenario({
simulateTransactionScenarioRequest: {
scenario: 'simple_purchase',
cardId: '<CARD_ID>',
subaccountId: '<SUBACCOUNT_ID>',
},
});from astrada.sandbox import SimulateTransactionScenarioRequest
client.sandbox.simulate_transaction_scenario(
SimulateTransactionScenarioRequest(
scenario="simple_purchase", card_id="<CARD_ID>", subaccount_id="<SUBACCOUNT_ID>"
)
)import co.astrada.client.model.SimulateTransactionScenarioRequest;
import java.util.UUID;
client.sandbox().simulateTransactionScenario(new SimulateTransactionScenarioRequest()
.scenario(SimulateTransactionScenarioRequest.ScenarioEnum.SIMPLE_PURCHASE)
.cardId(UUID.fromString("<CARD_ID>"))
.subaccountId(UUID.fromString("<SUBACCOUNT_ID>")));_links.messages on the transaction points to the underlying Transaction Messages. If you derive amounts from individual messages, exclude the ids in supersededMessageIds (duplicate clearings), or just use the transaction's own settled amounts. For every event and payload, see Event Types.
8. Manage and query
- Deactivate a subscription:
PATCH /card-subscriptions/{id}with{ "state": "deactivated" }. This is final, and not available for bulk-enrolled subscriptions. If the card also has a linked bank account, deactivating it stops that bank account's feed for the card too; to stop only the card network data, ask your Astrada contact. - Fetch transaction state:
GET /transactions/{id}, or list withGET /transactions.
What to build next
Each business event, and the webhook and API call that go with it:
| Business event | Webhook | API call | Notes |
|---|---|---|---|
| A business customer signs up | none | POST /subaccounts | Segments cards and transactions, and carries enrollment controls and verification policy. |
| Bank account is connected (optional) | banklink.completed, cardsubscription.created | POST /bank-links | Adds bank data and earlier settlement. Completion also enrolls each credit account as a bank-feed card. See Quick Start: Bank Linking. |
| Card is enrolled | cardsubscription.created | SDK, or POST /card-subscriptions | enrollmentType tells you the way it was enrolled (cardholder-single / bank-feed / network-bulk). A card entered by number starts at reqSCA and is connected when cardsubscription.updated reports active. |
| Expense is made / updated | transaction.created / transaction.updated | none | Amount revisions (tips, FX, early settlement) are expected, not errors. |
| Bank posting matched to a card transaction | transaction.match.created | none | The reconciliation signal, with a confidence and a score, once cards are linked to a bank account. See Bank Linking Webhooks & Events. |
| Card is deactivated | cardsubscription.updated (state: deactivated) | PATCH /card-subscriptions/{id} | Final, and unavailable for bulk-enrolled subscriptions. |
For example, an AI finance agent can read transaction.created with status PENDING to ask the cardholder for a receipt while the purchase is still pending, and a month-end close tool can read transaction.created and transaction.updated with status SETTLED, and transaction.match.created, to post settled charges and mark them matched. Use Cases lists what each one reads.
Next steps
- Unified Card & Bank Feeds: the shared model across every way of enrolling.
- Quick Start: Bank Linking and SDK v2: Quick Start.
- Event Types: every webhook payload, in one place.
Updated 22 minutes ago
