Skip to main content

Payment Methods

A payment method registers a source for agentic purchases and provisions every payment rail it supports. It carries no spending authority, so one payment method backs many allowances, each of which mints payment credentials.

Create a Payment Method

Registers the source with every supported provider in parallel and returns the outcome of each rail.

POST
https://api.basistheory.com/agentic/payment-methods
Copy

Permissions

agentic:payment-method:create

Available to public and private applications.

Request

Create a Payment Method
curl 'https://api.basistheory.com/agentic/payment-methods' \
-X 'POST' \
-H 'BT-API-KEY: <PUBLIC_API_KEY>' \
-H 'BT-IDEMPOTENCY-KEY: pm-create-shopper-card-v1' \
-H 'Content-Type: application/json' \
--data '{
"source": {
"type": "basis_theory_card_token",
"token_id": "7d9f4a48-4f14-4b29-9f0a-3b4dd75f6c21"
},
"consumer": {
"email": "shopper@example.com",
"id": "8e7d3f98-3e7b-4ab2-bd48-44e70cc8ec3f",
"country_code": "US",
"language_code": "en-US"
}
}'

Headers

HeaderRequiredDescription
BT-API-KEYYesPublic or private application key with agentic:payment-method:create. Never expose a private key in browser code
BT-IDEMPOTENCY-KEYNoOpts into durable retry handling. Without it, every request is a new create operation. See Idempotency

Request Parameters

AttributeRequiredTypeDescription
sourceYesobjectThe source for this payment method
consumerYesobjectThe consumer this payment method belongs to
agent_idNostringNon-empty. Optional attribution to an agent owned by the tenant; an unknown ID returns 404 AGENT_NOT_FOUND. Informational only and does not authorize the caller

Source Object

source is a discriminated union on type. Switch on type rather than assuming its shape.

AttributeRequiredTypeDescription
typeYesstringExactly basis_theory_card_token
token_idYesuuidID of a Basis Theory card token readable within the tenant. A missing token, or a token whose type is not card, returns 400 INVALID_TOKEN

Consumer Object

AttributeRequiredTypeDescription
emailYesstringValid email address. Rails that verify the consumer use it to identify them
idNouuidYour identifier for the consumer. Generated and returned when omitted. Use it to list a consumer's payment methods
country_codeNostringISO 3166-1 alpha-2 country of residence. Lowercase is normalized to uppercase
language_codeNostringBCP 47 language tag, 2 to 35 characters, canonicalized on input

Response

Returns a payment method object with 201, including when every rail failed at its provider. Read the rails array before using the payment method.

Response
{
"id": "pm_h2Kd91mAqLwX",
"source": {
"type": "basis_theory_card_token",
"token_id": "7d9f4a48-4f14-4b29-9f0a-3b4dd75f6c21"
},
"status": "active",
"consumer": {
"email": "shopper@example.com",
"id": "8e7d3f98-3e7b-4ab2-bd48-44e70cc8ec3f",
"country_code": "US",
"language_code": "en-US"
},
"card": {
"brand": "visa",
"bin": "424242",
"last4": "4242",
"expiration_month": 12,
"expiration_year": 2030,
"funding": "credit",
"issuer": { "name": "Example Bank", "country": "US" },
"issuer_country": { "alpha2": "US", "name": "UNITED STATES OF AMERICA", "numeric": "840" },
"segment": "Consumer",
"display": {
"art_url": "https://assets.vims.visa.com/vims/cardart/6f7c1e9d",
"background_color": "#1A1F71",
"foreground_color": "#FFFFFF",
"description": "Visa Signature",
"issuer_name": "Example Bank"
}
},
"rails": [
{
"rail": "agentic-token",
"provider": "vic",
"status": "enabled",
"provider_ids": {
"vpan_enrollment_id": "6f7c1e9d",
"provisioned_token_id": "8a2b4c1f"
}
},
{
"rail": "spt",
"provider": "stripe",
"status": "error",
"error": { "code": "CARD_REJECTED" }
}
],
"created_at": "2030-07-06T17:30:00.000Z",
"updated_at": "2030-07-06T17:30:00.000Z"
}

The idempotency key, not the source or consumer, defines sameness: a different or omitted key creates a distinct payment method even when the source and consumer are identical. After 409 CREATE_OUTCOME_UNKNOWN the key is terminal; recover by listing payment methods as described in Errors and Recovery. Perform the same list check before retrying a keyless create whose response was lost.

Errors: 400 VALIDATION_ERROR, 400 INVALID_TOKEN, 400 UNSUPPORTED_PROVIDER, 404 AGENT_NOT_FOUND, 409 IDEMPOTENCY_CONFLICT, 409 IDEMPOTENCY_IN_PROGRESS, 409 CREATE_OUTCOME_UNKNOWN.

