---
page_source: https://docs.juspay.io/api-reference/docs/express-checkout/tokenize
page_title: Tokenize
---

## API Version: default


# Tokenize



Authentication is NOT required for this API call.

The tokenization API takes in the details of a card and generates a token representing the details of the card. This API is expected to be called from the browser or directly from Android/iOS app. Once a card is tokenized, you can initiate a payment or add the card to any customer’s account using /card/add.

A tokenized card is remembered only for 15 minutes. You have to make use of the card before its validity expires. If expired, you have to get the card input by the user again. ## Endpoints:
- Sandbox: https://sandbox.juspay.in/card/tokenize

- Production: https://api.juspay.in/card/tokenize

## Request Type: 
POST

## Headers:

#### Content-Type:
application/x-www-form-urlencoded
- Tags: String, Mandatory

#### x-merchantid:
Merchant ID provided by Juspay
- Tags: String, Mandatory

#### x-routing-id:
We recommend passing the customer_id as the x-routing-id. If the customer is checking out as a guest, you can pass an alternative ID that helps track the payment session lifecycle. For example, this could be an Order ID or Cart ID.

> **Warning**
> This ID is associated with the customer. It plays a key role in ensuring consistency and maintaining connections across different systems. If you fail to pass the same x-routing-id for the same customer in all related API calls, it could lead to issues with API functionality. Therefore, it’s crucial that you use the same x-routing-id for all requests tied to the same customer.


- Value: customer_1122
- Tags: String, Required
## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl https://api.juspay.in/card/tokenize \
    -H 'x-routing-id: customer_1122'\
    -d "card_number=4111111111111111" \
    -d "card_exp_year=2015" \
    -d "card_exp_month=07" \
    -d "card_security_code=123" \
    -d "merchant_id=myshop" \
    -d "name_on_card=123"

```

### Sample Response:

#### 200 - Response:
```json
{
  "token": "ctkn_qvfiry6hreobblus"
}
```

#### 400 - Response - Invalid Card Expiry Month:
```plaintext
{
    "error_message": "Card expiry month should be between 1 and 12",
    "status": "error",
    "error_code": "invalidRange",
    "error_info": {
        "category": "USER_ERROR",
        "code": "INVALID_INPUT",
        "developer_message": "Invalid card expiry month.",
        "fields": [
            {
                "field_name": "card_exp_month",
                "reason": "Invalid value."
            }
        ],
        "href": "NA",
        "request_id": "59a880c5-1ae3-4ea5-9149-87e706c20799",
        "user_message": "Invalid card expiry month."
    }
}

```

#### 400 - Response - Invalid Card Expiry Year:
```plaintext
{
    "error_message": "Invalid card expiry year",
    "status": "error",
    "error_code": "invalid",
    "error_info": {
        "category": "USER_ERROR",
        "code": "INVALID_INPUT",
        "developer_message": "Invalid card expiry year.",
        "fields": [
            {
                "field_name": "card_exp_year",
                "reason": "Invalid value."
            }
        ],
        "href": "NA",
        "request_id": "bb2059af-4925-460f-b15c-345baa6bc137",
        "user_message": "Invalid card expiry year."
    }
}

```

#### 400 - Response - Missing Mandatory Parameter:
```plaintext
{
    "error_message": "Card security code should be present.",
    "status": "error",
    "error_code": "nullable",
    "error_info": {
        "category": "USER_ERROR",
        "code": "INVALID_INPUT",
        "developer_message": "Card security code is required.",
        "fields": [
            {
                "field_name": "card_security_code",
                "reason": "Missing value."
            }
        ],
        "href": "NA",
        "request_id": "c7e4ac85-bffc-485b-b0c0-431ca1ed1ee5",
        "user_message": "Missing cvv."
    }
}

```

## Body Parameters:
### Parameters:

#### merchant_id:
- Description: Merchant ID which represents the merchant storing the card
- Tags: string, Required

#### card_number:
- Description: A valid card number
- Tags: string, Required

#### card_exp_year:
- Description: Expiry year of the card (Format: yyyy) Example: 2020
- Tags: string, Required

#### card_exp_month:
- Description: Expiry month of the card (Format: mm) Example: 06
- Tags: string, Required

#### card_security_code:
- Description: The CVV number of the card.
- Tags: string, Required

#### name_on_card:
- Description: Cardholder name
- Tags: string

#### stored_card_token:
- Description: The card_token received in the response of list stored cards. Required for tokenising the saved card.
- Tags: string
## API Responses:
### 200:

#### token:
- Description: ctkn_qvfiry6hreobblus
- Tags: string
