import { PetStoreAPI } from '@petstoreapi/sdk';
const client = new PetStoreAPI({
accessToken: process.env.OAUTH_ACCESS_TOKEN
});
const order = await client.orders.create({
petId: 90180021,
quantity: 1,
shipDate: '2025-08-15',
status: 'placed'
});
console.log(`Order ${order.id} created successfully`);from petstore import PetStoreAPI
client = PetStoreAPI(access_token=os.environ['OAUTH_ACCESS_TOKEN'])
order = client.orders.create(
petId=90180021,
quantity=1,
shipDate='2025-08-15',
status='placed'
)
print(f"Order {order.id} created successfully")const response = await fetch(
'https://api.petstoreapi.com/v1/orders',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
petId: 90180021,
quantity: 1,
shipDate: '2025-08-15',
status: 'placed'
})
}
);
const order = await response.json();
console.log(`Order ${order.id} created successfully`);curl -X POST 'https://api.petstoreapi.com/v1/orders' \
-H 'Content-Type: application/json' \
-d '{
"petId": 90180021,
"quantity": 1,
"shipDate": "2025-08-15",
"status": "placed"
}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.petstoreapi.com/v1/orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'petId' => '019b4132-70aa-764f-b315-e2803d882a24',
'userId' => '019b4138-e0af-70b9-8f0c-6ea97d495dfa'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.petstoreapi.com/v1/orders"
payload := strings.NewReader("{\n \"petId\": \"019b4132-70aa-764f-b315-e2803d882a24\",\n \"userId\": \"019b4138-e0af-70b9-8f0c-6ea97d495dfa\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.petstoreapi.com/v1/orders")
.header("Content-Type", "application/json")
.body("{\n \"petId\": \"019b4132-70aa-764f-b315-e2803d882a24\",\n \"userId\": \"019b4138-e0af-70b9-8f0c-6ea97d495dfa\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.petstoreapi.com/v1/orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"petId\": \"019b4132-70aa-764f-b315-e2803d882a24\",\n \"userId\": \"019b4138-e0af-70b9-8f0c-6ea97d495dfa\"\n}"
response = http.request(request)
puts response.read_body{
"id": 44524671,
"petId": 90180021,
"quantity": 23,
"shipDate": "2025-08-15",
"status": "placed",
"complete": false
}{
"type": "https://petstoreapi.com/errors/bad-request",
"title": "Bad Request",
"status": 400,
"detail": "Invalid value for parameter 'status'. Must be one of: available, pending, sold.",
"instance": "/pets"
}{
"type": "https://petstoreapi.com/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "The requested pet with ID '123' was not found.",
"instance": "/pets/123"
}{
"type": "https://petstoreapi.com/errors/validation-error",
"title": "Validation Error",
"status": 422,
"detail": "The request body contains validation errors.",
"instance": "/pets",
"errors": [
{
"field": "name",
"message": "Pet name is required",
"code": "required_field"
},
{
"field": "status",
"message": "Invalid status value",
"code": "invalid_format"
}
]
}Create Order
Create a new order in the store.
import { PetStoreAPI } from '@petstoreapi/sdk';
const client = new PetStoreAPI({
accessToken: process.env.OAUTH_ACCESS_TOKEN
});
const order = await client.orders.create({
petId: 90180021,
quantity: 1,
shipDate: '2025-08-15',
status: 'placed'
});
console.log(`Order ${order.id} created successfully`);from petstore import PetStoreAPI
client = PetStoreAPI(access_token=os.environ['OAUTH_ACCESS_TOKEN'])
order = client.orders.create(
petId=90180021,
quantity=1,
shipDate='2025-08-15',
status='placed'
)
print(f"Order {order.id} created successfully")const response = await fetch(
'https://api.petstoreapi.com/v1/orders',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
petId: 90180021,
quantity: 1,
shipDate: '2025-08-15',
status: 'placed'
})
}
);
const order = await response.json();
console.log(`Order ${order.id} created successfully`);curl -X POST 'https://api.petstoreapi.com/v1/orders' \
-H 'Content-Type: application/json' \
-d '{
"petId": 90180021,
"quantity": 1,
"shipDate": "2025-08-15",
"status": "placed"
}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.petstoreapi.com/v1/orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'petId' => '019b4132-70aa-764f-b315-e2803d882a24',
'userId' => '019b4138-e0af-70b9-8f0c-6ea97d495dfa'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.petstoreapi.com/v1/orders"
payload := strings.NewReader("{\n \"petId\": \"019b4132-70aa-764f-b315-e2803d882a24\",\n \"userId\": \"019b4138-e0af-70b9-8f0c-6ea97d495dfa\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.petstoreapi.com/v1/orders")
.header("Content-Type", "application/json")
.body("{\n \"petId\": \"019b4132-70aa-764f-b315-e2803d882a24\",\n \"userId\": \"019b4138-e0af-70b9-8f0c-6ea97d495dfa\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.petstoreapi.com/v1/orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"petId\": \"019b4132-70aa-764f-b315-e2803d882a24\",\n \"userId\": \"019b4138-e0af-70b9-8f0c-6ea97d495dfa\"\n}"
response = http.request(request)
puts response.read_body{
"id": 44524671,
"petId": 90180021,
"quantity": 23,
"shipDate": "2025-08-15",
"status": "placed",
"complete": false
}{
"type": "https://petstoreapi.com/errors/bad-request",
"title": "Bad Request",
"status": 400,
"detail": "Invalid value for parameter 'status'. Must be one of: available, pending, sold.",
"instance": "/pets"
}{
"type": "https://petstoreapi.com/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "The requested pet with ID '123' was not found.",
"instance": "/pets/123"
}{
"type": "https://petstoreapi.com/errors/validation-error",
"title": "Validation Error",
"status": 422,
"detail": "The request body contains validation errors.",
"instance": "/pets",
"errors": [
{
"field": "name",
"message": "Pet name is required",
"code": "required_field"
},
{
"field": "status",
"message": "Invalid status value",
"code": "invalid_format"
}
]
}Headers
Optional tenant identifier for data isolation. When provided, all operations will be scoped to this tenant, ensuring data separation between different organizations or users. If omitted, operations will access the shared/public data pool where data may be visible to and modified by other users.
Body
Pet store order details
ID of the pet being ordered
"019b4132-70aa-764f-b315-e2803d882a24"
"019b4127-54d5-76d9-b626-0d4c7bfce5b6"
ID of the user placing the order
"019b4138-e0af-70b9-8f0c-6ea97d495dfa"
"019b4128-6a6b-777c-9ae8-335e962c68d8"
Order status
PLACED, APPROVED, SHIPPED, DELIVERED, CANCELLED "PLACED"
"APPROVED"
Total order amount
"125.50"
"75.00"
"200.99"
Currency code for the order amount (ISO 4217)
^[A-Z]{3}$"USD"
"EUR"
"GBP"
Response
Operation successful
Pet store order details
Unique order identifier (UUID v7)
"019b4139-1234-7abc-8def-123456789abc"
"019b4127-5678-7def-9012-234567890def"
ID of the pet being ordered
"019b4132-70aa-764f-b315-e2803d882a24"
"019b4127-54d5-76d9-b626-0d4c7bfce5b6"
ID of the user placing the order
"019b4138-e0af-70b9-8f0c-6ea97d495dfa"
"019b4128-6a6b-777c-9ae8-335e962c68d8"
Order status
PLACED, APPROVED, SHIPPED, DELIVERED, CANCELLED "PLACED"
"APPROVED"
Total order amount
"125.50"
"75.00"
"200.99"
Currency code for the order amount (ISO 4217)
^[A-Z]{3}$"USD"
"EUR"
"GBP"
Order creation timestamp (RFC 3339)
"2025-12-21T13:56:23Z"
"2025-11-15T08:30:00Z"
Order last update timestamp (RFC 3339)
"2025-12-21T13:56:23Z"
"2025-12-21T15:30:45Z"
Optional tenant identifier for data isolation. When present, indicates this order belongs to a specific tenant. Null or omitted means the order is in the shared/public data pool.
"550e8400-e29b-41d4-a716-446655440000"
"7c9e6679-7425-40de-944b-e07fc1f90ae7"