# Create a new token

Creating a new token for the payment instrument.

Endpoint: POST /tokens
Version: 3
Security: BasicAuth

## Request fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `description` (string)
    A description of your token. If not supplied, a default description is created for you.

  - `tokenExpiryDateTime` (string)
    The date/time after which the token is unavailable, expressed in ISO 8601 format. If not supplied, the default expiry date/time is 90 days in Try and 4 years in the Live environment.We extend the expiry in Live by 4 years, if under half of the time remains on the token.

  - `namespace` (string)
    A reference to group up to 16 cards, e.g. for one customer. A card can exist in more than one namespace. If supplied, must not start with an underscore, must not contain spaces, '&' or '<'

  - `schemeTransactionReference` (string)
    A value provided by Visa or Mastercard which tracks recurring transactions.Note: You are not normally expected to provide a value for schemeTransactionReference. If you are using the [Verified Tokens API](/products/verified-tokens/@v3/index.md) to create tokens, it is automatically included where applicable.

  - `paymentInstrument` (object, required)
    An object that contains the payment type and details. All sub-fields are mandatory with the exception of billingAddress (see below).

  - `paymentInstrument.type` (string)
    card/front

  - `paymentInstrument.cardHolderName` (string)
    The name on your customer's card.

  - `paymentInstrument.cardExpiryDate` (object)

  - `paymentInstrument.cardExpiryDate.month` (integer, required)

  - `paymentInstrument.cardExpiryDate.year` (integer, required)

  - `paymentInstrument.cardNumber` (string)
    Contains your customer's card number.

  - `paymentInstrument.billingAddress` (object)
    Contains the billing address information.

  - `paymentInstrument.billingAddress.address1` (string, required)

  - `paymentInstrument.billingAddress.postalCode` (string, required)

  - `paymentInstrument.billingAddress.city` (string, required)

  - `paymentInstrument.billingAddress.countryCode` (string, required)

  - `paymentInstrument.billingAddress.address2` (string)

  - `paymentInstrument.billingAddress.address3` (string)

  - `paymentInstrument.billingAddress.state` (string)

  - `merchant` (object, required)
    An object that contains information about your merchant account.

  - `merchant.entity` (string, required)
    Identifies merchant account for billing, reporting and reconciliation. Contact your Implementation Manager for more details.

## Response 200 fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `tokenPaymentInstrument` (object, required)

  - `tokenPaymentInstrument.type` (string)
    Indicating the type of this token.

  - `tokenPaymentInstrument.href` (string)
    Link to the corresponding token.

  - `description` (string, required)
    A description of your token. If not supplied, a default description is created for you.

  - `tokenExpiryDateTime` (string, required)
    The date/time after which the token is unavailable, expressed in ISO 8601 format. If not supplied, the default expiry date/time is 90 days in Try and 4 years in the Live environment.We extend the expiry in Live by 4 years, if under half of the time remains on the token.

  - `paymentInstrument` (object, required)

  - `paymentInstrument.cardNumber` (string, required)

  - `paymentInstrument.cardExpiryDate` (object, required)

  - `paymentInstrument.cardExpiryDate.month` (integer, required)

  - `paymentInstrument.cardExpiryDate.year` (integer, required)

  - `paymentInstrument.type` (string)

  - `paymentInstrument.cardHolderName` (string)
    The name on your customer's card.

  - `paymentInstrument.bin` (string)

  - `paymentInstrument.brand` (string)

  - `paymentInstrument.fundingType` (string)

  - `paymentInstrument.countryCode` (string)

  - `paymentInstrument.billingAddress` (object)

  - `paymentInstrument.billingAddress.address1` (string, required)

  - `paymentInstrument.billingAddress.postalCode` (string, required)

  - `paymentInstrument.billingAddress.city` (string, required)

  - `paymentInstrument.billingAddress.countryCode` (string, required)

  - `paymentInstrument.billingAddress.address2` (string)

  - `paymentInstrument.billingAddress.address3` (string)

  - `paymentInstrument.billingAddress.state` (string)

  - `paymentInstrument.networkType` (string)

  - `paymentInstrument.last4Digits` (string)

  - `tokenId` (string)
    Worldpay's internal identifier for a token. If supplied, must be between 15 and 21 characters, must consist of digits and upper-case characters excluding 'I' and 'O'.

  - `namespace` (string)
    A reference to group up to 16 cards, e.g. for one customer.

  - `schemeTransactionReference` (string)
    A value provided by Visa or Mastercard which tracks recurring transactions.Note: You are not normally expected to provide a value for schemeTransactionReference. If you are using the [Verified Tokens API](/products/verified-tokens/@v3/index.md) to create tokens, it is automatically included where applicable.

  - `_links` (object, required)

