Skip to main content

Overview

The Pets API allows you to create, read, update, and delete pet records in your veterinary practice management system.

The Pet Object

id
string
required
Unique identifier for the pet
ownerId
string
required
ID of the pet owner (foreign key to owners table)
name
string
required
Pet’s name
species
enum
required
Species: cat, dog, bird, rabbit, reptile, exotic, other
breed
string
required
Pet’s breed
color
string
Pet’s color or markings
gender
enum
required
Gender: male, female, unknown
dateOfBirth
string
Birth date in ISO 8601 format (YYYY-MM-DD)
age
number
required
Pet’s age in years
weight
number
Current weight in kilograms
isNeutered
boolean
default:"false"
Whether the pet is neutered/spayed
isMicrochipped
boolean
default:"false"
Whether the pet has a microchip
microchipNumber
string
Microchip ID number
knownConditions
string[]
default:"[]"
List of known medical conditions
allergies
string[]
default:"[]"
List of known allergies
currentMedications
string[]
default:"[]"
List of current medications
dietNotes
string
Dietary information and restrictions
photos
PetPhoto[]
default:"[]"
Array of pet photos
primaryVetId
string
ID of the assigned primary veterinarian
lastVisit
string
Date of last veterinary visit
status
enum
default:"active"
Status: active, deceased, transferred
createdAt
string
Timestamp when the record was created
updatedAt
string
Timestamp when the record was last updated

PetPhoto Object

id
string
Photo unique identifier
url
string
Photo URL
caption
string
Optional photo caption
isPrimary
boolean
Whether this is the primary profile photo

List All Pets

curl -X GET http://localhost:3000/api/pets \
  -H "Authorization: Bearer $TOKEN"

Query Parameters

ownerId
string
Filter pets by owner ID
species
string
Filter by species (cat, dog, etc.)
status
string
default:"active"
Filter by status (active, deceased, transferred)
limit
number
default:"50"
Maximum number of results
offset
number
default:"0"
Number of results to skip

Response

[
  {
    "id": "pet-001",
    "ownerId": "owner-123",
    "name": "Buddy",
    "species": "dog",
    "breed": "Golden Retriever",
    "color": "Golden",
    "gender": "male",
    "dateOfBirth": "2018-05-15",
    "age": 6,
    "weight": 32.5,
    "isNeutered": true,
    "isMicrochipped": true,
    "microchipNumber": "985112345678901",
    "knownConditions": ["Hip dysplasia"],
    "allergies": ["Chicken"],
    "currentMedications": ["Carprofen 100mg daily"],
    "dietNotes": "Grain-free diet",
    "photos": [
      {
        "id": "photo-1",
        "url": "https://example.com/buddy.jpg",
        "isPrimary": true
      }
    ],
    "primaryVetId": "vet-001",
    "lastVisit": "2024-12-10",
    "status": "active",
    "createdAt": "2023-01-15T10:30:00Z",
    "updatedAt": "2024-12-10T14:20:00Z"
  }
]

Get Pet by ID

curl -X GET http://localhost:3000/api/pets/pet-001 \
  -H "Authorization: Bearer $TOKEN"

Path Parameters

id
string
required
The pet ID

Response

Returns a single pet object (same structure as list response).

Create Pet

curl -X POST http://localhost:3000/api/pets \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ownerId": "owner-123",
    "name": "Luna",
    "species": "cat",
    "breed": "Siamese",
    "gender": "female",
    "age": 3,
    "weight": 4.2,
    "isNeutered": true,
    "allergies": []
  }'

Request Body

ownerId
string
required
ID of the pet owner
name
string
required
Pet’s name
species
string
required
Species (cat, dog, bird, etc.)
breed
string
required
Pet’s breed
gender
string
required
Gender (male, female, unknown)
age
number
required
Age in years
weight
number
Weight in kilograms
color
string
Color or markings
dateOfBirth
string
Birth date (YYYY-MM-DD)
isNeutered
boolean
default:"false"
Neutered/spayed status
isMicrochipped
boolean
default:"false"
Microchip status
microchipNumber
string
Microchip ID
knownConditions
string[]
Medical conditions
allergies
string[]
Known allergies
currentMedications
string[]
Current medications

Response

Returns the created pet object with generated id, createdAt, and updatedAt fields.

Update Pet

curl -X PATCH http://localhost:3000/api/pets/pet-001 \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "weight": 33.0,
    "currentMedications": ["Carprofen 100mg daily", "Glucosamine"]
  }'

Path Parameters

id
string
required
The pet ID to update

Request Body

Accepts partial pet object. Only include fields you want to update.

Response

Returns the updated pet object.

Delete Pet

Deleting a pet is permanent and will also delete associated medical records and appointments.
curl -X DELETE http://localhost:3000/api/pets/pet-001 \
  -H "Authorization: Bearer $TOKEN"

Path Parameters

id
string
required
The pet ID to delete

Response

{
  "success": true,
  "message": "Pet deleted successfully"
}

Example: Complete Pet Management

import { petsApi } from '@/lib/api';

// Create a new pet
const newPet = await petsApi.create({
  ownerId: 'owner-456',
  name: 'Max',
  species: 'dog',
  breed: 'Labrador Retriever',
  gender: 'male',
  age: 2,
  weight: 28.5,
  isNeutered: false,
  allergies: ['Peanuts'],
  knownConditions: []
});

console.log('Created pet:', newPet.id);

// Update pet after neutering procedure
const updated = await petsApi.update(newPet.id, {
  isNeutered: true,
  weight: 27.8,
  currentMedications: ['Pain medication - 5 days']
});

// Get all pets for an owner
const ownerPets = await petsApi.getAll({ ownerId: 'owner-456' });
console.log(`Owner has ${ownerPets.length} pet(s)`);

// Mark pet as transferred to another practice
await petsApi.update(newPet.id, {
  status: 'transferred'
});

Error Handling

try {
  const pet = await petsApi.getById('invalid-id');
} catch (error) {
  if (error.status === 404) {
    console.error('Pet not found');
  } else if (error.status === 403) {
    console.error('Access denied');
  } else {
    console.error('API error:', error.message);
  }
}

Build docs developers (and LLMs) love