Creates a single-use token that represents a credit card’s details. You can use this token in place of a credit card object with any v1 API method. You can only use these tokens once by creating a new Charge object or by attaching them to a Customer object.
To use this functionality, you need to enable access to the raw card data APIs. In most cases, you can use our recommended payments integrations instead of using the API.
Parameters
- cardobject | string
The card this token will represent. If you also pass in a customer, the card must be the ID of a card belonging to the customer. Otherwise, if you do not pass in a customer, this is an object containing a user’s credit card details, with the options described below.
- card.
exp_ monthstringRequired Two-digit number representing the card’s expiration month.
- card.
exp_ yearstringRequired Two- or four-digit number representing the card’s expiration year.
- card.
numberstringRequired The card number, as a string without any separators.
- card.
address_ citystring City / District / Suburb / Town / Village.
- card.
address_ countrystring Billing address country, if provided.
- card.
address_ line1string Address line 1 (Street address / PO Box / Company name).
- card.
address_ line2string Address line 2 (Apartment / Suite / Unit / Building).
- card.
address_ statestring State / County / Province / Region.
- card.
address_ zipstring ZIP or postal code.
- card.
currencystringcustom Connect only Required in order to add the card to an account; in all other cases, this parameter is not used. When added to an account, the card (which must be a debit card) can be used as a transfer destination for funds in this currency.
- card.
cvcstringUsually required Card security code. Highly recommended to always include this value.
- card.
namestring Cardholder’s full name.
- card.
networksobject Contains information about card networks used to process the payment.
- card.
networks. preferredenum The customer’s preferred card network for co-branded cards. Supports
cartes_
,bancaires mastercard
, orvisa
. Selection of a network that does not apply to the card will be stored asinvalid_
on the card.preference
Returns
Returns the created card token if it’s successful. Otherwise, this call raises an error.
{ "id": "tok_1N3T00LkdIwHu7ixt44h1F8k", "object": "token", "card": { "id": "card_1N3T00LkdIwHu7ixRdxpVI1Q", "object": "card", "address_city": null, "address_country": null, "address_line1": null, "address_line1_check": null, "address_line2": null, "address_state": null, "address_zip": null, "address_zip_check": null, "brand": "Visa", "country": "US", "cvc_check": "unchecked", "dynamic_last4": null, "exp_month": 5, "exp_year": 2026, "fingerprint": "mToisGZ01V71BCos", "funding": "credit", "last4": "4242", "metadata": {}, "name": null, "tokenization_method": null, "wallet": null }, "client_ip": "52.35.78.6", "created": 1683071568, "livemode": false, "type": "card", "used": false}