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
Related documentation
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.
/api/v2/orders/sendCreate an order and send its payment request.
curl -X POST "https://graph.whats91.com/api/v2/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
}
}'{
"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/v2/orders/ord_abc123/send"
},
"metadata": {
"apiVersion": "v2",
"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 -X POST "https://graph.whats91.com/api/v2/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
}
}'const response = await fetch("https://graph.whats91.com/api/v2/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);$ch = curl_init("https://graph.whats91.com/api/v2/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;import requests
response = requests.request(
"POST",
"https://graph.whats91.com/api/v2/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())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/v2/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
Orders
Create a merchant draft order with catalog products or custom items.
List Orders
List and search orders for one sender with status, payment, source, and date filters.
Get Order
Read one tenant- and sender-scoped order with items, charges, events, payment, and readiness.
Send Order
Create and send the exact-amount WhatsApp payment request for an existing draft order.