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

Create a product

POSThttps://api.testingapis.com/api/Products

Request body

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

Example body
{
  "title": "Wireless Noise-Cancelling Headphones",
  "price": 249.99,
  "description": "Over-ear headphones with 30hr battery life and active noise cancellation.",
  "category": "electronics",
  "image": "https://picsum.photos/seed/prod1/400/400",
  "rating": {"rate": 4.3, "count": 127},
  "inStock": true,
  "createdAt": "2025-06-12T10:30:00Z"
}

Responses

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

Example

Request
curl -X POST "https://api.testingapis.com/api/Products" \
  -H "Content-Type: application/json" \
  -d '{"title": "Wireless Noise-Cancelling Headphones", "price": 249.99, "description": "Over-ear headphones with 30hr battery life and active noise cancellation.", "category": "electronics", "image": "https://picsum.photos/seed/prod1/400/400", "rating": {"rate": 4.3, "count": 127}, "inStock": true, "createdAt": "2025-06-12T10:30:00Z"}'
Run in Studio
Response201 Created
{
  "message": "Product created successfully",
  "data": {
    "id": 24,
    "title": "Wireless Noise-Cancelling Headphones",
    "price": 249.99,
    "description": "Over-ear headphones with 30hr battery life and active noise cancellation.",
    "category": "electronics",
    "image": "https://picsum.photos/seed/prod1/400/400",
    "rating": {"rate": 4.3, "count": 127},
    "inStock": true,
    "createdAt": "2025-06-12T10:30:00Z"
  }
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/Products", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: "{\"title\": \"Wireless Noise-Cancelling Headphones\", \"price\": 249.99, \"description\": \"Over-ear headphones with 30hr battery life and active noise cancellation.\", \"category\": \"electronics\", \"image\": \"https://picsum.photos/seed/prod1/400/400\", \"rating\": {\"rate\": 4.3, \"count\": 127}, \"inStock\": true, \"createdAt\": \"2025-06-12T10:30:00Z\"}",
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "POST",
    "https://api.testingapis.com/api/Products",
    headers={
        "Content-Type": "application/json",
    },
    data="{\"title\": \"Wireless Noise-Cancelling Headphones\", \"price\": 249.99, \"description\": \"Over-ear headphones with 30hr battery life and active noise cancellation.\", \"category\": \"electronics\", \"image\": \"https://picsum.photos/seed/prod1/400/400\", \"rating\": {\"rate\": 4.3, \"count\": 127}, \"inStock\": true, \"createdAt\": \"2025-06-12T10:30:00Z\"}".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/Products"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString("{\"title\": \"Wireless Noise-Cancelling Headphones\", \"price\": 249.99, \"description\": \"Over-ear headphones with 30hr battery life and active noise cancellation.\", \"category\": \"electronics\", \"image\": \"https://picsum.photos/seed/prod1/400/400\", \"rating\": {\"rate\": 4.3, \"count\": 127}, \"inStock\": true, \"createdAt\": \"2025-06-12T10:30:00Z\"}"))
            .build();

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