## Response 201 fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `tokenPaymentInstrument` (object, required)

  - `tokenPaymentInstrument.type` (string)
    Indicating the type of this token.

  - `tokenPaymentInstrument.href` (string)
    Link to the corresponding token.

  - `description` (string, required)
    A description of your token. If not supplied, a default description is created for you.

  - `tokenExpiryDateTime` (string, required)
    The date/time after which the token is unavailable, expressed in ISO 8601 format. If not supplied, the default expiry date/time is 90 days in Try and 4 years in the Live environment.We extend the expiry in Live by 4 years, if under half of the time remains on the token.

  - `paymentInstrument` (object, required)

  - `paymentInstrument.cardNumber` (string, required)

  - `paymentInstrument.cardExpiryDate` (object, required)

  - `paymentInstrument.cardExpiryDate.month` (integer, required)

  - `paymentInstrument.cardExpiryDate.year` (integer, required)

  - `paymentInstrument.type` (string)

  - `paymentInstrument.cardHolderName` (string)
    The name on your customer's card.

  - `paymentInstrument.bin` (string)

  - `paymentInstrument.brand` (string)

  - `paymentInstrument.fundingType` (string)

  - `paymentInstrument.countryCode` (string)

  - `paymentInstrument.billingAddress` (object)

  - `paymentInstrument.billingAddress.address1` (string, required)

  - `paymentInstrument.billingAddress.postalCode` (string, required)

  - `paymentInstrument.billingAddress.city` (string, required)

  - `paymentInstrument.billingAddress.countryCode` (string, required)

  - `paymentInstrument.billingAddress.address2` (string)

  - `paymentInstrument.billingAddress.address3` (string)

  - `paymentInstrument.billingAddress.state` (string)

  - `paymentInstrument.networkType` (string)

  - `paymentInstrument.last4Digits` (string)

  - `tokenId` (string)
    Worldpay's internal identifier for a token. If supplied, must be between 15 and 21 characters, must consist of digits and upper-case characters excluding 'I' and 'O'.

  - `namespace` (string)
    A reference to group up to 16 cards, e.g. for one customer. A card can exist in more than one namespace.

  - `schemeTransactionReference` (string)
    A value provided by Visa or Mastercard which tracks recurring transactions.Note: You are not normally expected to provide a value for schemeTransactionReference. If you are using the [Verified Tokens API](/products/verified-tokens/@v3/index.md) to create tokens, it is automatically included where applicable.

  - `_links` (object, required)

## Response 400 fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `errorName` (string)
    Example: "bodyDoesNotMatchSchema"

  - `message` (string)
    Example: "The json body provided does not match the expected schema"

  - `validationErrors` (array)
    Further error details

  - `validationErrors.errorName` (string)
    Example: "fieldHasInvalidValue"

  - `validationErrors.message` (string)
    Example: "Card expiry month too small - must be between 1 & 12"

  - `validationErrors.jsonPath` (string)
    Example: "$.paymentInstrument.cardExpiryDate.month"

## Response 403 fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `errorName` (string)
    Example: "tooManyTokensForNamespace"

  - `message` (string)
    Example: "Too many tokens created for this namespace"

