# Create a payment token

Creates a payment token which can be exchanged into a payment instrument.
[FramePay](https://www.rebilly.com/docs/dev-docs/framepay) is the recommended way to create a payment token because it minimizes PCI DSS compliance.
After a payment token is created, it can only be used once.

A payment token expires upon first use or within 30 minutes of the token creation, whichever comes first.

Endpoint: POST /tokens
Version: latest
Security: PublishableApiKey, SecretApiKey, JWT

## Request fields

- `method` (string, required)
  Payment method of the token.
  Enum: "cryptocurrency"
- `paymentInstrument` (object, required)
  Payment card instrument details.
- `paymentInstrument.pan` (string)
  Primary Account Number (PAN) of the payment card. This value is required to perform a payment.
- `paymentInstrument.cvv` (string)
  Card Verification Value (CVV/CVC) of the payment card. Takes precedence over `encryptedCvv` if both are included.
- `paymentInstrument.encryptedCvv` (string | null)
  Encrypted CVV of the payment card. Use to update a payment card with a CVV stored on the client side. This value is returned for client side caching if `cvv` is provided in the request.
- `paymentInstrument.expMonth` (integer, required)
  Expiration month of the payment card.
- `paymentInstrument.expYear` (integer, required)
  Expiration year of the payment card.
- `paymentInstrument.brand` (string)
  Brand of payment card.
  Enum: "Visa", "MasterCard", "American Express", "Discover", "Maestro", "Solo", "Electron", "JCB", "Voyager", "Diners Club", "Switch", "Laser", "China UnionPay", "AstroPay Card"
- `billingAddress` (object)
  Contact's information.
- `billingAddress.firstName` (string | null)
  Contact's first name.
  Example: Benjamin
- `billingAddress.lastName` (string | null)
  Contact's last name.
  Example: Franklin
- `billingAddress.organization` (string | null)
  Contact's organization.
  Example: Rebilly
- `billingAddress.address` (string | null)
  First line of the contact's street address.
  Example: 36 Craven St
- `billingAddress.address2` (string | null)
  Second line of the contact's street address.
- `billingAddress.city` (string | null)
  Contact's city of residence.
  Example: Austin
- `billingAddress.region` (string | null)
  Contact's region of residence.
  Example: Texas
- `billingAddress.country` (string | null)
  Contact's country of residence in ISO 3166 alpha-2 country code. For examples, see [ISO.org](https://www.iso.org/obp/ui/#search/code/).
  Example: GB
- `billingAddress.postalCode` (string | null)
  Contact's postal code.
  Example: WC2N 5NF
- `billingAddress.phoneNumbers` (array)
  List of phone numbers associated with the contact.
- `billingAddress.phoneNumbers.label` (string, required)
  Phone number label or name.
  Example: main
- `billingAddress.phoneNumbers.value` (string, required)
  Phone number value.
  Example: 1-512-777-0269
- `billingAddress.phoneNumbers.primary` (boolean)
  Specifies if the phone number is the contact's primary phone number.
  Example: true
- `billingAddress.emails` (array)
  List of email addresses associated with the contact.
- `billingAddress.emails.label` (string, required)
  Email label or name.
  Example: main
- `billingAddress.emails.value` (string, required)
  Email address value.
  Example: rebilly@example.com
- `billingAddress.emails.primary` (boolean)
  Specifies if the email address is the contact's primary email address.
  Example: true
- `billingAddress.dob` (string | null)
  Contact's date of birth in ISO-8601 `YYYY-MM-DD` format.
  Example: 1980-04-01
- `billingAddress.jobTitle` (string | null)
  Contact's job title.
  Example: CEO
- `id` (string)
  Unique resource ID.
  Example: 4f6cf35x-2c4y-483z-a0a9-158621f77a21
- `riskMetadata` (any)
- `leadSource` (any)
- `paymentInstrument` (object, required)
  Paypal instrument details required for express checkout.
- `paymentInstrument.paypalMerchantId` (string, required)
  ID of the PayPal merchant.
- `paymentInstrument.billingAgreementToken` (string, required)
  PayPal billing agreement token.
- `billingAddress` (any)
  Billing address object.
- `paymentInstrument` (object, required)
  Bank account BBAN or IBAN instrument.
- `paymentInstrument` (object, required)
  Payment instrument details.
- `paymentInstrument.type` (string, required)
  Type of digital wallet.
  Enum: "Apple Pay", "Google Pay", "Samsung Pay"
- `paymentInstrument.amount` (number, required)
  Authorized for the digital wallet amount.
- `paymentInstrument.currency` (string, required)
  Currency code in ISO 4217 format.
  Example: USD
- `paymentInstrument.descriptor` (string, required)
  Descriptor for a payment.
- `paymentInstrument.payload` (object, required)
  Digital wallet encoded data. This field may contain the digital wallet billing address.
- `paymentInstrument` (object, required)
  Plaid payment instrument details.
- `paymentInstrument.linkToken` (string, required)
  Plaid link token.
- `paymentInstrument.publicToken` (string, required)
  Plaid public token.
- `paymentInstrument.accountId` (string, required)
  ID of the Plaid account.
- `paymentInstrument` (object, required)
  Klarna instrument details required for express checkout.
- `paymentInstrument.klarnaAuthorizationToken` (string, required)
  Klarna authorization token.
- `paymentInstrument.klarnaSessionId` (string, required)
  ID of the Klarna session.
- `walletName` (string | null)
  Name of the crypto wallet.
- `walletAddress` (string | null)
  Address of the crypto wallet.
- `walletCurrency` (string | null)
  Currency of the crypto wallet.
- `walletNetwork` (string | null)
  Network of the crypto wallet.

## Response 201 fields

- `method` (string, required)
  Payment method of the token.
  Enum: "cryptocurrency"
- `paymentInstrument` (object, required)
  Payment card instrument details.
- `paymentInstrument.encryptedCvv` (string | null)
  Encrypted CVV of the payment card. Use to update a payment card with a CVV stored on the client side. This value is returned for client side caching if `cvv` is provided in the request.
- `paymentInstrument.expMonth` (integer, required)
  Expiration month of the payment card.
- `paymentInstrument.expYear` (integer, required)
  Expiration year of the payment card.
- `paymentInstrument.bin` (string | null)
  Bank Identification Number (BIN) of the payment card. This value is the first 6 digits of the payment card number.
- `paymentInstrument.last4` (string | null)
  Last 4 digits of the Primary Account Number (PAN) of the payment card.
- `paymentInstrument.brand` (string)
  Brand of payment card.
  Enum: "Visa", "MasterCard", "American Express", "Discover", "Maestro", "Solo", "Electron", "JCB", "Voyager", "Diners Club", "Switch", "Laser", "China UnionPay", "AstroPay Card"
- `billingAddress` (object)
  Contact's information.
- `billingAddress.firstName` (string | null)
  Contact's first name.
  Example: Benjamin
- `billingAddress.lastName` (string | null)
  Contact's last name.
  Example: Franklin
- `billingAddress.organization` (string | null)
  Contact's organization.
  Example: Rebilly
- `billingAddress.address` (string | null)
  First line of the contact's street address.
  Example: 36 Craven St
- `billingAddress.address2` (string | null)
  Second line of the contact's street address.
- `billingAddress.city` (string | null)
  Contact's city of residence.
  Example: Austin
- `billingAddress.region` (string | null)
  Contact's region of residence.
  Example: Texas
- `billingAddress.country` (string | null)
  Contact's country of residence in ISO 3166 alpha-2 country code. For examples, see [ISO.org](https://www.iso.org/obp/ui/#search/code/).
  Example: GB
- `billingAddress.postalCode` (string | null)
  Contact's postal code.
  Example: WC2N 5NF
- `billingAddress.phoneNumbers` (array)
  List of phone numbers associated with the contact.
- `billingAddress.phoneNumbers.label` (string, required)
  Phone number label or name.
  Example: main
- `billingAddress.phoneNumbers.value` (string, required)
  Phone number value.
  Example: 1-512-777-0269
- `billingAddress.phoneNumbers.primary` (boolean)
  Specifies if the phone number is the contact's primary phone number.
  Example: true
- `billingAddress.emails` (array)
  List of email addresses associated with the contact.
- `billingAddress.emails.label` (string, required)
  Email label or name.
  Example: main
- `billingAddress.emails.value` (string, required)
  Email address value.
  Example: rebilly@example.com
- `billingAddress.emails.primary` (boolean)
  Specifies if the email address is the contact's primary email address.
  Example: true
- `billingAddress.dob` (string | null)
  Contact's date of birth in ISO-8601 `YYYY-MM-DD` format.
  Example: 1980-04-01
- `billingAddress.jobTitle` (string | null)
  Contact's job title.
  Example: CEO
- `billingAddress.hash` (string)
  Hash value for the contact. Use this value to compare contacts for identical attribute values.
  Example: 056ae6d97c788b9e98b049ebafd7b229bf852221
- `id` (string)
  Unique resource ID.
  Example: 4f6cf35x-2c4y-483z-a0a9-158621f77a21
- `isUsed` (boolean)
  Specifies if the token has been used.
- `riskMetadata` (any)
- `leadSource` (any)
- `createdTime` (string)
  Date and time when the resource is created. This value is set automatically when the resource is created.
- `updatedTime` (string)
  Date and time when the resource is updated. This value is set automatically when the resource is updated.
- `usageTime` (string | null)
  Date and time when the token is used.
- `expirationTime` (string | null)
  Date and time when the token expired.
- `_links` (array)
  Related links.
- `_links.href` (string)
  Link URL.
- `_links.rel` (string)
  Type of link.
  Enum: "self"
- `paymentInstrument` (object, required)
  Paypal instrument details required for express checkout.
- `paymentInstrument.paypalMerchantId` (string, required)
  ID of the PayPal merchant.
- `paymentInstrument.billingAgreementToken` (string, required)
  PayPal billing agreement token.
- `billingAddress` (any)
  Billing address object.
- `isUsed` (boolean)
  Specifies if the token is already used.
- `expirationTime` (string | null)
  Date and time when the token expires.
- `paymentInstrument` (object, required)
  Bank account BBAN or IBAN instrument.
- `paymentInstrument` (object, required)
  Payment instrument details.
- `paymentInstrument.type` (string, required)
  Type of digital wallet.
  Enum: "Apple Pay", "Google Pay", "Samsung Pay"
- `paymentInstrument.amount` (number, required)
  Authorized for the digital wallet amount.
- `paymentInstrument.currency` (string, required)
  Currency code in ISO 4217 format.
  Example: USD
- `paymentInstrument.descriptor` (string, required)
  Descriptor for a payment.
- `paymentInstrument.bin` (string | null)
  Bank Identification Number (BIN) of the payment card. This value is the same as the first 6 digits of the associated Device Primary Account Number (DPAN).
- `paymentInstrument.last4` (string)
  Last 4 digits of the Device Primary Account Number (DPAN) of the payment card. The DPAN is the tokenized card number used in digital wallet transactions, as opposed to the Funding Primary Account Number (FPAN) which is the physical card number visible to the cardholder.
- `paymentInstrument.fpanLast4` (string | null)
  Last 4 digits of the Funding Primary Account Number (FPAN) of the payment card. The FPAN is the physical card number visible to the cardholder, as opposed to the Device Primary Account Number (DPAN) used in digital wallet transactions.
- `paymentInstrument.expMonth` (integer)
  Payment card expiration month.
- `paymentInstrument.expYear` (integer)
  Payment card expiration year.
- `paymentInstrument` (object, required)
  Plaid payment instrument details.
- `paymentInstrument.publicToken` (string, required)
  Plaid public token.
- `paymentInstrument.accountId` (string, required)
  ID of the Plaid account.
- `paymentInstrument` (object, required)
  Klarna instrument details required for express checkout.
- `paymentInstrument.klarnaAuthorizationToken` (string, required)
  Klarna authorization token.
- `paymentInstrument.klarnaSessionId` (string, required)
  ID of the Klarna session.
- `walletName` (string | null)
  Name of the crypto wallet.
- `walletAddress` (string | null)
  Address of the crypto wallet.
- `walletCurrency` (string | null)
  Currency of the crypto wallet.
- `walletNetwork` (string | null)
  Network of the crypto wallet.

## Response 401 fields

- `status` (integer)
  HTTP status code.
- `type` (string)
  Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank".
- `title` (string)
  Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
- `detail` (string)
  Human-readable explanation that is specific to this occurrence of the problem.
- `instance` (string)
  URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.

## Response 403 fields

- `status` (integer)
  HTTP status code.
- `error` (string)
  Message that describes why the request is forbidden. Most responses use a descriptive message, such as `Not allowed to change security settings`. If the organization requires multi-factor authentication (MFA) and MFA verification has not been completed for the session, this value is `mfa_required`. If MFA verification has not been completed for the session and the operation requires a confirmed session, this value is `mfa_required_for_caller`. This includes turning on `requireMfa` and resetting MFA for a user. If the organization restricts access to a list of IP addresses and the request comes from an IP address that is not in the list, this value is `ip_not_allowed`.
- `organizationId` (string)
  Unique organization identifier. An organization is an entity that represents a company. For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
  Example: org_0YVDM8RC7GDADADSBSMW124JA8
- `type` (string)
  Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank".
- `title` (string)
  Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
- `detail` (string)
  Human-readable explanation that is specific to this occurrence of the problem.
- `instance` (string)
  URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.

## Response 422 fields

- `status` (integer)
  HTTP status code.
- `type` (string)
  Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank".
- `title` (string)
  Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
- `detail` (string)
  Human-readable explanation that is specific to this occurrence of the problem.
- `instance` (string)
  URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
- `invalidFields` (array)
  Invalid field details.
  Example: [{"field":"field1","message":"field1 is invalid"},{"field":"subObject.field2","message":"field2 is invalid"},{"field":"subObject.field2","message":"another error in the field2"}]
- `invalidFields.field` (string)
  Name of the field. Dot notation is used for nested object field names.
- `invalidFields.message` (string)
  Message field.

## Response 429 fields

- `type` (string)
  Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference. It should provide human-readable documentation for the problem type. When this member is not present, its value is assumed to be "about:blank".
  Example: about:blank
- `title` (string)
  Short, human-readable summary of the problem type. Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
  Example: Rate Limit Exceeded
- `status` (integer)
  HTTP status code.
- `detail` (string)
  Human-readable explanation that is specific to this occurrence of the problem.
  Example: A request cannot be executed because the user has sent too many requests within a certain period of time
- `instance` (string)
  URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.
