---
page_source: https://juspay.io/in/docs/ec-headless/cordova/mandates/mandates-create-order-api
page_title: Mandates Create Order API
---

## API Version: default


# Create Order



This is the same API used for creating order for one-time payments. It can also be used to create a mandate for your existing customers with subscription specific details like amount, subscription frequency, duration of the mandate, Required/Optional mandate flow, etc. Use the order ID from the response of this API to call the Mandate Registration API.

Prerequisite for creating a mandate is to have the customer already registered/created with you. You can use Customer APIs to create a new customer or check the status of an existing customer.The API is not required for the merchants using Juspay's Payment Page product.

During the entire journey, a mandate once created can take up any of the following states:


| Status | Description |
|---|---|
| CREATED | Mandate has been created, but awaiting status from PG. |
| ACTIVE | When PG accepts the chosen mode of payment, the mandate is set to the active state. This is a terminal state until mandate expires or customer/merchant wants to revoke the mandate. |
| PAUSED | Customer has an option to pause the mandate. Status changes to PAUSED when customer exercises this option. |
| REVOKED | Mandate is revoked by either the customer or the merchant. Revoked is a terminal state, once Revoked the status cannot be changed. |
| FAILURE | Mandate creation was unsuccessful. This is a terminal state, the merchant has to create a new mandate if failed. |
| EXPIRED | Mandate validity has expired. This is a terminal state. |


> **Note**
> 
> ### Values that mandate.rule_value can adopt depending on mandate.frequency
> 
> 
> 
> **Fortnightly** 
> 
> 1. If the value is ‘14’, ‘15’ or ‘16’ and falls on the latter half of February (16th to 28th) then the mandate shall execute on the last day of February.
> 2. If the mandate start date is 24th January 2018 with value ‘16’ then the first debit will be on 31st January, followed by 15th February, 28th February, 15th March, 31st March and so on.
> 3. If the value is ‘16’ and the month has only 30 days then the mandate should execute on 30th.
> 4. If the mandate start date is 29th January and the value is ‘4’ then the first debit will be on 4th February followed by 19th February, 4th March and so on.
> 
> **Monthly** 
> 
> 1. If the value is ‘29’, ‘30’ or ‘31’ and falls on February then the mandate shall execute on the last day of February.
> 2. If the value is ‘31’ and the next executable month has 30 days only then the mandate will execute on 30th
> 3. If the mandate start date is 29th January and the value is ‘17’ then the first debit will be on 17th February

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

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

## Request Type: 
POST

## Content-Type: 
application/json

## Headers:

#### x-merchantid:
Merchant ID which would have been issues while registering with Juspay
- Tags: String, Mandatory

#### Content-Type:
It should be 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:

#### Order Create Request Code Snippet:

```order create request
curl --location 'https://api.juspay.in/orders' \
--header 'x-merchantid: merchant' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-routing-id: customer_1122' \
--data-urlencode 'order_id=234823498237423894273498' \
--data-urlencode 'amount=1.00' \
--data-urlencode 'currency=BRL' \
--data-urlencode 'customer_id=cst_lz7emoo5okgav' \
--data-urlencode 'customer_email=test@gmail.com' \
--data-urlencode 'customer_phone=9818638469' \
--data-urlencode 'billing_address_first_name=Name' \
--data-urlencode 'billing_address_city=Bengaluru' \
--data-urlencode 'shipping_address_city=Mumbai' \
--data-urlencode 'shipping_address_first_name=Name' \
--data-urlencode 'options.create_mandate=REQUIRED' \
--data-urlencode 'mandate.amount_rule=VARIABLE' \
--data-urlencode 'mandate.max_amount=1000.00' \
--data-urlencode 'mandate.recurring_amount=1000.00' \
--data-urlencode 'mandate.revokable_by_customer=true' \
--data-urlencode 'mandate.block_funds=false' \
--data-urlencode 'mandate.end_date=1914141600' \
--data-urlencode 'mandate.frequency=MONTHLY' \
--data-urlencode 'mandate.rule_value=1' \
--data-urlencode 'mandate.rule_type=ON' \
--data-urlencode 'gateway_id=19' \
```

#### Order to Refund Debited amount post setting up Mandate Code Snippet:

```order to refund debited amount post setting up mandate
curl --location 'https://api.juspay.in/orders' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic MzJCNDM3QTZCNUI0OEE5O' \
--header 'x-routing-id: customer_1122'\
--data-urlencode 'order_id=test_1721138542' \
--data-urlencode 'amount=2' \
--data-urlencode 'currency=BRL' \
--data-urlencode 'return_url=https://google.com' \
--data-urlencode 'customer_id=cth_d7bYTY1XKSFWjjTZ' \
--data-urlencode 'customer_email=aasdkj@gmail.com' \
--data-urlencode 'product_id=Testing' \
--data-urlencode 'options.create_mandate=REQUIRED' \
--data-urlencode 'mandate_max_amount=10' \
--data-urlencode 'metadata.auto_refund_post_success=True'
```

### Sample Request and Response:

#### Response:
```plaintext

{
  "status": "CREATED",
  "status_id": 1,
  "id": "ord_e294a26e66ad4336a992ceab81ad704c",
  "order_id": "1478851764",
  "payment_links": {
    "web": "https://api.juspay.io/guest/pay/ord_e294a26e66ad4336a992ceab81ad704c",
    "mobile": "https://api.juspay.io/guest/pay/ord_e294a26e66ad4336a992ceab81ad704c?mobile=true",
    "iframe": "https://api.juspay.io/guest/ipay/ord_e294a26e66ad4336a992ceab81ad704c"
  }
}
```

## Body Parameters:
### Request Parameters:

#### order_id:
- Description: Unique Identifier for the order. You can pass your native **order ID**  here.
- Value: value
- Tags: String, Mandatory

#### amount:
- Description: This is the amount that a customer will be charged in this transaction. 
- Tags: doube, Mandatory

#### currency:
- Description: ISO string of the currency. Default value: `INR`
- Tags: String

#### customer_id:
- Description: Unique ID for a customer that you get after running the **Create Customer API** (Check Customer section for more details)
- Tags: String, Mandatory

#### customer_email:
- Description: Email address of the customer. This field is mandatory if gateway requires it.
- Tags: String

#### customer_phone:
- Description: Mobile number or fixed line number of the customer. This field is mandatory if gateway requires it.
- Tags: String

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

#### product_id:
- Description: An identifier for the product. Fits well for impulse purchase usecases.
- Tags: String