List Payment Methods

GET
https://api.basistheory.com/agentic/payment-methods
Copy

Permissions

agentic:payment-method:get

Request

List Payment Methods
curl 'https://api.basistheory.com/agentic/payment-methods?consumer_id=8e7d3f98-3e7b-4ab2-bd48-44e70cc8ec3f&size=20' \
-H 'BT-API-KEY: <PRIVATE_API_KEY>'

Query Parameters

ParameterRequiredTypeDefaultDescription
sizeNointeger201 through 100. Out of range returns 400
startNostringOpaque cursor from the previous response's pagination.next
consumer_idNouuidReturn only payment methods for one consumer
statusNostringactiveactive, deleted, or all

Response

Returns a paginated list of payment method objects using the platform's cursor pagination. A filtered page can return fewer than size results while more remain, so treat the absence of pagination.next, not a short page, as the end of the results.

Response
{
"data": [
{ "id": "pm_h2Kd91mAqLwX", "...": "..." }
],
"pagination": {
"next": "eyJQSyI6",
"page_size": 1
}
}

Get a Payment Method

GET
https://api.basistheory.com/agentic/payment-methods/{payment_method_id}
Copy

Permissions

agentic:payment-method:get

Request

Get a Payment Method
curl 'https://api.basistheory.com/agentic/payment-methods/pm_h2Kd91mAqLwX' \
-H 'BT-API-KEY: <PRIVATE_API_KEY>'

Request Parameters

AttributeRequiredTypeDescription
payment_method_idYesstringID of the payment method to retrieve

Response

Returns a payment method object, or 404 PAYMENT_METHOD_NOT_FOUND when the ID does not exist within the tenant.

Retry a Payment Method Rail

Re-runs provisioning for one rail without recreating the payment method. Use it after a transient provider failure, and to resolve a rail left pending.

POST
https://api.basistheory.com/agentic/payment-methods/{payment_method_id}/rails/retry
Copy

Permissions

agentic:payment-method:create

Available to public and private applications.

Request

Retry a Payment Method Rail
curl 'https://api.basistheory.com/agentic/payment-methods/pm_h2Kd91mAqLwX/rails/retry' \
-X 'POST' \
-H 'BT-API-KEY: <PUBLIC_API_KEY>' \
-H 'Content-Type: application/json' \
--data '{
"rail": "spt",
"provider": "stripe"
}'

Request Parameters

AttributeRequiredTypeDescription
payment_method_idYesstringID of the payment method
railYesstringagentic-token or spt. Must be present on the payment method
providerYesstringvic, agentpay, or stripe. Must be valid for the rail

Only rails whose status is error or pending can be retried. Any other status returns 400 VALIDATION_ERROR.

Response

Returns the complete updated payment method object with 200, so the new rail status can be read directly from it.

Errors: 400 VALIDATION_ERROR, 400 RAIL_NOT_FOUND, 400 PAYMENT_METHOD_DELETED, 404 PAYMENT_METHOD_NOT_FOUND, 422 when the provider rejects the retry, such as 422 CARD_REJECTED or 422 RAIL_ENROLLMENT_INVALID, and 409 RAIL_ALREADY_ENROLLED when the provider reports the source as already enrolled. A rejected retry leaves the stored rail in error.

It can also return 409 PAYMENT_METHOD_OPERATION_IN_PROGRESS, 409 PAYMENT_METHOD_DELETE_IN_PROGRESS, or 409 PAYMENT_METHOD_DELETE_INCOMPLETE; see Operations in Progress.

List Payment Method Errors

Returns sanitized provider failures for the payment method and the operations beneath it, retained for 90 days.

GET
https://api.basistheory.com/agentic/payment-methods/{payment_method_id}/errors
Copy

Permissions

agentic:payment-method:get

Request

List Payment Method Errors
curl 'https://api.basistheory.com/agentic/payment-methods/pm_h2Kd91mAqLwX/errors' \
-H 'BT-API-KEY: <PRIVATE_API_KEY>'

Query Parameters

ParameterRequiredTypeDefaultDescription
sizeNointeger201 through 100
startNostringOpaque cursor from the previous response's pagination.next

Response

Returns a paginated list of provider error objects. Provider response bodies, provider messages, sensitive source data, and credential values are never included.

Delete a Payment Method

DELETE
https://api.basistheory.com/agentic/payment-methods/{payment_method_id}
Copy

Permissions

agentic:payment-method:delete

Request

