Skip to content
Whats91

Create an order and send its payment request in one call, with idempotency protection.

Create and Send Order

Summary

Create an order and send its payment request in one call, with idempotency protection.

Prerequisites

  • Authorization: Bearer w91_live_xxx
  • Content-Type: application/json for JSON requests

Creates an order and sends its payment request in a single call. The two steps run sequentially; use the create body with a nested send object.

POST/api/v3/orders/send

Create an order and send its payment request.

cURL
curl -X POST "https://graph.whats91.com/api/v3/orders/send" \
  -H "Authorization: Bearer w91_live_xxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: restaurant-checkout-2092" \
  -d '{
    "sender_id": "919999999999",
    "recipient": { "phone": "919876543210", "name": "Restaurant Guest" },
    "items": [
      { "product_uid": "prod_masala_dosa", "quantity": 1 },
      { "product_uid": "prod_filter_coffee", "quantity": 2 }
    ],
    "currency": "INR",
    "total_amount": "300.00",
    "send": {
      "config_uid": "pcfg_manual_upi",
      "body_text": "Please review and pay.",
      "expires_in_minutes": 30
    }
  }'
Created, then send failed
{
  "success": false,
  "message": "The 24-hour chat window is closed. Select an approved payment template.",
  "error_code": "PAYMENT_TEMPLATE_REQUIRED",
  "details": {
    "templates": [],
    "order_uid": "ord_abc123",
    "order_status": "draft",
    "send_retry_endpoint": "/api/v3/orders/ord_abc123/send"
  },
  "metadata": {
    "apiVersion": "v3",
    "requestId": "request-uuid"
  }
}

Warning

If creation succeeds but sending fails, the draft is deliberately not rolled back. Correct the send input and call the endpoint returned in details.send_retry_endpoint. Do not call create-and-send again without the original idempotency key, or you will create a second order.

SDK Examples

Use these examples as starting points for server-side implementations.

cURL
curl -X POST "https://graph.whats91.com/api/v3/orders/send" \
  -H "Authorization: Bearer w91_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
  "sender_id": "919999999999",
  "recipient": {
    "phone": "919876543210",
    "name": "Restaurant Guest"
  },
  "items": [
    {
      "product_uid": "prod_masala_dosa",
      "quantity": 1
    },
    {
      "product_uid": "prod_filter_coffee",
      "quantity": 2
    }
  ],
  "currency": "INR",
  "total_amount": "300.00",
  "send": {
    "config_uid": "pcfg_manual_upi",
    "body_text": "Please review and pay.",
    "expires_in_minutes": 30
  }
}'
Node.js
const response = await fetch("https://graph.whats91.com/api/v3/orders/send", {
  method: "POST",
  headers: {
    "Authorization": "Bearer w91_live_xxx",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "sender_id": "919999999999",
    "recipient": {
      "phone": "919876543210",
      "name": "Restaurant Guest"
    },
    "items": [
      {
        "product_uid": "prod_masala_dosa",
        "quantity": 1
      },
      {
        "product_uid": "prod_filter_coffee",
        "quantity": 2
      }
    ],
    "currency": "INR",
    "total_amount": "300.00",
    "send": {
      "config_uid": "pcfg_manual_upi",
      "body_text": "Please review and pay.",
      "expires_in_minutes": 30
    }
  })
});

const data = await response.json();
console.log(data);
PHP
$ch = curl_init("https://graph.whats91.com/api/v3/orders/send");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer w91_live_xxx",
    "Content-Type: application/json"
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "sender_id" => "919999999999",
    "recipient" => [
      "phone" => "919876543210",
      "name" => "Restaurant Guest"
    ],
    "items" => [
      [
        "product_uid" => "prod_masala_dosa",
        "quantity" => 1
      ],
      [
        "product_uid" => "prod_filter_coffee",
        "quantity" => 2
      ]
    ],
    "currency" => "INR",
    "total_amount" => "300.00",
    "send" => [
      "config_uid" => "pcfg_manual_upi",
      "body_text" => "Please review and pay.",
      "expires_in_minutes" => 30
    ]
  ])
]);

$response = curl_exec($ch);
curl_close($ch);
echo $response;
Python
import requests

response = requests.request(
    "POST",
    "https://graph.whats91.com/api/v3/orders/send",
    headers={
        "Authorization": "Bearer w91_live_xxx",
        "Content-Type": "application/json",
    },
    json={
        "sender_id": "919999999999",
        "recipient": {
            "phone": "919876543210",
            "name": "Restaurant Guest"
        },
        "items": [
            {
                "product_uid": "prod_masala_dosa",
                "quantity": 1
            },
            {
                "product_uid": "prod_filter_coffee",
                "quantity": 2
            }
        ],
        "currency": "INR",
        "total_amount": "300.00",
        "send": {
            "config_uid": "pcfg_manual_upi",
            "body_text": "Please review and pay.",
            "expires_in_minutes": 30
        }
    }
)

print(response.json())
C#
using System.Text;

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer w91_live_xxx");

var request = new HttpRequestMessage(HttpMethod.Post, "https://graph.whats91.com/api/v3/orders/send");
request.Content = new StringContent(
  """
  {
    "sender_id": "919999999999",
    "recipient": {
      "phone": "919876543210",
      "name": "Restaurant Guest"
    },
    "items": [
      {
        "product_uid": "prod_masala_dosa",
        "quantity": 1
      },
      {
        "product_uid": "prod_filter_coffee",
        "quantity": 2
      }
    ],
    "currency": "INR",
    "total_amount": "300.00",
    "send": {
      "config_uid": "pcfg_manual_upi",
      "body_text": "Please review and pay.",
      "expires_in_minutes": 30
    }
  }
  """,
  Encoding.UTF8,
  "application/json"
);

var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());

Related APIs