Swagger Petstore - OpenAPI 3.0
POST/pet

Create a new pet in the store

Creates a new pet in the store. Supply name and photoUrls at minimum — category, tags, and status are optional. status must be one of available, pending, or sold if provided. Returns the created pet object with its generated identifier.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

6 body fields

Pet object to create. name and photoUrls are required.

idintegeroptional
The pet's unique identifier. Assigned by the store if omitted.
namestringrequired
The pet's name.
categoryobjectoptional
A category object containing an `id` and `name` for classification.
photoUrlsarray<string>required
Array of URLs pointing to pet photos. Must contain at least one URL.
tagsarray<object>optional
Array of tag objects, each with an `id` and `name` for labeling.
statusstringoptional
pet status in the store
Allowed:availablependingsold

4 status codes
200Returns the created pet object with all supplied fields and its assigned identifier.
idintegeroptional
namestringrequired
categoryobjectoptional
photoUrlsarray<string>required
tagsarray<object>optional
statusstringoptional
pet status in the store
Allowed:availablependingsold
400Returned when `name` or `photoUrls` is missing or malformed.
422Returned when the request body fails schema validation, such as an invalid `status` value or incorrect data type.
defaultUnexpected error

Error handling

Omitting name or photoUrls returns a 400. A 422 is returned when the request body fails validation — ensure photoUrls is a non-empty array of strings and status, if supplied, is one of the accepted values.