---
title: Create Subscription Order
slug: create-subscription-order
docTags: 
createdAt: 2025-05-02T10:40:00.252Z
---

This API creates a subscription order to enable users to make payment and start subscriptions. It accepts amount and currency details. On creating an order a dynamic `token` is returned from this api which is required to be passed to Pay3 SDK

This api requires access token that can be generated using [Access Token](docId\:lq-v6fF_2i-h1O3XD5KKA) API.

:::ApiMethodV2
```json
{
  "name": "Create Checkout Order",
  "method": "POST",
  "url": "https://your-hostname.pay3.app/v1/client/checkout/create-order",
  "description": "Create an order with payin details from application's backend",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "nyfSHp7J-NrsuqTH3FW7t",
        "language": "curl",
        "code": "curl --location 'https://api.dev.pay3.app/v1/client/subscription/create-order' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--header 'signature: {{signature}}' \\\n--header 'access-token: ' \\\n--data-raw '{\n    \"currencyId\": \"usd_usa\",\n    \"fiatAmount\": \"1.00\",\n    \"paymentMethodId\": \"all\",\n    \"email\": \"user@example.com\",\n    \"userId\": \"....\",\n    \"clientId\": \"....\",\n    \"requestId\": \"....\",\n    \"interval\": \"MONTHLY\",\n    \"requestDescription\": \"Gold plan\",\n    \"mode\": \"returnUrl\"\n}'",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "nyfSHp7J-NrsuqTH3FW7t"
  },
  "results": {
    "languages": [
      {
        "id": "VQyRchSR38UbBEhATUpjh",
        "language": "200",
        "code": "{\n    \"requestId\": \"5a3566b0-b0a9-4329-b48f-2921c715ce44\",\n    \"url\": \"https://dev-ui.pay3.app/web-sdk-pay/3b789bdc-3b33-4123-be35-459f58787cee?referrer=https://dev-ui.pay3.app&action=subscription&data=eyJyZXF1ZXN0SWQiOiI1YTM1NjZiMC1iMGE5LTQzMjktYjQ4Zi0yOTIxYzcxNWNlNDQiLCJ0b2tlbiI6IjBhZDM3OTQxLTg2ODItNDg5NC1iMDlkLWYzYjg3MzhkOTY5ZSJ9&lang=en\",\n    \"token\": \"0ad37941-8682-4894-b09d-f3b8738d969e\",\n    \"status\": null\n}",
        "customLabel": ""
      },
      {
        "id": "tIvoQbUSKGnrqallvNDVQ",
        "language": "401",
        "code": "{\n    \"code\": \"7001\",\n    \"error\": {\n        \"code\": \"500\",\n        \"message\": \"No route found for subscription\"\n    }\n}\n\n{\n    \"code\": \"7001\",\n    \"error\": {\n        \"code\": \"500\",\n        \"message\": \"Invalid value for interval: DAILY1\"\n    }\n}",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "VQyRchSR38UbBEhATUpjh"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [
      {
        "name": "signature",
        "kind": "required",
        "type": "string",
        "description": "Signature generated with sha256 followed by base64 encoding. Check below section for more details",
        "children": []
      },
      {
        "name": "access-token",
        "kind": "required",
        "type": "string",
        "description": "Access token received from Access token API. You can reuse the access token across multiple API calls till it is expired",
        "children": []
      }
    ],
    "bodyDataParameters": [
      {
        "name": "currencyId",
        "kind": "required",
        "type": "string",
        "description": "This will be provided by Pay3 during onboarding",
        "": "This will be provided by Pay3 during onboarding"
      },
      {
        "name": "fiatAmount",
        "kind": "required",
        "type": "string",
        "description": "Amount user have to Pay in string format. Maximum two decimal places are allowed",
        "": "Amount user have to Pay in string format. Maximum two decimal places are allowed"
      },
      {
        "name": "paymentMethodId",
        "kind": "required",
        "type": "string",
        "description": "Unique string identifier. This will be provided by Pay3 during onboarding ",
        "": "required"
      },
      {
        "name": "email",
        "kind": "required",
        "type": "string",
        "description": "User email to identify the user, which will be available in reporting dashboard",
        "": "required"
      },
      {
        "name": "userId",
        "kind": "required",
        "type": "string",
        "description": "It is a type of UUID. It will used as unique identifier of the user. If this is not passed, email will be used as a unique identifier of the user within Pay3.",
        "": "required"
      },
      {
        "name": "clientId",
        "kind": "required",
        "type": "string",
        "description": "Client id. Application's identifier",
        "children": []
      },
      {
        "name": "requestId",
        "kind": "required",
        "type": "string",
        "description": "Identifier that is created by client application's backend. This will be passed in relevant events and webhooks from Pay3 to Application. It is required to be globally unique example UUID.",
        "": "Identifier that is created by client application's backend. This will be passed in relevant events and webhooks from Pay3 to Application. It is required to be globally unique example UUID."
      },
      {
        "name": "interval",
        "kind": "required",
        "type": "string",
        "description": "Defines the billing frequency for the subscription. This value determines how often the recurring payment will be charged after the initial payment.\n\nAllowed values: DAILY, WEEKLY, MONTHLY, YEARLY\n\nThe interval must match the subscription plan configured on Pay3. Any mismatch will result in request validation failure.",
        "": "required"
      },
      {
        "name": "requestDescription",
        "kind": "required",
        "type": "string",
        "description": "The subscription plan name as displayed on the client’s UI. This value is used by Pay3 to identify and match the subscription plan associated with the request.\n\nThe requestDescription must exactly match the plan name configured on the client side to ensure correct subscription mapping and recurring billing setup.",
        "": "required"
      },
      {
        "name": "mode",
        "kind": "required",
        "type": "string",
        "description": "returnUrl - In this mode, the API returns a Pay3 payment URL that can be embedded directly into the client’s application. This is useful when the client wants to open the Pay3 URL inside a WKWebView (iOS), WebView (Android/React Native), or an <iframe> in a web app.\n",
        "": "required"
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "create-checkout-order",
  "legacyHash": "706EUjTSNEFgKfL4kKq4S"
}
```
:::

## Signature Generation

The request for creating checkout order requires a header `signature`. This can be generated using following code snippet.&#x20;

```javascript
const crypto = require('crypto');

// Required Parameters
const secretKey="Api-Secret-Provided-By-Pay3";
const fiatAmount =  "0.02";
const requestId = "Order-Id-Generated-By-Application";
const currencyId = "currency-id";
const interval = "MONTHLY";
const trialPeriodDays = "7";
const clientId = "your-client-id";
const accessToken = "dynamic-access-token";

const getSignature = (secretKey, fiatAmount, requestId) => {
    // Prepare the string to sign in same format. 
    // currencyId, fiatAmount, requestId and interval (if trialPeriodDays then add trialPeriodDays as well)
    let stringToSign = 'currencyId=' + currencyId + 
                        '&fiatAmount=' + fiatAmount + 
                        '&requestId=' + requestId +
                        '&interval=' + interval;
    if(trialPeriodDays && trialPeriodDays != "") {
        stringToSign = stringToSign + '&trialPeriodDays=' + trialPeriodDays;
    }
    
    // Generating signature using SHA256 and provided secret and
    // base64 encode the result
    const mac = crypto.createHmac('sha256', secretKey);
    return mac.update(stringToSign).digest('base64');
}

// Generate Signature
const signature = getSignature(secretKey, fiatAmount, requestId);
```

***