Delete a Payment Method
curl 'https://api.basistheory.com/agentic/payment-methods/pm_h2Kd91mAqLwX' \
-X 'DELETE' \
-H 'BT-API-KEY: <PRIVATE_API_KEY>'

Response

Returns 204 with no body.

Deletion cascades. Every allowance backed by the payment method is cancelled, including any provider-side mandates held for those allowances, and no further verification or credential minting is possible on any of them.

Deletion is idempotent: repeating a successful delete succeeds without another provider call and without changing updated_at. Deletion requires no child operation to be in flight, so a concurrent allowance create, rail retry, or mint returns 409 PAYMENT_METHOD_OPERATION_IN_PROGRESS.

Errors: 404 PAYMENT_METHOD_NOT_FOUND, 409 PAYMENT_METHOD_OPERATION_IN_PROGRESS, 409 PAYMENT_METHOD_DELETE_IN_PROGRESS, 500 PROVIDER_ALLOWANCE_CANCEL_FAILED when a child allowance cannot be cancelled at its provider (e.g. a vic allowance). A delete that stopped during its cascade is resumed by repeating the DELETE; child operations, not this endpoint, return PAYMENT_METHOD_DELETE_INCOMPLETE.

Rails and Providers

A rail is identified by the rail and provider pair together. Only these combinations are valid:

railproviderProvider programCredential formats
agentic-tokenvicVisa Intelligent Commercecard, network-token, mpp
agentic-tokenagentpayMastercard Agent Paycard, network-token, mpp
sptstripeStripe Shared Payment Tokensidentifier, mpp

Any other pairing returns 400 VALIDATION_ERROR naming the provider field. A pairing that is valid but not present on the resource returns 400 RAIL_NOT_FOUND.

Rails follow from the source: a Visa card provisions vic, a Mastercard card provisions agentpay, and either can back the spt rail. The provider is not a caller input.

Treat rail and provider as reported capabilities, not a product choice. Do not infer or select a provider yourself: read the pair off the resource and send it back only when an endpoint asks you to identify an existing rail. A payment method's rails array and an allowance's rails are the authoritative list of what that resource can do.

Payment Method Object

AttributeTypeDescription
idstringPrefixed with pm_
sourceobjectThe source object supplied at creation
statusstringactive or deleted
consumerobjectThe consumer object, including a generated id when one was not supplied
cardobjectPresent when the source is a card: non-sensitive card metadata resolved from the token and enriched by the enrolling provider
railsarrayOne payment method rail per provisioned rail
agent_idstringPresent when supplied at creation
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp. Changes only for externally observable state, not for internal lock or counter activity

Payment Method Rail Object

AttributeTypeDescription
railstringThe rail this entry provisions. See Rails and Providers
providerstringThe provider operating the rail. See Rails and Providers
statusstringenabled, pending, or error. See rail statuses
errorobjectPresent only when status is error. Contains a stable machine-readable code drawn from the rail error codes
provider_idsobjectProvider-native reference identifiers, all string values. Informational for support and correlation; the key set varies by provider and is not a stable contract

Rail Statuses

StatusMeaning
enabledProvisioning succeeded. Allowances can be created against this rail
pendingProvisioning will resolve asynchronously. Retry the rail to pick up the result
errorThe provider rejected or failed provisioning. error.code carries the reason

Clients must handle all three. A rail in enabled or pending never carries an error object.

Card Object

Every field is optional, since availability depends on the token and on what the enrolling provider returned.

AttributeTypeDescription
brandstringCard network reported by the vault, such as visa. The agentic-token rail requires visa or mastercard; the spt rail accepts any network Stripe supports, so treat this as an open string
binstringCard BIN
last4stringLast four digits of the card
expiration_monthintegerCard expiration month
expiration_yearintegerFour-digit card expiration year
fundingstringFunding type, such as credit or debit
typestringAlways card
segmentstringCard segment, such as Consumer
issuerobjectname and country of the issuing bank
issuer_countryobjectalpha2, name, and numeric ISO 3166 representations
displayobjectProvider-supplied card display data

Full card numbers and security codes are never stored on or returned by a payment method.

Card Display Object

Presentation data supplied by the provider that enrolled the card. Use it to render the card rather than inferring issuer branding. A rail retry that eventually succeeds backfills these values if the first attempt did not return them.

AttributeTypeDescription
art_urlstringIssuer card art, hosted by the provider
background_colorstringHex color for a card tile when no art is available
foreground_colorstringHex color for text on that tile
descriptionstringShort product name, such as Visa Signature
issuer_namestringIssuing bank name

Every field is nullable; fall back to {brand} •••• {last4} when one is absent.