/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
mid | optional | Your 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 |
environment | optional | Your 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_method | Object | Required | Contains the credit_card object and the optional fields below. |
payment_method.email | String | Optional | Cardholder email address. |
payment_method.sense_key | String | Optional | Provide the key generated by SenseJS during the checkout. |
payment_method.metadata | Object | Optional | Up to 25 key/value pairs stored with the payment method. Keys up to 50 characters, values up to 500 characters. |
payment_method.credit_card | Object | Required | Required fields for this object: |
credit_card.first_name | String | Optional | Cardholder first name. |
credit_card.last_name | String | Optional | Cardholder last name. |
credit_card.number | String | Required | Provide credit card number to tokenize. |
credit_card.verification_value (CVV) | String | Recommended | CVV: Provide this value if you have it. Leave empty if not. |
credit_card.year | String | Required | Format: YYYY |
credit_card.month | String | Required | Format: 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.token | guid | The tokenized payment method. Store this value. |
transaction.payment_method.first_six_digits | string | The 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_digits | string | The last four digits of the card number. |
transaction.payment_method.month | integer | Expiry month of the card. |
transaction.payment_method.year | integer | Expiry year of the card. |
transaction.payment_method.first_name, last_name, email | string | The values you sent; null when you did not send them. |
transaction.metadata | object | The metadata you sent. |
transaction.succeeded | boolean | true when the card was vaulted. |
success | boolean | true when errors is empty. |
result | string | Not populated on this endpoint. |
status | string | Not populated on this endpoint. |
statusCode | string | Not populated on this endpoint. It is not the HTTP status code. |
errors | array of objects | Error details; empty on success. |
customProperties | object | Additional 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
| Situation | HTTP | Body |
|---|---|---|
| The card was vaulted | 200 | transaction.payment_method.token, the FlexFactor token, and the envelope with success: true |
mid is not a GUID | 400 | Problem 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 limits | 400 | Problem details; errors maps a field name to its messages |
| Not found | 404 | Problem details |
mid is a well-formed GUID that does not match a merchant | 500 | The JSON string "Failed tokenizing a record" |
payment_method carries no credit_card, or month or year is not a number | 500 | The JSON string "Failed tokenizing a record" |
| An internal error occurred | 500 | — |
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
cardNumber | string | recommended | Use the returned transaction.payment_method.token. |
holderName | string | recommended | Use credit_card.first_name and credit_card.last_name. |
cardType | string | recommended | E.g.: Credit, Debit, Prepaid Card |
cardBrand | string | recommended | E.g.: VISA, Mastercard |
cardCountry | string | recommended | ISO 3166-1 alpha-2 country code (2-letter) |
cardIssuer | string | optional | |
cardLevel | string | optional | |
cardFingerprint | string | optional | |
expirationMonth | integer | recommended | Format: MM |
expirationYear | integer | recommended | Format: YYYY |
cardBinNumber | string | recommended | Use the returned transaction.payment_method.first_six_digits. |
cardLast4Digits | string | recommended | Use 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.
Updated 9 days ago