#### gateway_id:
- Description: Specify your preferred gateway for this order. Complete mapping for **gateway_id**  can be found here: [Gateway mapping](https://docs.juspay.io/br/resources/docs/dynamic-routing/dynamic-routing#Enforce-Gateway-Routing)
- Tags: String

#### return_url:
- Description: A fully qualified URL such as [http://shop.merchant.com/](http://shop.merchant.com/) to which the customer will be redirected after payment completion. This URL shouldn’t contain any query parameters.This URL takes higher precedence over the common return URL configured in your account settings.
- 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: Line 1 in the billing address
- Tags: String

#### billing_address_line2:
- Description: Line 2 in the billing address
- Tags: String

#### billing_address_line3:
- Description: Line 3 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

#### options.create_mandate:
- Description: For merchants who wants to set up mandates, can pass this as either **“REQUIRED”**  or **“OPTIONAL”** . **“REQUIRED”**  means that the transaction for this order has to be definitely converted to a mandate. **“OPTIONAL”**  means that the final decision of conversion of the transaction lies at the **/txns**  api call with the flag **“should_create_mandate”** 
- Tags: String, Mandatory

#### mandate object:
- Value:
  - **Max_amount**:
    - Description: Maximum amount for a mandate. Required, only when amount type is variable. If amount type is fixed, amount is considered as max amount.
    - Tags: String, Mandatory
  - **Frequency**:
    - Description: Defines the frequency of mandate execution, how often a customer should be charged.Data type **ENUM:** **ONETIME (Supported only by UPI)** **DAILY** **WEEKLY** **FORTNIGHTLY** **MONTHLY** **BIMONTHLY** **QUARTERLY** **HALFYEARLY** **YEARLY** **ASPRESENTED** By Default it is considered as **ASPRESENTED** 
      
      If frequency is selected anything other than **ONETIME** , **DAILY** , **ASPRESENTED** , rule_value should be passed mandatorily.
      
      **Note:** 1. Daily is not supported by Billdesk and Paytm (For cards)2. In UPI AutoPay, ONETIME frequency, Mandate is valid only for 90 Days
    - Tags: String
  - **Amount_rule**:
    - Description: Data type **ENUM: FIXED, VARIABLE** . By default, it is considered as VARIABLE. In case of FIXED **amount_rule** .
    - Tags: String
  - **End_date**:
    - Description: **Mandatory for UPI Mandate** . Mandate end date in UNIX EPOCH timestamp (UTC timezone). Post end date, mandate will move to **EXPIRED**  state and recurring mandate will not be [allowed.By](http://allowed.By) default value will be Mandate start date + 30 years
    - Tags: String
  - **Revokable_by_customer**:
    - Description: If false, the mandate cannot be revoked by the customer once set. Applicable only for UPI mandate. It should be true for Recurring and true/false for **ONETIME** . By default value will be true
    - Tags: boolean
  - **Block_funds**:
    - Description: Set to true if funds have to be blocked while a mandate is being created. Should be true for **ONETIME**  and false for **Recurring** . By default value will be **TRUE**  for ONETIME and **FALSE**  for Recurring.
    - Tags: Boolean
  - **Rule_value**:
    - Description: **1-7**  when frequency is **WEEKLY** . In weekly, serial numbers start from **Monday** . **Monday**  represents 1 and **Sunday**  represents 7.**1-16**  when frequency is **FORTNIGHTLY** . This mandate is executed **twice**  a month. **First day**  of the month is represented by value ‘1’ and ends with ‘15’ on 15th day of the month. Then again starts with ‘1’ for 16th of the month and ends with the last day of the month.1-31 when frequency is **MONTHLY** , **BIMONTHLY** , **QUARTERLY** , **HALFYEARLY** , or **YEARLY** .Not required when frequency is **ONETIME** , **DAILY** , **ASPRESENTED** .For Razorpay, **rule_value**  will be considered as the last date of the week/month/year.For Paytm, **rule_value**  will be considered as today’s date/day.Refer notes for detailed explanation.
    - Tags: String
  - **Rule_type**:
    - Description: **ON| BEFORE| AFTER** For Razorpay, rule_type will be updated to **BEFORE** . For Paytm, Billdesk rule_type will be updated to **AFTER** .
    - Tags: String
  - **Recurring_amount**:
    - Description: Recurring amount for a mandate.For variable amount type, Recurring amount should not be greater than max_amount.For fixed amount type, Recurring amount should not be greater than order amount.Recommended, if update mandate flow is used later.
    - Tags: String, Recommended
- Tags: Object

#### udf1-10:
- Tags: String

#### metadata object:
- Value:
  - **PAYTM_V2:SUBSCRIPTION_GRACE_DAYS**:
    - Description: Number of days after renewal cycle start date for which merchant can send renewal request. By default 0 for **DAILY**  and **ASPRESENTED**  and 7 for remaining frequencies.
    - Tags: String
  - **PAYTM_V2:SUBSCRIPTION_RETRY_COUNT**:
    - Description: Applicable only for **Paytm** . By default 2 for UPI mandate.
    - Tags: String
  - **Bank_account_details**:
    - Description: Applicable for TPV Mandate. _This is a array of JSON objects and each JSON object includes set of parameters as below 1. bank_account_number 2. bank_ifsc 3. juspay_bank_code 4. bank_beneficiary_name 5. bank_account_type 6. bank_account_id_ If a merchant uses juspay bank_account feature APIs, then sending bank_account_id is sufficient.
    - Tags: String
  - **Auto_refund_post_success**:
    - Description: Pass the param if you want to refund the debit amount while setting up the mandate, this will keep you mandate in active state and initiate a refund call to the PG
    - Value: True
    - Tags: String
- Tags: object

#### order_type:
- Description: **TPV_PAYMENT** . Applicable only for TPV Mandates.
- Tags: String
## API Responses:
### 200:

#### 200 : UPI:
- Value:
  - **Status_id**:
    - Tags: integer
  - **Status**:
    - Tags: String
  - **Payment_links**:
    - Value:
      - **Web**:
        - Tags: String
      - **Mobile**:
        - Tags: String
      - **Iframe**:
        - Tags: String
    - Tags: object
  - **Order_id**:
    - Tags: String
  - **Id**:
    - Tags: String
- Tags: Object

#### 200 : Card:
- Value:
  - **Status**:
    - Tags: String
  - **Status_id**:
    - Tags: integer
  - **Id**:
    - Tags: String
  - **Order_id**:
    - Tags: String
  - **Payment_links**:
    - Value:
      - **Web**:
        - Tags: String
      - **Mobile**:
        - Tags: String
      - **Iframe**:
        - Tags: String
    - Tags: object
- Tags: object

#### 200 :  Netbanking:
- Value:
  - **Status**:
    - Tags: String
  - **Status_id**:
    - Tags: Integer
  - **Id**:
    - Tags: String
  - **Order_id**:
    - Tags: String
  - **Payment_links**:
    - Value:
      - **Web**:
        - Tags: String
      - **Mobile**:
        - Tags: String
      - **Iframe**:
        - Tags: String
    - Tags: object
- Tags: object
