Create an Order
Create an order for goods.
For services, see Create Subscription.
The payment method used in the process is the customer’s default payment method. See Pay an Order.
This method triggers the Order Created webhook. This webhook contains the same information as the response.
Code Samples
.NET
using System; using System.Text.Json; namespace RapydApiRequestSample { class Program { static void Main(string[] args) { try { var metadata = new { merchant_defined = true }; var items = new Object[] { new { type = "sku", currency = "USD", amount = 200, quantity = 2, parent = "sku_2cc9627661754e0a0b78397a62c9d9f2", description = "Deluxe Gamer's Chair", }, new { type = "shipping", amount = 10, currency = "USD", description = "Shipping", } }; var shipping_address = new { name = "John Doe", line_1 = "123 State Street", line_2 = "Apt. 34", line_3 = "", city = "Anytown", district = "", canton = "", state = "NY", country = "US", zip = "12345", phone_number = "12125559999", metadata, }; var requestObj = new { customer = "cus_c697782cd18d3862e40e991fe4f0ca34", currency = "USD", external_coupon_code = "squeee", items, shipping_address, tax_percent = 0, upstream_id = "GZC12345", email = "johndoe@rapyd.net", metadata, }; string request = JsonSerializer.Serialize(requestObj); string result = RapydApiRequestSample.Utilities.MakeRequest("POST", "/v1/orders", request); Console.WriteLine(result); } catch (Exception e) { Console.WriteLine("Error completing request: " + e.Message); } } } }
JavaScript
const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest; async function main() { try { const body = { customer: 'cus_c697782cd18d3862e40e991fe4f0ca34', currency: 'USD', external_coupon_code: 'squeee', items: [ { type: 'sku', currency: 'USD', amount: 200, quantity: 2, parent: 'sku_2cc9627661754e0a0b78397a62c9d9f2', description: "Deluxe Gamer's Chair" }, { type: 'shipping', amount: 10, currency: 'USD', description: 'Shipping' } ], shipping_address: { name: 'John Doe', line_1: '123 State Street', line_2: 'Apt. 34', line_3: '', city: 'Anytown', district: '', canton: '', state: 'NY', country: 'US', zip: '12345', phone_number: '12125559999', metadata: { merchant_defined: true } }, tax_percent: 0, upstream_id: 'GZC12345', email: 'johndoe@rapyd.net', metadata: { merchant_defined: true } }; const result = await makeRequest('POST', '/v1/orders', body); console.log(result); } catch (error) { console.error('Error completing request', error); } }
PHP
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/<path-to-your-utility-file>/utilities.php"; include($path); $body = [ "customer" => "cus_c697782cd18d3862e40e991fe4f0ca34", "currency" => "USD", "external_coupon_code" => "squeee", "items" => array( array( "type" => "sku", "currency" => "USD", "amount" => 200, "quantity" => 2, "parent" => "sku_2cc9627661754e0a0b78397a62c9d9f2", "description" => "Deluxe Gamer's Chair" ), array( "type" => "shipping", "amount" => 10, "currency" => "USD", "description" => "Shipping" ) ), "shipping_address" => array( "name" => "John Doe", "line_1" => "123 State Street", "line_2" => "Apt. 34", "line_3" => "", "city" => "Anytown", "district" => "", "canton" => "", "state" => "NY", "country" => "US", "zip" => "12345", "phone_number" => "12125559999", "metadata" => array( "merchant_defined" => true ) ) "tax_percent" => 0, "upstream_id" => "GZC12345", "email" => "johndoe@rapyd.net", "metadata" => array( "merchant_defined" => true ), ]; try { $object = make_request('post', '/v1/orders', $body); var_dump($object); } catch(Exception $e) { echo "Error => $e"; } ?>
Python
from pprint import pprint from utilities import make_request order = { "customer": "cus_c697782cd18d3862e40e991fe4f0ca34", "currency": "USD", "external_coupon_code": "squeee", "items": [ { "type": "sku", "currency": "USD", "amount": 200, "quantity": 2, "parent": "sku_2cc9627661754e0a0b78397a62c9d9f2", "description": "Deluxe Gamer's Chair" }, { "type": "shipping", "amount": 10, "currency": "USD", "description": "Shipping" } ], "shipping_address": { "name": "John Doe", "line_1": "123 State Street", "line_2": "Apt. 34", "line_3": "", "city": "Anytown", "district": "", "canton": "", "state": "NY", "country": "US", "zip": "12345", "phone_number": "12125559999", "metadata": { "merchant_defined": True } }, "tax_percent": 0, "upstream_id": "GZC12345", "email": "johndoe@rapyd.net", "metadata": { "merchant_defined": True } } result = make_request(method='post', path='/v1/orders', body=order) pprint(result)
/v1/orders
Create an Order
curl -X post 'https://sandboxapi.rapyd.net/v1/orders' \ -H 'access_key: your-access-key-here' \ -H 'Content-Type: application/json' \ -H 'idempotency: your-idempotency-parameter-here' \ -H 'salt: your-random-string-here' \ -H 'signature: your-calculated-signature-here' \ -H 'timestamp: your-unix-timestamp-here' \ --data-raw '{ "customer": "cus_4e25112ac20e144ad073a614dc46934b", "currency": "USD", "items": [ { "type": "sku", "currency": "USD", "amount": 200.00, "quantity": 2, "parent": "sku_6eb43887fd478baaf9223ec7ec17da21", "description": "Deluxe Gamer's Chair" }, { "type": "shipping", "amount": 10.00, "currency": "USD", "description": "Shipping" } ], "shipping_address": { "name": "John Doe", "line_1": "123 First Street", "city": "Anytown", "state": "NY", "country": "US", "zip": "12345", "phone_number": "12125559999" }, "upstream_id": "2025-11-18a", "email": "johndoe@rapyd.net" }'{ "status": { "error_code": "", "status": "SUCCESS", "message": "", "response_code": "", "operation_id": "187bffe8-4c0e-453a-91ab-4787ebee48cc" }, "data": { "id": "order_87b78d2923633ab410654749e8817895", "amount": 410, "amount_returned": 0, "payment": null, "created": 1763477605, "customer": "cus_4e25112ac20e144ad073a614dc46934b", "currency": "USD", "email": "johndoe@rapyd.net", "external_coupon_code": "", "items": [ { "amount": 200, "currency": "USD", "description": "Deluxe Gamer's Chair", "parent": "sku_6eb43887fd478baaf9223ec7ec17da21", "quantity": 2, "type": "sku" }, { "amount": 10, "currency": "USD", "description": "Shipping", "parent": "", "quantity": 1, "type": "shipping" } ], "metadata": {}, "returns": [], "shipping_address": { "id": "address_a2472851af98bf84b818e4ffdfed6b01", "name": "John Doe", "line_1": "123 First Street", "line_2": "", "line_3": "", "city": "Anytown", "state": "NY", "country": "US", "zip": "12345", "phone_number": "12125559999", "metadata": {}, "canton": "", "district": "", "created_at": 1763477606 }, "status": "created", "status_transitions": { "canceled": 0, "fulfilled": 0, "paid": 0, "returned": 0, "pending": 0, "partial": 0 }, "updated": 1763477605, "upstream_id": "2025-11-18a", "tax_percent": 0 } }
Bad Request - Currency Mismatch
curl -X post 'https://sandboxapi.rapyd.net/v1/orders' \ -H 'access_key: your-access-key-here' \ -H 'Content-Type: application/json' \ -H 'idempotency: your-idempotency-parameter-here' \ -H 'salt: your-random-string-here' \ -H 'signature: your-calculated-signature-here' \ -H 'timestamp: your-unix-timestamp-here' \ --data-raw '{ "customer": "cus_4e25112ac20e144ad073a614dc46934b", "currency": "USD", "items": [ { "type": "sku", "currency": "EUR", "amount": 200.00, "quantity": 2, "parent": "sku_6eb43887fd478baaf9223ec7ec17da21", "description": "Deluxe Gamer's Chair" }, { "type": "shipping", "amount": 10.00, "currency": "USD", "description": "Shipping" } ], "shipping_address": { "name": "John Doe", "line_1": "123 First Street", "city": "Anytown", "state": "NY", "country": "US", "zip": "12345", "phone_number": "12125559999" }, "upstream_id": "2025-11-18a", "email": "johndoe@rapyd.net" }'{ "status": { "error_code": "ERROR_INVALID_ORDER_CURRENCY", "status": "ERROR", "message": "The request tried to create an order, but the currency of the order items did not match the currency of the order. The request was rejected. Corrective action: For 'currency' in each object in the 'items' array, use the currency of the order.", "response_code": "ERROR_INVALID_ORDER_CURRENCY", "operation_id": "76b1dab8-cc7e-4035-9a3c-792c21bef676" } }
Bad Request - Item Type Not Valid
curl -X post 'https://sandboxapi.rapyd.net/v1/orders' \ -H 'access_key: your-access-key-here' \ -H 'Content-Type: application/json' \ -H 'idempotency: your-idempotency-parameter-here' \ -H 'salt: your-random-string-here' \ -H 'signature: your-calculated-signature-here' \ -H 'timestamp: your-unix-timestamp-here' \ --data-raw '{ "customer": "cus_4e25112ac20e144ad073a614dc46934b", "currency": "USD", "items": [ { "type": "skew", "currency": "USD", "amount": 200.00, "quantity": 2, "parent": "sku_6eb43887fd478baaf9223ec7ec17da21", "description": "Deluxe Gamer's Chair" }, { "type": "shipping", "amount": 10.00, "currency": "USD", "description": "Shipping" } ], "shipping_address": { "name": "John Doe", "line_1": "123 First Street", "city": "Anytown", "state": "NY", "country": "US", "zip": "12345", "phone_number": "12125559999" }, "upstream_id": "2025-11-18a", "email": "johndoe@rapyd.net" }'{ "status": { "error_code": "ERROR_ORDER_ITEM_INVALID_TYPE", "status": "ERROR", "message": "The request tried to create an order, but the 'type' of an order item was not recognized. The request was rejected. Corrective action: Set 'type' to one of the following values: 'sku' or 'shipping'.", "response_code": "ERROR_ORDER_ITEM_INVALID_TYPE", "operation_id": "6e71aa87-c2a1-4a08-bca4-66eee2000e28" } }