{
  "openapi": "3.1.0",
  "info": {
    "title": "Pet Cheri Hotel API",
    "version": "1.0.0",
    "description": "Send your guests' pet-care requests (walk, in-room sitting, visit, grooming, vet escort) from your hotel's own system. A Pet Cheri concierge confirms the pet sitter and the time; your front desk receives the confirmation by email and the status is available here. Requests are billed to the hotel each month.",
    "contact": { "name": "Pet Cheri", "url": "https://petcheri.com/contact" }
  },
  "servers": [
    { "url": "https://api.petcheri.com/v1", "description": "Production" },
    { "url": "https://app.petcheri.com/api/partners/v1", "description": "Production (same API, application domain)" }
  ],
  "security": [{ "bearerAuth": [] }],
  "paths": {
    "/me": {
      "get": {
        "summary": "Check your key",
        "description": "Returns the hotel the key belongs to, the services open to your guests and today's request count. A good first call for an integration.",
        "operationId": "getMe",
        "responses": {
          "200": {
            "description": "Your hotel",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Me" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/requests": {
      "post": {
        "summary": "Create a request",
        "description": "Creates a request for one pet and one service. Send an `externalRef` (your booking or folio id): sending the same `externalRef` again returns the request already created, with HTTP 200, instead of a duplicate. The time is at least 1 hour and at most 30 days ahead, on the half hour, between 07:00 and 22:00, Paris time.",
        "operationId": "createRequest",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateRequest" } } }
        },
        "responses": {
          "201": {
            "description": "Request created",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreatedRequest" } } }
          },
          "200": {
            "description": "A request with this `externalRef` already exists: it is returned unchanged",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreatedRequest" } } }
          },
          "400": {
            "description": "Missing or invalid fields",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ValidationError" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/requests/{id}": {
      "get": {
        "summary": "Get a request's status",
        "description": "Returns the status of one of your requests. Once confirmed, it gives the pet sitter's first name and the time of the first visit.",
        "operationId": "getRequest",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "description": "The `id` returned at creation, or your `externalRef` with `?by=externalRef`", "schema": { "type": "string" } },
          { "name": "by", "in": "query", "required": false, "schema": { "type": "string", "enum": ["externalRef"] } }
        ],
        "responses": {
          "200": {
            "description": "The request",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Request" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your hotel's API key, given by Pet Cheri: `Authorization: Bearer pch_live_...`. Keep it on your server, never in a web page."
      }
    },
    "schemas": {
      "Service": {
        "type": "string",
        "enum": ["walk", "room", "visit", "grooming", "vet"],
        "description": "walk: one-hour walk. room: in-room sitting, up to three hours. visit: 30-minute visit. grooming: on-site grooming. vet: escort to the vet and back."
      },
      "Species": { "type": "string", "enum": ["dog", "cat", "nac"] },
      "Size": { "type": "string", "enum": ["small", "medium", "large"], "description": "Dogs only." },
      "NacType": {
        "type": "string",
        "enum": ["RABBIT", "GUINEA_PIG", "FERRET", "HAMSTER", "PARROT", "TURTLE", "OTHER_ANIMAL_TYPE"],
        "description": "When `species` is `nac`. Anything else is stored as OTHER_ANIMAL_TYPE."
      },
      "Status": {
        "type": "string",
        "enum": ["received", "confirmed", "cancelled"],
        "description": "received: waiting for a Pet Cheri concierge. confirmed: a pet sitter is booked. cancelled: the request will not be served."
      },
      "CreateRequest": {
        "type": "object",
        "required": ["service", "guest", "pet", "guestConsent"],
        "properties": {
          "externalRef": { "type": "string", "maxLength": 100, "description": "Your own id for this request. Strongly recommended: makes retries safe." },
          "service": { "$ref": "#/components/schemas/Service" },
          "wantedAt": { "type": "string", "format": "date-time", "description": "Start time, ISO 8601 with offset. Or send `date` and `time` (Paris time) instead.", "example": "2026-12-01T09:00:00+01:00" },
          "date": { "type": "string", "format": "date", "example": "2026-12-01" },
          "time": { "type": "string", "pattern": "^([01]\\d|2[0-3]):(00|30)$", "example": "09:00" },
          "guest": {
            "type": "object",
            "required": ["name", "room"],
            "properties": {
              "name": { "type": "string", "maxLength": 120, "example": "Mr Dupont" },
              "room": { "type": "string", "maxLength": 20, "example": "412" },
              "phone": { "type": "string", "maxLength": 30, "description": "Optional. Otherwise the concierge goes through the front desk." }
            }
          },
          "pet": {
            "type": "object",
            "required": ["name", "species"],
            "properties": {
              "name": { "type": "string", "maxLength": 60, "example": "Max" },
              "species": { "$ref": "#/components/schemas/Species" },
              "nacType": { "$ref": "#/components/schemas/NacType" },
              "breed": { "type": "string", "maxLength": 80, "example": "Bichon" },
              "size": { "$ref": "#/components/schemas/Size" }
            }
          },
          "notes": { "type": "string", "maxLength": 1000, "example": "Pulls on the leash." },
          "guestConsent": { "type": "boolean", "const": true, "description": "You confirm the guest agreed that Pet Cheri receives this information to organise the service." }
        }
      },
      "CreatedRequest": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "externalRef": { "type": ["string", "null"] },
          "status": { "$ref": "#/components/schemas/Status" },
          "wantedAt": { "type": "string", "format": "date-time" },
          "sandbox": { "type": "boolean", "description": "Present and true for a demo hotel: nothing was stored." }
        }
      },
      "Request": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "externalRef": { "type": ["string", "null"] },
          "status": { "$ref": "#/components/schemas/Status" },
          "pro": {
            "type": ["object", "null"],
            "properties": { "firstName": { "type": "string", "example": "Léa" } }
          },
          "slot": {
            "type": ["object", "null"],
            "properties": {
              "start": { "type": "string", "format": "date-time" },
              "end": { "type": "string", "format": "date-time" }
            }
          },
          "wantedAt": { "type": ["string", "null"], "format": "date-time" },
          "updatedAt": { "type": "string", "format": "date-time" }
        }
      },
      "Me": {
        "type": "object",
        "properties": {
          "hotel": { "type": "object", "properties": { "slug": { "type": "string" }, "name": { "type": "string" } } },
          "services": { "type": "array", "items": { "$ref": "#/components/schemas/Service" } },
          "dailyCap": { "type": "integer" },
          "todayCount": { "type": "integer" },
          "sandbox": { "type": "boolean" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "string", "enum": ["UNAUTHORIZED", "INVALID", "NOT_FOUND", "RATE_LIMIT", "DAILY_CAP", "SERVER_ERROR"] },
              "message": { "type": "string" }
            }
          }
        }
      },
      "ValidationError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "string", "const": "INVALID" },
              "message": { "type": "string" },
              "fields": {
                "type": "object",
                "additionalProperties": {
                  "type": "string",
                  "enum": ["REQUIRED", "INVALID", "CONSENT_REQUIRED", "INVALID_DATE", "INVALID_TIME", "PAST", "TOO_SOON", "TOO_FAR"]
                },
                "example": { "guest.room": "REQUIRED", "wantedAt": "TOO_SOON" }
              }
            }
          }
        }
      }
    },
    "responses": {
      "Unauthorized": { "description": "Missing, invalid or revoked key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "NotFound": { "description": "No such request for this hotel", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "TooManyRequests": { "description": "More than 60 calls per minute (RATE_LIMIT), or the hotel's daily request limit is reached (DAILY_CAP)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    }
  }
}
