---
page_title: Pre Auth API
product: API Reference
page_source: https://juspay.io/in/docs/api-reference/docs/preauth-and-capture/pre-auth-api
openapi: https://juspay.io/in/docs/api/swagger?document=https%3A%2F%2Fjuspay.io%2Fin%2Fdocs%2Fapi-reference%2Fdocs%2Fpreauth-and-capture%2Fpre-auth-api
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/api-reference/llms.txt
---

## API Version: default


# Pre Auth Order+Payment API



This API supports parameters from both the **Create Order API**  and the **Payments API** .

> **Note**
> Only If you are a **PCI-compliant merchant** , you can integrate with this API.

## Endpoints:
- Sandbox: https://sandbox.juspay.in/txns

- Production: https://api.juspay.in/txns

## Request Type: 
POST

## Content-Type: 
application/json

## Authorization:

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

* Username: API Key obtained from Juspay dashboard
* Password: Empty string
- Value:  Example:- Basic MUQ2QUxxxxxxxxxxxxU5QTIxQzNFNTQwNkFDMEZCOg==
- Tags: Base64 Encoded Username:Password, Required
## Headers:

#### x-merchantid:
Merchant ID provided by Juspay

Example:-merchant-id
- Tags: String, Required

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

#### 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:
### Code Snippets:

#### New Card Transaction Code Snippet:

```new card transaction
curl --location 'https://api.juspay.in/txns' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-routing-id: customer_1122'\
--header 'Authorization: Basic Auth of <your-api-key>' \
--data-urlencode 'order.order_id=ord_1590759422' \
--data-urlencode 'order.amount=101550.00' \
--data-urlencode 'order.currency=INR' \
--data-urlencode 'order.customer_id=cst_1590759422' \
--data-urlencode 'order.return_url=https://merchant.in/payments' \
--data-urlencode 'merchant_id=<your-merchant-id>' \
--data-urlencode 'payment_method_type=CARD' \
--data-urlencode 'payment_method=VISA' \
--data-urlencode 'card_number=4242424242424242' \
--data-urlencode 'card_exp_month=10' \
--data-urlencode 'card_exp_year=25' \
--data-urlencode 'name_on_card=Name' \
--data-urlencode 'card_security_code=111' \
--data-urlencode 'save_to_locker=true' \
--data-urlencode 'redirect_after_payment=true' \
--data-urlencode 'order.customer_email=customer@gmail.com' \
--data-urlencode 'order.customer_phone=9988665522' \
--data-urlencode 'order.product_id=prod-141833' \
--data-urlencode 'order.description=Sample description' \
--data-urlencode 'order.billing_address_first_name=Juspay' \
--data-urlencode 'order.billing_address_last_name=Technologies' \
--data-urlencode 'order.billing_address_line1=Girija Building' \
--data-urlencode 'order.billing_address_line2=Ganapathi Temple Road' \
--data-urlencode 'order.billing_address_line3=8th Block, Koramangala' \
--data-urlencode 'order.billing_address_city=Bengaluru' \
--data-urlencode 'order.billing_address_state=Karnataka' \
--data-urlencode 'order.billing_address_country=India' \
--data-urlencode 'order.billing_address_postal_code=560095' \
--data-urlencode 'order.billing_address_phone=9988775566' \
--data-urlencode 'order.billing_address_country_code_iso=IND' \
--data-urlencode 'order.shipping_address_first_name=Juspay' \
--data-urlencode 'order.shipping_address_last_name=Technologies' \
--data-urlencode 'order.shipping_address_line1=Girija Building' \
--data-urlencode 'order.shipping_address_line2=Ganapathi Temple Road' \
--data-urlencode 'order.shipping_address_line3=8th Block, Koramangala' \
--data-urlencode 'order.shipping_address_city=Bengaluru' \
--data-urlencode 'order.shipping_address_state=Karnataka' \
--data-urlencode 'order.shipping_address_postal_code=560095' \
--data-urlencode 'order.shipping_address_phone=9962881912' \
--data-urlencode 'order.shipping_address_country_code_iso=IND' \
--data-urlencode 'order.shipping_address_country=India' \
--data-urlencode 'order.metadata.txns.auto_capture=false'
--data-urlencode 'format=json'
```

#### Saved Card Transaction Code Snippet:

