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.
Permissions
agentic:payment-method:create
Available to public and private applications.
Request
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
| Header | Required | Description |
|---|---|---|
BT-API-KEY | Yes | Public or private application key with agentic:payment-method:create. Never expose a private key in browser code |
BT-IDEMPOTENCY-KEY | No | Opts into durable retry handling. Without it, every request is a new create operation. See Idempotency |
Request Parameters
| Attribute | Required | Type | Description |
|---|---|---|---|
source | Yes | object | The source for this payment method |
consumer | Yes | object | The consumer this payment method belongs to |
agent_id | No | string | Non-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.
| Attribute | Required | Type | Description |
|---|---|---|---|
type | Yes | string | Exactly basis_theory_card_token |
token_id | Yes | uuid | ID 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
| Attribute | Required | Type | Description |
|---|---|---|---|
email | Yes | string | Valid email address. Rails that verify the consumer use it to identify them |
id | No | uuid | Your identifier for the consumer. Generated and returned when omitted. Use it to list a consumer's payment methods |
country_code | No | string | ISO 3166-1 alpha-2 country of residence. Lowercase is normalized to uppercase |
language_code | No | string | BCP 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.
{
"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": "42424242",
"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.