## Response 409 fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `tokenPaymentInstrument` (object, required)

  - `tokenPaymentInstrument.type` (string)
    Indicating the type of this token.

  - `tokenPaymentInstrument.href` (string)
    Link to the corresponding token.

  - `description` (string, required)
    A description of your token. If not supplied, a default description is created for you.

  - `tokenExpiryDateTime` (string, required)
    The date/time after which the token is unavailable, expressed in ISO 8601 format. If not supplied, the default expiry date/time is 90 days in Try and 4 years in the Live environment.We extend the expiry in Live by 4 years, if under half of the time remains on the token.

  - `paymentInstrument` (object, required)

  - `paymentInstrument.cardNumber` (string, required)

  - `paymentInstrument.cardExpiryDate` (object, required)

  - `paymentInstrument.cardExpiryDate.month` (integer, required)

  - `paymentInstrument.cardExpiryDate.year` (integer, required)

  - `paymentInstrument.type` (string)

  - `paymentInstrument.cardHolderName` (string)
    The name on your customer's card.

  - `paymentInstrument.bin` (string)

  - `paymentInstrument.brand` (string)

  - `paymentInstrument.fundingType` (string)

  - `paymentInstrument.countryCode` (string)

  - `paymentInstrument.billingAddress` (object)

  - `paymentInstrument.billingAddress.address1` (string, required)

  - `paymentInstrument.billingAddress.postalCode` (string, required)

  - `paymentInstrument.billingAddress.city` (string, required)

  - `paymentInstrument.billingAddress.countryCode` (string, required)

  - `paymentInstrument.billingAddress.address2` (string)

  - `paymentInstrument.billingAddress.address3` (string)

  - `paymentInstrument.billingAddress.state` (string)

  - `paymentInstrument.networkType` (string)

  - `paymentInstrument.last4Digits` (string)

  - `tokenId` (string)
    Worldpay's internal identifier for a token. If supplied, must be between 15 and 21 characters, must consist of digits and upper-case characters excluding 'I' and 'O'.

  - `namespace` (string)
    A reference to group up to 16 cards, e.g. for one customer. A card can exist in more than one namespace.

  - `schemeTransactionReference` (string)
    A value provided by Visa or Mastercard which tracks recurring transactions.Note: You are not normally expected to provide a value for schemeTransactionReference. If you are using the [Verified Tokens API](/products/verified-tokens/@v3/index.md) to create tokens, it is automatically included where applicable.

  - `conflicts` (object)

  - `conflicts.conflictsExpiryDateTime` (string)

  - `conflicts.paymentInstrument` (object)

  - `conflicts.paymentInstrument.cardHolderName` (string)

  - `conflicts.paymentInstrument.cardExpiryDate` (object)

  - `conflicts.paymentInstrument.cardExpiryDate.month` (integer)

  - `conflicts.paymentInstrument.cardExpiryDate.year` (integer)

  - `conflicts.paymentInstrument.billingAddress` (object)

  - `conflicts.paymentInstrument.billingAddress.address1` (string)

  - `conflicts.paymentInstrument.billingAddress.postalCode` (string)

  - `conflicts.paymentInstrument.billingAddress.city` (string)

  - `conflicts.paymentInstrument.billingAddress.countryCode` (string)

  - `conflicts.paymentInstrument.billingAddress.address2` (string)

  - `conflicts.paymentInstrument.billingAddress.address3` (string)

  - `conflicts.paymentInstrument.billingAddress.state` (string)

  - `conflicts.schemeTransactionReference` (string)

  - `_links` (object, required)

## Response 422 fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `errorName` (string)
    Example: "unrecognizedCardBrand"

  - `message` (string)
    Example: "The card brand is not recognized"

## Response 500 fields (application/vnd.worldpay.tokens-v3.hal+json):

  - `errorName` (string)
    Example: "tokenizationNotEnabled"

  - `message` (string)
    Example: "Tokenization not enabled"


