Skip to content
myela

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.

Add a card from a token

POST/v1/payment_methodsLink

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.

SandboxSecret keypaymentMethods.create

Request fields

Edit a field and the generated request updates immediately.

Request body
stringrequired

The customer that owns or receives this resource.

stringrequired

A single-use token returned by Myela Elements or an approved card-capture field.

Response contract

The successful wire shape and errors an integration should branch on.

201

Payment method

application/json
idstringrequired
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
401authentication_failed

The key is missing, malformed, revoked, or invalid for this environment.

403permission_denied

The key does not have paymentMethods.create.

422invalid_request

One or more request fields are invalid.