---
title: Create Payout Order
slug: fiat-docs/create-payout-order
docTags: 
createdAt: 2024-02-15T08:33:09.287Z
---

This API creates a payout order to enable users to withdraw funds. 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 [pay3Pay.openPayout()](docId:5YeEhTUtJ0mhyfY85CrKd)&#x20;

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

:::ApiMethodV2
```json
{
  "name": "Create Payout Order",
  "method": "POST",
  "url": "https://your-hostname.pay3.app/v1/client/payout/create-order",
  "description": "Create an order with payout details from application's backend",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "eXhyHL9RWXfgU_lG6oq1Q",
        "language": "curl",
        "code": "curl --location 'https://your-hostname.pay3.app/v1/client/payout/create-order' \\\n--header 'signature': \"generated-signature\"\\\n--header 'access-token' : \"dynamic-access-token\" \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"currencyId\": \"currency-id\",\n    \"fiatAmount\": \"0.02\",\n    \"requestId\": \"9824649238\",\n    \"paymentMethodId\": \"payment-method-id\",\n    \"email\": \"user@address.com\",\n    \"clientId\": \"your-client-id\",\n    \"firstName\": \"John\",\n    \"lastName\": \"Doe\",\n    \"taxId\": \"tax-id\"\n}'",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "eXhyHL9RWXfgU_lG6oq1Q"
  },
  "results": {
    "languages": [
      {
        "id": "VQyRchSR38UbBEhATUpjh",
        "language": "200",
        "customLabel": "",
        "code": "{\n  \"requestId\": \"9824649238\",\n  \"token\": \"a35dc551-9fb4-491c-9f9b-44d9c2ef4b32\",\n  \"offerInfoData\": {\n    \"clientId\": \"your-client-id\",\n    \"currencyId\": \"currency-id\",\n    \"onRampPartner\": \"partner-id\",\n    \"requestMetadata\": {\n      \"lastName\": \"Doe\",\n      \"firstName\": \"John\",\n      \"requestId\": \"9824649238\",\n      \"signature\": \"generated-signature\"\n    },\n    \"selectedPaymentMethod\": \"payment-method-id\",\n    \"totalFiatAmount\": \"0.02\",\n    \"type\": \"PAYOUT\",\n    \"userAddress\": \"user@address.com\"\n  }\n}\n"
      },
      {
        "id": "66DvgM2SsFyRRj4NnmNJ1",
        "language": "400",
        "code": "{\n    error: {\n      code: '7001',\n      message: 'Order already exists for given requestId'\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": "requestId",
        "kind": "required",
        "type": "string",
        "description": "Identifier that is created by Application's backend. This will be passed in relevant events and webhooks from Pay3 to Application",
        "children": []
      },
      {
        "name": "currencyId",
        "kind": "required",
        "type": "string",
        "description": "Currency id supported in the payout flow. This will be provided by Pay3 during onboarding"
      },
      {
        "name": "fiatAmount",
        "kind": "required",
        "type": "string",
        "description": "Amount user can withdraw in string format. Maximum two decimal places are allowed",
        "children": []
      },
      {
        "name": "paymentMethodId",
        "kind": "required",
        "type": "string",
        "description": "Unique string identifier. This will be provided by Pay3 during onboarding ",
        "children": []
      },
      {
        "name": "email",
        "kind": "required",
        "type": "string",
        "description": "User email to identify the user, which will be available in reporting dashboard",
        "children": []
      },
      {
        "name": "userId",
        "kind": "optional",
        "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.",
        "": "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."
      },
      {
        "name": "clientId",
        "kind": "required",
        "type": "string",
        "description": "Client id. Application's identifier",
        "children": []
      },
      {
        "name": "firstName",
        "kind": "optional",
        "type": "string",
        "description": "Optional first name of the user",
        "children": []
      },
      {
        "name": "lastName",
        "kind": "optional",
        "type": "string",
        "description": "Optional last name of the user",
        "children": []
      },
      {
        "name": "taxId",
        "kind": "optional",
        "type": "string",
        "description": "Tax ID issued to the user by their country",
        "children": []
      },
      {
        "name": "pixKey",
        "kind": "optional",
        "type": "string",
        "description": "PIX Key is a unique identifier that links to a Brazilian user’s bank account and determines where the funds will be received.",
        "children": []
      },
      {
        "name": "mode",
        "kind": "optional",
        "type": "string",
        "description": "mode can accept values like bank, cpf, pix etc. pixKey is mandatory if mode is set to pix.",
        "children": []
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```
:::

## Signature Generation

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

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

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

const getSignature = (secretKey, currencyId, fiatAmount, requestId) => {
    // Prepare the string to sign in same format. 
    // currencyId followed by fiatAmount followed by requestId
    const stringToSign = 'currencyId=' + currencyId + '&fiatAmount=' + fiatAmount + '&requestId=' + requestId;
    
    // 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, currencyId, fiatAmount, requestId);

```

