Add a card from a token
Turns a single-use paymentToken (mtok_…) from browser capture into a reusable saved card. Needs a customer id (create one at the top of this folder) and a FRESH token — see "Where a payment token comes from" in 00 · Start here. With the hosted frame not serving yet, this runs once Elements is up.
Response contract
The successful wire shape and errors an integration should branch on.
Payment method
application/jsonidstringrequired- Unique payment-method identifier.
object"payment_method"required- Stable resource discriminator.
customerIdstringrequired- Customer that owns this method.
brandstringrequired- Card brand.
last4stringrequired- Last four digits only.
expMonthintegerrequired- Expiration month.
expYearintegerrequired- Four-digit expiration year.
isDefaultbooleanrequired- Whether this is the customer default.
createdAtstringrequired- ISO 8601 creation timestamp.
Example response
{
"id": "pm_01JEXAMPLE",
"object": "payment_method",
"customerId": "cus_01JEXAMPLE",
"brand": "visa",
"last4": "4242",
"expMonth": 12,
"expYear": 2030,
"isDefault": true,
"createdAt": "2026-08-10T20:49:51.653Z"
}Error responses
authentication_failedThe key is missing, malformed, revoked, or invalid for this environment.
permission_deniedThe key does not have paymentMethods.create.
invalid_requestOne or more request fields are invalid.