```saved card transaction
curl --location 'https://api.juspay.in/txns' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-routing-id: customer_1122'\
--header 'Authorization: Basic Auth of <your-api-key>' \
--data-urlencode 'order.order_id=ord_1590759422' \
--data-urlencode 'order.amount=101550.00' \
--data-urlencode 'order.currency=INR' \
--data-urlencode 'order.customer_id=cst_1590759422' \
--data-urlencode 'order.return_url=https://merchant.in/payments' \
--data-urlencode 'merchant_id=<your-merchant-id>' \
--data-urlencode 'payment_method_type=CARD' \
--data-urlencode 'payment_method=VISA' \
--data-urlencode "card_token=:card_token" \
--data-urlencode "card_security_code=111" \ #optional field for CVV less supported transactions
--data-urlencode 'redirect_after_payment=true' \
--data-urlencode 'order.customer_email=customer@gmail.com' \
--data-urlencode 'order.customer_phone=9988665522' \
--data-urlencode 'order.product_id=prod-141833' \
--data-urlencode 'order.description=Sample description' \
--data-urlencode 'order.billing_address_first_name=Juspay' \
--data-urlencode 'order.billing_address_last_name=Technologies' \
--data-urlencode 'order.billing_address_line1=Girija Building' \
--data-urlencode 'order.billing_address_line2=Ganapathi Temple Road' \
--data-urlencode 'order.billing_address_line3=8th Block, Koramangala' \
--data-urlencode 'order.billing_address_city=Bengaluru' \
--data-urlencode 'order.billing_address_state=Karnataka' \
--data-urlencode 'order.billing_address_country=India' \
--data-urlencode 'order.billing_address_postal_code=560095' \
--data-urlencode 'order.billing_address_phone=9988775566' \
--data-urlencode 'order.billing_address_country_code_iso=IND' \
--data-urlencode 'order.shipping_address_first_name=Juspay' \
--data-urlencode 'order.shipping_address_last_name=Technologies' \
--data-urlencode 'order.shipping_address_line1=Girija Building' \
--data-urlencode 'order.shipping_address_line2=Ganapathi Temple Road' \
--data-urlencode 'order.shipping_address_line3=8th Block, Koramangala' \
--data-urlencode 'order.shipping_address_city=Bengaluru' \
--data-urlencode 'order.shipping_address_state=Karnataka' \
--data-urlencode 'order.shipping_address_postal_code=560095' \
--data-urlencode 'order.shipping_address_phone=9962881912' \
--data-urlencode 'order.shipping_address_country_code_iso=IND' \
--data-urlencode 'order.shipping_address_country=India' \
--data-urlencode 'order.metadata.txns.auto_capture=false'
--data-urlencode 'format=json'

```

### Sample Request and Response:

#### 200 Response - New Card:
```json
{
  "order_id": "ord_1590759422",
  "status": "PENDING_VBV",
  "payment": {
    "authentication": {
      "url": "https://api.juspay.in/v2/pay/start/MID/moz3BDvrJSbBzuqFiw1?cardIssuerBankName%3DAxisBank%26cardType%3DDEBIT%26paymentMethod%3DVISA%26paymentMethodType%3DCARD",
      "method": "GET"
    }
  },
  "txn_uuid": "moz3BDvrJSbBzuqFiw1",
  "offer_details": {
    "offers": []
  },
  "txn_id": "MID-ord_1590759422-1"
}

```

#### 200 Response - Saved Cards:
```plaintext
{
   "payment": {
       "authentication": {
           "method": "GET",
           "url": "https://sandbox.in/in/v2/pay/start/tesIN/moziZi5LcUMYcuq2cje?cardIssuerBankName%3D%26cardType%3DCREDIT%26paymentMethod%3DVISA%26paymentMethodType%3DCARD"
       }
   },
   "status": "PENDING_VBV",
   "txn_uuid": "moziZi5LcUMYcuq2cje",
   "juspay": {
       "client_auth_token": "tkn_414e4c2cb80",
       "client_auth_token_expiry": "2025-07-24T07:22:48Z"
   },
   "offer_details": {
       "offers": []
   },
   "order_id": "1753340868",
   "txn_id": "testHSBCIN-1753340868-1"
}

```

## Body Parameters:
### Basic Parameters:

#### order.order_id:
- Description: Unique Identifier for the order. Should be Alphanumeric with character length less than 21.

Example:-order-id-9876580
- Value: value
- Tags: String, Required

#### order.amount:
- Description: Amount that the customer has to pay. Will accept stringified double or integer values with upto two decimal places. For example, "100.15" and "100" are valid input but "100.1532" is not valid.
- Tags: Double, Required

#### order.customer_id:
- Description: It is the ID with which merchant refers to a customer object. This id is used to access the stored payment methods, allow EMI transactions and setup subscriptions.In case of guest login it should be an empty string.

Example:-customer-id-007
- Tags: String

#### order.customer_email:
- Description: Email address of the customer. If the backend gateway requires it, then you must send this value.

Example:-[test@gmail.com](mailto:test@gmail.com)
- Tags: String

#### order.customer_phone:
- Description: Mobile number or fixed line number of the customer. If the backend gateway requires it, then you must send this value.

Example:-

9999999912
- Tags: String

#### order.currency:
- Description: ISO string of the currency. Use INR for Indian Rupee. Among other accepted values are EUR, USD, GBP. Default value: INR
- Tags: String

#### order.return_url:
- Description: A fully qualified URL which the customer will be redirected after payment completion. It is also required to provide the control back to SDK after the completion of transaction. This URL shouldn't contain any query parameters or Ip address. This URL takes higher precedence over the common return URL configured in your account settings.

