---
page_source: https://docs.juspay.io/paytm-gateway-configuration/docs/express-checkout/create-order-api
page_title: Create Order API
---

## API Version: default


# Create Order API



This is a Server-to-Server API that takes order parameters as an input and creates an order in the Juspay system and fetches the corresponding client_auth_token.


---


Amount and order id are the mandatory fields, the contact details like email, phone number, customer id's are conditional and depends on the underlying payment gateway/ aggregator used.  

'UDF' is used to pass any additional information that is required to be stored at Juspay for any analysis or other operations. In some cases, these UDFs are passed to the downstream gateways as well. 

Juspay supports 10 UDFs (UDF1 to UDF10). The values passed in UDFs are reflected back in the order status response and in webhooks back to the merchant. If there are any special characters that need to be passed in UDF values, please use UDF 6 to 10 for passing the same. UDF 1 to 5 can be used to pass values which do not have any special characters.

‘Metadata’ is used to send custom params to the payment aggregators, irrespective of default parameters, The supported parameters

Note: Auth api key should be Base64 encoded.


| Payment Gateways | Fields |
|---|---|
| PG1 | metadata.PG1:promo_code |
| PG2 | metadata.PG2:AdditionalInfo3 |
| PG3 | metadata.PG3:campaignCode |
| PG4 | metadata.PG4:OrderInfo |
| PAYPAL | metadata.PAYPAL:landing_page |
| PAYPAL | metadata.PAYPAL:phone_number |
| PAYPAL | metadata.PAYPAL:country_code |
| PAYPAL | metadata.PAYPAL:first_name  |
| PAYPAL | metadata.PAYPAL:last_name  |
| PAYPAL | metadata.PAYPAL:experience_id |
| PAYPAL | metadata.PAYPAL:brand_name |
| PAYPAL | metadata.PAYPAL:additional_data |
| PAYPAL - For Link and Pay  | metadata.PAYPAL:lnp_product_name |
| PAYPAL - For Link and Pay  | metadata.PAYPAL:lnp_product_code |
| PAYPAL - For Link and Pay  | metadata.PAYPAL:lnp_charge_pattern |
| PAYPAL - For Link and Pay  | metadata.PAYPAL:direct_wallet_version |
| PAYPAL - For Link and Pay  | metadata.PAYPAL:purchase_category |


