Skip to main content
POST
/
pets
TypeScript SDK
import { PetStoreAPI } from '@petstoreapi/sdk';

const client = new PetStoreAPI({
  accessToken: process.env.OAUTH_ACCESS_TOKEN
});

const newPet = await client.pets.create({
  species: 'dog',
  name: 'Buddy',
  breed: 'Golden Retriever',
  ageMonths: 24,
  size: 'large',
  color: 'Golden',
  gender: 'male',
  goodWithKids: true,

  price: '150.00',
  description: 'Friendly golden retriever looking for an active family'
});

console.log(`Created pet with ID: ${newPet.id}`);
from petstore import PetStoreAPI

client = PetStoreAPI(access_token=os.environ['OAUTH_ACCESS_TOKEN'])

new_pet = client.pets.create(
species='dog',
name='Buddy',
breed='Golden Retriever',
ageMonths=24,
size='large',
color='Golden',
gender='male',
goodWithKids=True,

price='150.00',
description='Friendly golden retriever looking for an active family'
)

print(f"Created pet with ID: {new_pet.id}")
const response = await fetch(
'https://api.petstoreapi.com/v1/pets',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
species: 'dog',
name: 'Buddy',
breed: 'Golden Retriever',
ageMonths: 24,
size: 'large',
color: 'Golden',
gender: 'male',
goodWithKids: true,

price: '150.00',
description: 'Friendly golden retriever looking for an active family'
})
}
);

const newPet = await response.json();
console.log(`Created pet with ID: ${newPet.id}`);
curl -X POST 'https://api.petstoreapi.com/v1/pets' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"species": "dog",
"name": "Buddy",
"breed": "Golden Retriever",
"ageMonths": 24,
"size": "large",
"color": "Golden",
"gender": "male",
"goodWithKids": true,

"price": "150.00",
"description": "Friendly golden retriever looking for an active family"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.petstoreapi.com/v1/pets",
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([
'name' => 'Max',
'species' => 'DOG',
'breed' => 'Golden Retriever',
'ageMonths' => 24,
'size' => 'LARGE',
'color' => 'Golden',
'gender' => 'MALE',
'goodWithKids' => true,
'price' => '250.00',
'currency' => 'USD',
'status' => 'AVAILABLE',
'description' => 'Friendly golden retriever looking for an active family',
'medicalInfo' => [
'vaccinated' => true,
'spayedNeutered' => true,
'microchipped' => true,
'specialNeeds' => false,
'healthNotes' => 'Up to date on all vaccinations'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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/pets"

payload := strings.NewReader("{\n \"name\": \"Max\",\n \"species\": \"DOG\",\n \"breed\": \"Golden Retriever\",\n \"ageMonths\": 24,\n \"size\": \"LARGE\",\n \"color\": \"Golden\",\n \"gender\": \"MALE\",\n \"goodWithKids\": true,\n \"price\": \"250.00\",\n \"currency\": \"USD\",\n \"status\": \"AVAILABLE\",\n \"description\": \"Friendly golden retriever looking for an active family\",\n \"medicalInfo\": {\n \"vaccinated\": true,\n \"spayedNeutered\": true,\n \"microchipped\": true,\n \"specialNeeds\": false,\n \"healthNotes\": \"Up to date on all vaccinations\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
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/pets")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Max\",\n \"species\": \"DOG\",\n \"breed\": \"Golden Retriever\",\n \"ageMonths\": 24,\n \"size\": \"LARGE\",\n \"color\": \"Golden\",\n \"gender\": \"MALE\",\n \"goodWithKids\": true,\n \"price\": \"250.00\",\n \"currency\": \"USD\",\n \"status\": \"AVAILABLE\",\n \"description\": \"Friendly golden retriever looking for an active family\",\n \"medicalInfo\": {\n \"vaccinated\": true,\n \"spayedNeutered\": true,\n \"microchipped\": true,\n \"specialNeeds\": false,\n \"healthNotes\": \"Up to date on all vaccinations\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.petstoreapi.com/v1/pets")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Max\",\n \"species\": \"DOG\",\n \"breed\": \"Golden Retriever\",\n \"ageMonths\": 24,\n \"size\": \"LARGE\",\n \"color\": \"Golden\",\n \"gender\": \"MALE\",\n \"goodWithKids\": true,\n \"price\": \"250.00\",\n \"currency\": \"USD\",\n \"status\": \"AVAILABLE\",\n \"description\": \"Friendly golden retriever looking for an active family\",\n \"medicalInfo\": {\n \"vaccinated\": true,\n \"spayedNeutered\": true,\n \"microchipped\": true,\n \"specialNeeds\": false,\n \"healthNotes\": \"Up to date on all vaccinations\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "name": "<string>",
  "ageMonths": 1,
  "price": "<string>",
  "currency": "USD",
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z",
  "breed": "<string>",
  "color": "<string>",
  "goodWithKids": true,
  "description": "<string>",
  "tenantId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "photos": [
    "<string>"
  ],
  "medicalInfo": {
    "spayedNeutered": true,
    "vaccinated": true,
    "microchipped": true,
    "specialNeeds": true,
    "healthNotes": "<string>"
  }
}
{
"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/unauthorized",
"title": "Unauthorized",
"status": 401,
"detail": "Authentication is required to access this resource. Please provide a valid OAuth 2.0 token."
}
{
"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"
}
]
}
{
"type": "https://petstoreapi.com/errors/rate-limit-exceeded",
"title": "Too Many Requests",
"status": 429,
"detail": "Rate limit exceeded. Please wait 60 seconds before making another request."
}