Example:-[https://shop.merchant.com](https://shop.merchant.com)
- Tags: String

#### merchant_id:
- Description: ID of the merchant_account that you hold with us.
- Tags: String, Required

#### payment_method_type:
- Description: Depending on type of payment to be processed.
- Value:  CARD, NB, UPI
- Tags: String, Required

#### payment_method:
- Description: One of VISA/MASTERCARD/MAESTRO/AMEX/RUPAY. This is usually inferred from the card number itself and we will take care of this if you are unable to provide this from your end.
- Tags: String

#### card_token:
- Description: A valid card token obtained using /card/list API. If you send this parameter, then card_number, name_on_card, card_exp_year, card_exp_month fields are not required. If the token is generated using the /card/tokenize API, card_number, name_on_card, card_exp_year, card_exp_month and card_security_code fields are not required.
- Tags: String, Required

#### card_number:
- Description: A valid credit/debit card number
- Tags: String, Required

#### name_on_card:
- Description: Card holder name. Should contain alphabetical characters only.
- Tags: String

#### card_exp_year:
- Description: Represent the expiry year of the card as YY (two digits only)
- Tags: String, Required

#### card_exp_month:
- Description: Represent the expiry month of the card as MM (two digits only)
- Tags: String, Required

#### card_security_code:
- Description: CVV of the card. Usually three digits. Optional for all VISA saved cards, SODEXO saved cards, and saved cards of select issuing banks of MASTERCARD
- Tags: String, Required

#### redirect_after_payment:
- Description: This is a boolean variable and accepts true/false. We recommend that you set this to true and use the redirection flow. If set to true, then the user is redirected to the return_url configured for the order. If set to false, then the user will be stopped at the response page from the gateway. Your client should be able to read the page/title to infer that the user has completed the transaction.
- Tags: Boolean, Required

#### format:
- Description: If it is set to json, then the response will be HTTP 200 with a JSON formatted text. Otherwise, the response is HTTP 302 with the Location attribute having the destination URL.
- Tags: String, Required
### Metadata Object:

#### order.metadata.auto_refund_post_success:
- Description: Set it to true if you want to auto initiate refunds once the transaction is successful. For example, if you are doing refundable penny drop transactions for authentication/tokenization
- Value:  true, false
- Tags: Boolean

#### order.metadata.JUSPAY:gateway_reference_id:
- Description: **Use this parameter only when you have use case of gateway reference ID.** For detailed information check [here](https://juspay.io/br/docs/resources/docs/common-resources/gateway-reference-id).
- Tags: String

#### metadata.txns.auto_capture:
- Description: The default is set to **true** . Pass **false**  to for pre-auth orders.
- Value:  false,true
- Tags: Boolean
## API Responses:
### 200:

#### order_id:
- Description: :order_id
- Tags: String

#### txn_id:
- Tags: String, Mandatory

#### status:
- Description: PENDING_VBV
- Tags: String

#### payment:
- Value:
  - **Authentication.method**:
    - Tags: String
  - **Authentication.url**:
    - Tags: String
  - **Sdk_params**:
    - Value:
      - **Tr**:
        - Tags: String
      - **Tid**:
        - Tags: String
      - **Merchant_vpa**:
        - Tags: String
      - **Merchant_name**:
        - Tags: String
      - **Mcc**:
        - Tags: String
      - **Amount**:
        - Tags: String
    - Tags: object
- Tags: Object

#### txn_uuid:
- Description: :txn_uuid
- Tags: String

#### offer_details:
- Value:
  - **Offers**:
    - Description: Offer ID’s passed in transaction
    - Tags: Array of Strings
- Tags: Object
### 400:

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

#### error_message:
- Description: invalid_card_number
- Tags: String, Mandatory

#### error_code:
- Description: invalid_request
- Tags: String, Mandatory



## API Latency Guidelines




#### **What is API Latency?** 



Time taken by the server to respond to the API request.


#### **Average API Percentile Metrics and Recommended Timeout** 



* **TP50 (s)** : This represents the median latency, meaning 50% of all requests are completed in this time or less. It indicates the typical performance experienced by the majority of users.
* **TP90 (s)** : This value shows that 90% of requests are completed within this time, leaving 10% of requests that take longer. It gives insight into the performance for a broader set of users, beyond the median.
* **TP99 (s)** : This value indicates that 99% of requests finish within this time, with only 1% of requests taking longer. It helps identify outlier cases where latency may become an issue for a small group of users.
* **TP99.9 (s)** : This metric captures extreme latency outliers, where only 0.1% of requests take longer than this value. It's useful for understanding edge cases where performance degrades for very few users.
* **TP99.99 (s)** : This measures the most rare and severe performance outliers, where just 0.01% of requests exceed this time. Monitoring this helps in addressing the rarest and most critical latency issues that may impact user experience in exceptional scenarios.
  
  
  |  Transaction Percentile |  Latency (s) |
  |---|---|
  |  TP50 (s)em | 0.0198 |
  |  TP90 (s) | 0.290 |
  |  TP99 (s) | 0.429 |
  |  TP99.9 (s) | 0.429 |
  | Recommended Timeout | 1 |

---

## See Also

- [OmniChannel API flow](https://juspay.io/in/docs/api-reference/docs/googlepay-integrations-and-flows/omnichannel-api-flow)
- [Capture API](https://juspay.io/in/docs/api-reference/docs/preauth-and-capture/capture-api)
