New in 2.4: Test runs you can trust See what's new →

Create a order

POSThttps://api.testingapis.com/api/Orders

Request body

Optional. application/json, text/json, application/*+json, application/xml, text/xml, application/*+xml. Model: Order. The new order. Any client-supplied ID is replaced.

Example body
{
  "userId": 104,
  "items": [{"productId": 2, "title": "Smartwatch Series 6", "quantity": 1, "price": 199.99}],
  "shippingAddress": {"street": "1 Main St", "city": "Pune", "state": "MH", "zip": "411001", "country": "IN"}
}

Responses

200
OK
201
Created; returns { message, data } with the generated ID.
400
items is missing or empty.
500
Unexpected server error.

Example

Request
curl -X POST "https://api.testingapis.com/api/Orders" \
  -H "Content-Type: application/json" \
  -d '{"userId": 104, "items": [{"productId": 2, "title": "Smartwatch Series 6", "quantity": 1, "price": 199.99}], "shippingAddress": {"street": "1 Main St", "city": "Pune", "state": "MH", "zip": "411001", "country": "IN"}}'
Run in Studio
Response201 Created
{
  "message": "Order created successfully",
  "data": {
    "id": 16,
    "userId": 104,
    "items": [{"productId": 2, "title": "Smartwatch Series 6", "quantity": 1, "price": 199.99}],
    "total": 199.99,
    "status": "pending",
    "shippingAddress": {"street": "1 Main St", "city": "Pune", "state": "MH", "zip": "411001", "country": "IN"},
    "orderedAt": "2026-09-30T18:26:45Z",
    "deliveredAt": null
  }
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/Orders", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: "{\"userId\": 104, \"items\": [{\"productId\": 2, \"title\": \"Smartwatch Series 6\", \"quantity\": 1, \"price\": 199.99}], \"shippingAddress\": {\"street\": \"1 Main St\", \"city\": \"Pune\", \"state\": \"MH\", \"zip\": \"411001\", \"country\": \"IN\"}}",
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "POST",
    "https://api.testingapis.com/api/Orders",
    headers={
        "Content-Type": "application/json",
    },
    data="{\"userId\": 104, \"items\": [{\"productId\": 2, \"title\": \"Smartwatch Series 6\", \"quantity\": 1, \"price\": 199.99}], \"shippingAddress\": {\"street\": \"1 Main St\", \"city\": \"Pune\", \"state\": \"MH\", \"zip\": \"411001\", \"country\": \"IN\"}}".encode("utf-8"),
    allow_redirects=False,
)
print(response.status_code, response.text)
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.testingapis.com/api/Orders"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString("{\"userId\": 104, \"items\": [{\"productId\": 2, \"title\": \"Smartwatch Series 6\", \"quantity\": 1, \"price\": 199.99}], \"shippingAddress\": {\"street\": \"1 Main St\", \"city\": \"Pune\", \"state\": \"MH\", \"zip\": \"411001\", \"country\": \"IN\"}}"))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}