Authorizations

Authorization
string
header
required

Bearer token authentication using JWT (JSON Web Token). Include the token in the Authorization header as: Authorization: Bearer <token>

Headers

X-Tenant-ID
string<uuid>

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

application/json

Animal information in the pet store available for adoption.

species
enum<string>
required

The species of the pet

Available options:
DOG,
CAT,
RABBIT,
BIRD,
REPTILE,
OTHER
name
string
required

The pet's name

Required string length: 1 - 50
Examples:

"Whiskers"

"Max"

"Luna"

ageMonths
integer
required

Age of the pet in months

Required range: x >= 0
Examples:

18

36

6

price
string
required

Adoption fee amount

Examples:

"75.00"

"150.00"

"50.00"

currency
string
default:USD
required

Currency code for the adoption fee (ISO 4217)

Pattern: ^[A-Z]{3}$
Examples:

"USD"

"EUR"

"GBP"

status
enum<string>
required

Current adoption status

Available options:
AVAILABLE,
PENDING,
ADOPTED,
NOT_AVAILABLE
breed
string

The breed of the pet

Examples:

"Domestic Shorthair"

"Labrador Retriever"

"Holland Lop"

size
enum<string>

Size category of the pet

Available options:
SMALL,
MEDIUM,
LARGE
color
string

Primary color or coloring pattern

Examples:

"Orange Tabby"

"Black"

"Brown and White"

gender
enum<string>

The pet's gender

Available options:
MALE,
FEMALE,
UNKNOWN
goodWithKids
boolean

Whether the pet is good with children

description
string

Detailed description of the pet's personality and traits

photos
string<uri>[]

URLs of pet photos

medicalInfo
object

Response

Pet created successfully

Animal information in the pet store available for adoption.

id
string<uuid>
required
read-only

Unique identifier for the pet (UUID v7)

Examples:

"019b4132-70aa-764f-b315-e2803d882a24"

"019b4127-54d5-76d9-b626-0d4c7bfce5b6"

species
enum<string>
required

The species of the pet

Available options:
DOG,
CAT,
RABBIT,
BIRD,
REPTILE,
OTHER
name
string
required

The pet's name

Required string length: 1 - 50
Examples:

"Whiskers"

"Max"

"Luna"

ageMonths
integer
required

Age of the pet in months

Required range: x >= 0
Examples:

18

36

6

price
string
required

Adoption fee amount

Examples:

"75.00"

"150.00"

"50.00"

currency
string
default:USD
required

Currency code for the adoption fee (ISO 4217)

Pattern: ^[A-Z]{3}$
Examples:

"USD"

"EUR"

"GBP"

status
enum<string>
required

Current adoption status

Available options:
AVAILABLE,
PENDING,
ADOPTED,
NOT_AVAILABLE
createdAt
string<date-time>
required
read-only

Timestamp when the pet record was created (RFC 3339)

Examples:

"2025-12-21T13:56:23Z"

"2025-11-15T08:30:00Z"

updatedAt
string<date-time>
required
read-only

Timestamp when the pet record was last updated (RFC 3339)

Examples:

"2025-12-21T13:56:23Z"

"2025-12-21T15:30:45Z"

breed
string

The breed of the pet

Examples:

"Domestic Shorthair"

"Labrador Retriever"

"Holland Lop"

size
enum<string>

Size category of the pet

Available options:
SMALL,
MEDIUM,
LARGE
color
string

Primary color or coloring pattern

Examples:

"Orange Tabby"

"Black"

"Brown and White"

gender
enum<string>

The pet's gender

Available options:
MALE,
FEMALE,
UNKNOWN
goodWithKids
boolean

Whether the pet is good with children

description
string

Detailed description of the pet's personality and traits

tenantId
string<uuid> | null
read-only

Optional tenant identifier for data isolation. When present, indicates this pet belongs to a specific tenant. Null or omitted means the pet is in the shared/public data pool.

Examples:

"550e8400-e29b-41d4-a716-446655440000"

"7c9e6679-7425-40de-944b-e07fc1f90ae7"

photos
string<uri>[]

URLs of pet photos

medicalInfo
object