---
page_title: Process OTP
product: API Reference
page_source: https://juspay.io/in/docs/api-reference/docs/direct-otp/process-otp
openapi: https://juspay.io/in/docs/api/swagger?document=https%3A%2F%2Fjuspay.io%2Fin%2Fdocs%2Fapi-reference%2Fdocs%2Fdirect-otp%2Fprocess-otp
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/api-reference/llms.txt
---

## API Version: default


# Process OTP



This will complete the authentication and authorization. It takes OTP as input and returns the transaction response.

> **Note**
> `id` path parameter is the unique id generated for the transaction in a generate OTP API call.

## Endpoints:
- Sandbox: https://sandbox.juspay.in/v2/txns/{id}/authenticate

- Production: https://api.juspay.in/v2/txns/{id}/authenticate

## Request Type: 
POST

## Content-Type: 
application/json

## Authorization:

#### Basic Auth:
Consists of two parts.

* Username: API Key obtained from Juspay dashboard
* Password: Empty string

Example:- Basic MUQ2QUxxxxxxxxxxxxU5QTIxQzNFNTQwNkFDMEZCOg==
- Tags: Base64 Encoded Username:Password, Mandatory
## Headers:

#### Content-Type:
application/x-www-form-urlencoded
- 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 -X POST https://api.juspay.in/v2/txns/:id/authenticate \
-u your_api_key: \
-H 'x-routing-id: customer_1122'\
-d "challenge_id=ch_xyz" \
-d "answer.otp=123456"

```

### Sample Response:

#### Response - 200:
```json
{
  "id": "txn_035b4e708d5148478828ea3136a9efd7",
  "order_id": ":order_id",
  "txn_id": ":txn_id",
  "status": "CHARGED",
  "gateway": "RAZORPAY",
  "created": "2017-05-05T12:12:08Z",
  "resp_code": "00",
  "resp_message": "",
  "payment_info": {
    "payment_method_type": "CARD",
    "payment_method": "VISA",
    "card": {
    "last_four_digits": "",
    "card_isin": "400020",
    "expiry_month": "09",
    "expiry_year": "2020",
    "name_on_card": "",
    "card_type": "",
    "card_issuer": "",
    "card_brand": "VISA",
    "card_reference": "",
    "card_fingerprint": "37sug6sns7p8ubota3md74va3u",
    "using_saved_card": false,
    "saved_to_locker": false
    }
  },"payment"  : {
    "authentication": {
    "method": "POST",
    "url": "https://api.juspay.in/v2/txns/:id/authenticate",
    "params": {
            "id"                    : "8646a7a0xxxxxxxxxx95fec00340a507",
            "challenge_id"          : "ch_xyz",
            "auth_type"         : "OTP",
            "card_isin"             : "424242",
            "card_issuer_bank_name" : "AXIS BANK LTD",
            "submit_otp_allowed"    : true,
            "resend_otp_allowed"    : false,
            "fallback_url"          : "https://api.juspay.in/v2/pay/start/guest/eul5g88xxxxxswrHYMh"

    }
    }
   },
  "payment_gateway_response": {
    "created": "2017-05-05T12:12:42Z",
    "txn_id": ":txn_id",
    "rrn": "",
    "epg_txn_id": ":epg_txn_id",
    "auth_id_code": "",
    "resp_code": "00",
    "resp_message": "",
    "gateway_response_map": {
    //gateway dependent response parameters
    }
  },
  "refunds":[ ]
}
```

#### 200 - OTP fails:
```plaintext
{
  "id": "txn_035b4e708d5148478828ea3136a9efd7",
  "order_id": ":order_id",
  "txn_id": ":txn_id",
  "status": "AUTHORIZATION_FAILED",
  "gateway": "RAZORPAY",
  "created": "2017-05-05T12:12:08Z",
  "resp_code": "00",
  "resp_message": "",
  "payment"  : {
    "authentication": {
    "method": "POST",
    "url": "https://api.juspay.in/v2/txns/:id/authenticate",
    "params": {
            "id"                    : "8646a7a02997xxxxx995fec00340a507",
            "challenge_id"          : "ch_xyz",
            "auth_type"         : "OTP",
            "card_isin"             : "424242",
            "card_issuer_bank_name" : "AXIS BANK LTD",
            "submit_otp_allowed"    : true,
            "resend_otp_allowed"    : false,
            "fallback_url"          : "https://api.juspay.in/v2/pay/start/guest/eul5g88xxxxxswrHYMh"

    }
    }
   },
  "payment_info": {
    "payment_method_type": "CARD",
    "payment_method": "VISA",
    "card": {
    "last_four_digits": "",
    "card_isin": "400020",
    "expiry_month": "09",
    "expiry_year": "2020",
    "name_on_card": "",
    "card_type": "",
    "card_issuer": "",
    "card_brand": "VISA",
    "card_reference": "",
    "card_fingerprint": "37sug6snsxxxxxota3md74va3u",
    "using_saved_card": false,
    "saved_to_locker": false
    }
  },
  "payment_gateway_response": {
    "created": "2017-05-05T12:12:42Z",
    "txn_id": ":txn_id",
    "rrn": "",
    "epg_txn_id": ":epg_txn_id",
    "auth_id_code": "",
    "resp_code": "00",
    "resp_message": "",
    "gateway_response_map": {
    //gateway dependent response parameters
    }
  },
  "refunds":[ ]
}
```

## Path Parameters:

#### id:
Transaction Id
- Value: Example:- txn_035b4e708d5148478828ea3136a9efd7
- Tags: String, Mandatory
## Body Parameters:
### Basic Parameters:

#### challenge_id:
- Description: Challenge id generated against the transaction in generating OTP API call.
- Value: value
- Tags: String, Mandatory

#### answer.otp:
- Description: OTP to be sent for authenticating the transaction.
- Tags: String, Mandatory

#### auto_capture:
- Description: Optional parameter. Send false if you want to capture at a later stage. The default is true.
- Tags: String
## API Responses:
### 200:

#### id:
- Description: Unique id generated for the transaction.
- Tags: String

#### order_id:
- Description: Order Id provided by you while order creation.
- Tags: String

#### txn_id:
- Description: Transaction id for a given order.
- Tags: String

#### status:
- Description: Status of the transaction. If you receive ���CHARGED”, then the transaction is successful. “AUTHORIZED” in case if auto_capture is false.
- Tags: String

#### gateway:
- Description: Gateway through which authorization process was performed.
- Tags: String

#### created:
- Description: Creation date of transaction.
- Tags: String

#### resp_code:
- Description: Gateway response code for the transaction.
- Tags: String

#### resp_message:
- Description: Error message from the gateway in case if the transaction failed.
- Tags: String

#### payment_info:
- Description: This contains the payment details provided during the transaction.
- Tags: object

#### payment_gateway_response:
- Description: This will give the payment response received from the gateway.
- Tags: object

#### refunds:
- Description: List of refunds attempted for a given transaction.
- Tags: Array
### 400:

#### status:
- Description: invalid_request_error
- Tags: String

#### error_code:
- Description: invalid
- Tags: String

#### error_message:
- Description: Invalid authentication account id
- Tags: String
### 401:

#### status:
- Description: error
- Tags: String

#### error_code:
- Description: access_denied
- Tags: String

#### error_message:
- Description: Invalid Authentication
- Tags: String


---

## See Also

- [Start Authentication](https://juspay.io/in/docs/api-reference/docs/direct-otp/start-authentication)
- [Resend OTP](https://juspay.io/in/docs/api-reference/docs/direct-otp/resend-otp)