**Payment Links** Order create response will contain payment links for web, mobile & iFrame. These links can directly be emailed or messaged to your customers. If you wish to use your own branding, then you can embed the iframe link into your page. Note that, these links are not valid perpetually. As soon as your order expires (this can be changed via [our dashboard](https://analytics.expresscheckout.juspay.in/?navtab=euler_settings), the link will cease to work.## Endpoints:
- Production: https://api.juspay.in/orders

## 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: <p>Example:- <br> Basic MUQ2QUxxxxxxxxxxxxU5QTIxQzNFNTQwNkFDMEZCOg==</p>
- Tags: Base64 Encoded username:password, required
## Headers:

#### x-merchantid:
Merchant ID provided by Juspay
- Value: <p>Example:- <br>merchant-id</p>
- Tags: string, required

#### version:
Pass the date in YYYY-MM-DD format
- Value: <p>Example:- <br>2023-01-01</p>
- Tags: string

#### Content-Type:
application/x-www-form-urlencoded
- Tags: String
## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl --location 'https://sandbox.juspay.in/txns' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic e3thcGlrZXl9fTo=' \
--data-urlencode 'order_id=1692783824' \
--data-urlencode 'merchant_id=paypal' \
--data-urlencode 'payment_method_type=WALLET' \
--data-urlencode 'payment_method=GRABPAY' \
--data-urlencode 'redirect_after_payment=true' \
--data-urlencode 'format=json'
--data-urlencode 'order.order_id=ord_1590759422' \
--data-urlencode 'order.amount=1015.00' \
--data-urlencode 'order.currency=SGD' \
--data-urlencode 'order.customer_id=cst_1590759422' \
--data-urlencode 'order.return_url=https://merchant.in/payments' \

```

### Sample Response:

#### Response with auth token:
```plaintext
{
  "udf9": "",
  "udf8": "",
  "udf7": "",
  "udf6": "",
  "udf5": "",
  "udf4": "",
  "udf3": "",
  "udf2": "",
  "udf10": "",
  "udf1": "",
  "status_id": 10,
  "status": "NEW",
  "return_url": "",
  "refunded": false,
  "product_id": "",
  "payment_links": {
    "web": "https://api.juspay.in/merchant/pay/ordeu_8bddad1e3b9c85eab3db4528575c01b",
    "mobile": "https://api.juspay.in/merchant/pay/ordeu_8bddad1e3b9c85eab3db4528575c01b?mobile=true",
    "iframe": "https://api.juspay.in/merchant/ipay/ordeu_8bddad1e3b9c485eab3db4528575c01b"
  },
  "order_id": "14183944763",
  "merchant_id": "merchantId",
  "juspay": {
    "client_auth_token_expiry": "2020-06-16T10:43:35Z",
    "client_auth_token": "tkn_753275c49a44a1a313eb2567f2fd6b"
  },
  "id": "ordeu_8bddad1e3b9c85eab3db4528575c01b",
  "date_created": "2020-06-16T10:28:35Z",
  "customer_phone": "99999999",
  "customer_id": "1235677",
  "customer_email": "test@gmail.com",
  "currency": "SGD",
  "amount_refunded": 0,
  "amount": 1
}
```

#### Response without auth token:
```json
{
  "status": "CREATED",
  "status_id": 1,
  "id": "ord_e294a26e66ad4336a992ceab81ad704c",
  "order_id": "14183944763",
  "payment_links": {
    "web": "https://api.juspay.in/merchant/pay/ord_e294a26e66ad4336a992ceab81ad704c",
    "mobile": "https://api.juspay.in/merchant/pay/ord_e294a26e66ad4336a992ceab81ad704c?mobile=true",
    "iframe": "https://api.juspay.in/merchant/ipay/ord_e294a26e66ad4336a992ceab81ad704c"
  }
}
```

## Body Parameters:
### Basic Parameters:

#### order_id:
- Description: Unique Identifier for the order. Should be Alphanumeric with character length less than 21.
- Value: <p>Example:- <br> order-id-9876580 </p>
- Tags: string, required

#### 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.
- Value: <p>Example:- <br> 1.00 </p>
- Tags: Double, required

#### options.get_client_auth_token:
- Description: Client side authenticaion token required for Hyper SDK calls
- Value: Value : true
- Tags: string

#### 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.
- Value: <p>Example:- <br> customer-id-007 </p>
- Tags: string

#### customer_email:
- Description: Email address of the customer. If the backend gateway requires it, then you must send this value.
- Value: <p>Example:- <br> test@gmail.com</p>
- Tags: string

#### customer_phone:
- Description: Mobile number or fixed line number of the customer. If the backend gateway requires it, then you must send this value.
- Value: <p>Example:- <br> 99999999</p>
- Tags: string

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

#### description:
- Description: Short description for the order. We send this information to the backend gateways whenever there is a provision for this.
- Tags: string

#### 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.
- Value: <p>Example:- <br> https://shop.merchant.com </p>
- Tags: string

#### product_id:
- Description: An identifier for the product. Fits well for impulse purchase usecases.
- Value: <p>Example:- <br> John </p>
- Tags: string

#### gateway_id:
- Description: Specify your preferred gateway for this order.
- Value: <p>Example:- <br> Wick </p>
- Tags: string

#### billing_address_first_name:
- Description: First name in the billing address
- Tags: string

#### billing_address_last_name:
- Description: Last name in the billing address
- Tags: string

#### billing_address_line1:
- Description: Line1 in the billing address
- Tags: string

#### billing_address_line2:
- Description: Line2 in the billing address
- Tags: string

#### billing_address_line3:
- Description: Line3 in the billing address
- Tags: string

#### billing_address_city:
- Description: Billing address city
- Tags: string

#### billing_address_state:
- Description: Billing address state
- Tags: string

#### billing_address_country:
- Description: Billing address country
- Tags: string

#### billing_address_postal_code:
- Description: Billing address postal code or zip code
- Tags: string

#### billing_address_phone:
- Description: Mobile or phone number in the billing address
- Tags: string

#### billing_address_country_code_iso:
- Description: ISO Country code Default value: IND
- Tags: string

#### shipping_address_first_name:
- Description: First name in the shipping address
- Tags: string

#### shipping_address_last_name:
- Description: Last name in the shipping address
- Tags: string

#### shipping_address_line1:
- Description: Line1 in the shipping address
- Tags: string

#### shipping_address_line2:
- Description: Line2 in the shipping address
- Tags: string

#### shipping_address_line3:
- Description: Line3 in the shipping address
- Tags: string

#### shipping_address_city:
- Description: Shipping address city
- Tags: string

#### shipping_address_state:
- Description: Shipping address state
- Tags: string

#### shipping_address_country:
- Description: Shipping address country
- Tags: string

#### shipping_address_postal_code:
- Description: Shipping address postal code or zip code
- Tags: string

#### shipping_address_phone:
- Description: Mobile or phone number in the shipping address
- Tags: string

#### shipping_address_country_code_iso:
- Description: ISO Country code Default value: IND
- Tags: string
### Metadata Object:

#### 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://docs.juspay.in/resources/docs/common-resources/gateway-reference-id).
- Value: <p>Example:- <br> BUS </p>
- Tags: string

#### subvention_amount:
- Description: The amount for which the EMI interest should not be calculated.
- Tags: String

#### webhook_url:
- Description: Merchant can pass dynamic webhook URL in this field. The webhook authentication would be same as the one configured on the dashboard. Ex: metadata.webhook_url=[https://merchant.juspay/response](https://merchant.juspay/response)
- Tags: String
### User Defined Parameters (UDF):

#### udf1 , udf2 , udf3 , udf4, udf5:
- Description: User Defined Parameter (UDF)

This field can be used to send any user defined parameters

The UDF parameters for orders can be seen in the JUSPAY dashboard under each order
- Value: <p>Example:- <br>user5349</p>
- Tags: string (Upto 255 characters), No special characters supported

#### udf6 , udf7 , udf8 , udf9 , udf10:
- Description: User Defined Parameter (UDF)

This field can be used to send any user defined parameters

The UDF parameters for orders can be seen in the JUSPAY dashboard under each order
- Value: <p>Example:-<br>user_5349</p>
- Tags: string (Upto 255 characters), Special characters supported
## API Responses:
### 200:

#### status:
- Description: Status of order Example:- NEW
- Tags: string

#### status_id:
- Description: Status ID is a numeric id corresponding to the status value.
- Tags: integer

#### id:
- Description: Unique ID generated by Juspay for the given order
- Tags: string

#### order_id:
- Description: Order Id passed during order creation
- Tags: string

#### payment_links:
- Description: Https link using which user can open payment page and perform transaction against the order created
- Value:
  - **Web**:
    - Tags: string
  - **Mobile**:
    - Tags: string
  - **Iframe**:
    - Tags: string
- Tags: JSON

#### juspay:
- Value:
  - **Client_auth_token_expiry**:
    - Tags: string
  - **Client_auth_token**:
    - Tags: string
- Tags: JSON
### 400:

#### status:
- Description: Bad Request
- Tags: string

#### error_code:
- Description: Details of keys missing
- Value: <p>Example:- <br> Mandatory fields are missing </p>
- Tags: string

#### error_message:
- Description: Further Details of keys missing
- Tags: string
