/tokenize

Add POST /tokenize to your checkout flow, and store the FlexFactor token for later use.


The /tokenize endpoint is designed to securely vault credit card information after every checkout. A tokenized representation of the card information is returned.

Store that token for later use in case of payment decline.

You can send that request in parallel to the Payment Authorization request. If you are already tokenizing with a partner, you can tokenize twice.



1. Request

Query parameters

midoptionalYour FlexFactor Merchant Identification Number, as a GUID. If you omit it, the card is tokenized without a merchant association. A value that is not a GUID returns HTTP 400; a well-formed GUID that does not match a merchant returns HTTP 500.
Get your Mid
environmentoptionalYour unique Tokenization key.
Get your key.

The schema does not enforce these parameters.

Log into into your Sandbox. Go to section Developers > Tokenization get both your Tokenization endpoint and Environment.


Body parameters

Field names in the request body are snake_case. A body that uses other names, for example paymentMethod in place of payment_method, returns HTTP 400 with the message The PaymentMethod field is required.

payment_methodObjectRequiredContains the credit_card object and the optional fields below.
payment_method.emailStringOptionalCardholder email address.
payment_method.sense_keyStringOptionalProvide the key generated by SenseJS during the checkout.
payment_method.metadataObjectOptionalUp to 25 key/value pairs stored with the payment method. Keys up to 50 characters, values up to 500 characters.
payment_method.credit_cardObjectRequiredRequired fields for this object:
credit_card.first_nameStringOptionalCardholder first name.
credit_card.last_nameStringOptionalCardholder last name.
credit_card.numberStringRequiredProvide credit card number to tokenize.
credit_card.verification_value (CVV)StringRecommendedCVV: Provide this value if you have it. Leave empty if not.
credit_card.yearStringRequiredFormat: YYYY
credit_card.monthStringRequiredFormat: MM
❗️

Real financial data cannot be used in the Sandbox.
Please use our whitelisted test credit cards.


Request example

curl --location -g --request POST '
  https://api-sandbox.flexfactor.io/v1/tokenize?mid={Your mid}&environment={Your Tokenization Key}' \
--header 'Content-Type: application/json' \
--data-raw '{
  "payment_method": {
    	"sense_key": "XXX", //provide the key generated by SenseJS during the checkout
      "email": "[email protected]",
    	"credit_card": {
        "first_name": "Joe",
        "last_name": "Jones",
        "number": "4111111111111111",
        "verification_value": "999", //That's the CVV
        "month": "03", // provide 2 numbers
        "year": "2029" // provide 4 numbers
      },
      "metadata": {
        "customerId": "cust_123"
      }
  }
}'

2. Response

The response returns the vaulted card in transaction.payment_method, followed by the common FlexFactor envelope fields. The token is transaction.payment_method.token.

transaction.payment_method.tokenguidThe tokenized payment method. Store this value.
transaction.payment_method.first_six_digitsstringThe leading digits of the card number (the BIN). Despite the name, the value can hold eight digits, for example 41111111.
transaction.payment_method.last_four_digitsstringThe last four digits of the card number.
transaction.payment_method.monthintegerExpiry month of the card.
transaction.payment_method.yearintegerExpiry year of the card.
transaction.payment_method.first_name, last_name, emailstringThe values you sent; null when you did not send them.
transaction.metadataobjectThe metadata you sent.
transaction.succeededbooleantrue when the card was vaulted.
successbooleantrue when errors is empty.
resultstringNot populated on this endpoint.
statusstringNot populated on this endpoint.
statusCodestringNot populated on this endpoint. It is not the HTTP status code.
errorsarray of objectsError details; empty on success.
customPropertiesobjectAdditional properties. Optional

The transaction and payment_method objects carry more fields than the table lists. They are null on a tokenization, and the example leaves them out.

{
  "transaction": {
    "on_test_gateway": true,
    "created_at": "2026-11-23T21:52:33.6141632Z",
    "updated_at": "2026-11-23T21:52:33.6141633Z",
    "succeeded": true,
    "payment_method": {
      "token": "baf4abdc-14a3-4458-abfb-c856c711b9c7", //this is the tokenized payment method
      "created_at": "2026-11-23T21:52:33.6141639Z",
      "updated_at": "2026-11-23T21:52:33.6141639Z",
      "email": "[email protected]",
      "test": false,
      "last_four_digits": "1111",
      "first_six_digits": "41111111",
      "first_name": "Joe",
      "last_name": "Jones",
      "month": 3,
      "year": 2029
    },
    "metadata": {
      "customerId": "cust_123"
    }
  },
  "cardBinInfo": null,
  "success": true,
  "result": null,
  "status": null,
  "statusCode": null,
  "errors": [],
  "customProperties": {}
}

HTTP status codes

SituationHTTPBody
The card was vaulted200transaction.payment_method.token, the FlexFactor token, and the envelope with success: true
mid is not a GUID400Problem details
The body failed validation: payment_method, number, month, or year is missing, the card number is not a test card (sandbox only), or metadata exceeds its limits400Problem details; errors maps a field name to its messages
Not found404Problem details
mid is a well-formed GUID that does not match a merchant500The JSON string "Failed tokenizing a record"
payment_method carries no credit_card, or month or year is not a number500The JSON string "Failed tokenizing a record"
An internal error occurred500—

For the error key and the message of each 400 on this endpoint, see Error Messages: /tokenize.


3. Token storage

The returned token must be stored in your database for future use, you will need it in case of payment decline.

A payment decline can happen immediately after tokenization (in case of CIT) of a few months after tokenization (in case of MIT).

❕

This vaulted token will not expire.

Store transaction.payment_method.token alongside the card details below.

paymentMethod information

cardNumberstringrecommendedUse the returned transaction.payment_method.token.
holderNamestringrecommendedUse credit_card.first_name and credit_card.last_name.
cardTypestringrecommendedE.g.: Credit, Debit, Prepaid Card
cardBrandstringrecommendedE.g.: VISA, Mastercard
cardCountrystringrecommendedISO 3166-1 alpha-2 country code (2-letter)
cardIssuerstringoptional
cardLevelstringoptional
cardFingerprintstringoptional
expirationMonthintegerrecommendedFormat: MM
expirationYearintegerrecommendedFormat: YYYY
cardBinNumberstringrecommendedUse the returned transaction.payment_method.first_six_digits.
cardLast4DigitsstringrecommendedUse the returned transaction.payment_method.last_four_digits.

4. Retrieve that token for /evaluate

On a payment decline, you will need to look up the paymentMethod information and include it in your call to /evaluate.


What’s Next

Retrieve that payment method token and use it in /evaluate

Did this page help you?