Linking Cards to Bank Accounts
Link cards to a connected bank account for earlier settlement: automatic last-4 matching, manual linking with history backfill, and one account per card.
For: developers
Introduction
Linking a card to a connected bank account is what turns on earlier settlement for that card: when a card authorization matches a posted bank transaction on the account, the transaction moves from PENDING to SETTLED on the bank's evidence, typically within hours of the swipe rather than days.
Linking cards is optional and independent of the bank connection itself. Bank-only events (fees, transfers, payroll, FX markup) fire on a connected bank account with no card link at all. See Quick Start: Bank Linking. This page is about the second step: attaching cards for earlier settlement.
You may not need to call anythingCard links are detected automatically. Read on for when to link manually: pre-linking before any spend, correcting an assignment, or importing history.
Automatic detection
Astrada links cards automatically at two moments, with no API call required: at bank-link completion, and after completion.
At bank-link completion
At bank-link completion, each discovered credit account's mask is compared against the subaccount's enrolled cards:
| Case | Which card links |
|---|---|
| A card's last 4 digits match exactly one way | That card is linked. |
| Several enrolled cards share the mask | Evidence derived from each card's number (the issuing bank it implies versus the connected institution, and its funding type) can narrow the field: if exactly one plausible card remains, it links. |
| Anything still ambiguous | Links nothing. |
| A mask claimed by several accounts | If exactly one of those accounts is active, the card links to that one. Otherwise it links nothing. |
What happens next depends on what that mask matched:
| What the mask matched | Is a bank-feed card created? |
|---|---|
| None of those matches is a card you've already enrolled | Yes: the account gets its own bank-feed card instead, so its feed still has an identity (see Unified Card & Bank Feeds). |
| A card you've already enrolled | No bank-feed card is created: the account uses the card you enrolled. Astrada does not create a second card for one you already enrolled. |
After completion
After completion, the same last-4 rule keeps running. Every few hours Astrada re-checks each bank account that still has no card against the subaccount's enrolled cards, and links one when the match is again exactly one-to-one. So the common card-after-bank path needs no API call either: connect the bank, enroll the card whenever you like, and the link appears on the next pass.
It is deliberately the same rule in both places. A link is decided by last 4 digits and institution, never by guesswork about which card a transaction belongs to, so the answer you get after completion is the answer you would have got at completion had the card existed then.
Two things to know about auto-detected links:
- They do not backfill history. Only transactions from the moment of linking forward benefit from earlier settlement. To import earlier history, link the card manually with
backfill(below). - The current set of linked cards is always readable. See Reading the current links.
Why an account has no card
When a bank link completes and leaves a credit account with no card, the API says why: noLinkReason on GET /bank-accounts/{id} (and on the completed bank link's account summaries) names the case (bulk_card_owns_mask, mask_ambiguous_accounts, mask_ambiguous_cards, card_linked_elsewhere, card_not_attachable, no_institution_id or mask_matches_no_plausible_card). The field disappears as soon as any card links.
Manual linking
PATCH /bank-accounts/{id} (scope banking:write) sets the account's card set explicitly. It's the manual override for the automatic detector. Use it to:
- Pre-link a card before any spend exists, so the very first matching transaction settles early.
- Correct an assignment, or move a card between accounts.
- Import history for newly linked cards, via
backfill.
PATCH /bank-accounts/a1b2c3d4-e5f6-7890-abcd-ef1234567890 HTTP/1.1
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
{
"cardIds": [
"5dec2c49-0aa5-4683-a317-427eb5d115f3",
"8abc1d23-4e56-7f89-0abc-def123456789"
],
"backfill": { "startDate": "2026-01-27", "endDate": "2026-04-27" }
}# Sandbox shown; production is https://api.astrada.co
curl -X PATCH https://api.sandbox.astrada.co/bank-accounts/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cardIds": [
"5dec2c49-0aa5-4683-a317-427eb5d115f3",
"8abc1d23-4e56-7f89-0abc-def123456789"
],
"backfill": { "startDate": "2026-01-27", "endDate": "2026-04-27" }
}'{
"cardIds": [
"5dec2c49-0aa5-4683-a317-427eb5d115f3",
"8abc1d23-4e56-7f89-0abc-def123456789"
],
"backfill": { "startDate": "2026-01-27", "endDate": "2026-04-27" }
}| Field | Type | Required | Description |
|---|---|---|---|
cardIds | UUID[] | Yes | The cards to link. Full replacement: send the complete desired set, not a delta. |
backfill | object | No | Opt-in historical import. Runs only for cards being added in this request. |
backfill.startDate | ISO date | No | Defaults to 90 days ago. |
backfill.endDate | ISO date | No | Defaults to today. |
Response (200 OK):
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"cardIds": [
"5dec2c49-0aa5-4683-a317-427eb5d115f3",
"8abc1d23-4e56-7f89-0abc-def123456789"
],
"state": "active",
"updatedAt": "2026-04-27T15:00:00Z",
"backfill": { "transactionsProcessed": 50, "matchesFound": 10 }
}The backfill block appears only when a backfill was requested.
cardIdsis a full replacementThe endpoint replaces the account's card set with exactly what you send. It is not a delta. To add a card, send the existing
cardIdsplus the new one; to remove one, send the set without it. SendingcardIds: []clears every link on the account: manual, mask-matched, and the link to any card created from this account at completion. Unlinking a created card changes how the account's feed is attributed and removes it from the account'scards[]list; the card and itsbank-feedsubscription continue to exist, and re-linking it later restores it tocardIdsonly.A removal is not permanent if it leaves the account cardless. If the card you removed still matches the account's last 4 and the account is left with no cards, automatic detection re-links it within a few hours; the scheduled sweep re-examines only cardless accounts, so an account that keeps other cards keeps your edit. A manual removal holds only while the account keeps another card, because the last-4 rule keeps applying. To keep a card off an account for good, link it to the account it does belong to, or deactivate it. Always start from the account's current
cardIds, which includes created cards, and edit that set.
Backfill history
The backfill field on the manual linking request imports historical bank transactions for the cards you add (default: the last 90 days). Earlier settlement then runs against any historical card authorizations still in PENDING, and bank-only events fire retroactively for historical transactions that remain unmatched.
Backfill runs only for the cards added in that request, not cards already linked to the account.
Multi-card linking & constraints
A bank account can carry many cards; a card links to at most one bank account at a time. One rule returns an error; the other you must check yourself. Handle both in your linking UI:
| Rule | On violation |
|---|---|
| A card links to only one bank account at a time. | 409 Conflict: the card is already linked to another bank account. |
Every card and the bank account must share the same subaccountId. | PATCH answers 422 (SUBACCOUNT_MISMATCH) for a card being added from another subaccount, and nothing is saved. |
To move a card from account A to account B: first PATCH A with a cardIds set that omits the card (freeing it), then PATCH B to add it. Linking a card to B while it's still linked to A returns 409 Conflict (the card is already linked to another bank account).
Reading the current links
GET /bank-accounts/{id}(scopebanking:read): the account, including itscardIds(linked cards) andcards[](cards created from the account at bank-link completion).GET /bank-accounts?cardId={cardId}: the account a given card is linked to (empty if none).GET /bank-accounts?subaccountId={subaccountId}: every account for a subaccount, each with itscardIds.
Next steps
- Quick Start: Bank Linking: the integration from token to events.
- Bank Linking Webhooks & Events: what earlier settlement looks like on the wire.
- Webhook Event Types: the canonical event catalog.
Updated 4 days ago
