# Loki API: full reference > REST API for pet profiles, care calendars, journals and photos. Base URL: https://app.loki.pet/public-api/v1 Today, each API key works with the pets on the Loki account it belongs to. Access for your own app's users is planned. ## Security rules - Call the API from your server, never from a browser or a mobile app bundle. - Store the key in an environment variable such as LOKI_API_KEY. Never put it in code, logs or version control. - A key acts on the pets of the one Loki account it belongs to. Treat it like a database password. - Request only the scopes you need. ## Authentication Send your key in the `X-API-Key` header on every request. Keys look like `loki_...`. A missing or invalid key returns 401: ```json { "error": "unauthorized", "message": "Missing X-API-Key header." } ``` ## Scopes - `pets:read`: List and view pets. - `pets:write`: Create, update and delete pets. - `care:read`: List and view care items. - `care:write`: Create, update and delete care items. - `journal:read`: List and view journal entries. - `photos:read`: List and view photos. ## Rate limits 60 requests per minute per key, plus a per-IP limit. Exceeding it returns 429 rate_limited. - `RateLimit-Limit`: Requests allowed in the current window. - `RateLimit-Remaining`: Requests left in the current window. - `RateLimit-Reset`: Seconds until the window resets. - `Retry-After`: Only on a 429 response: seconds to wait before retrying. ## Pagination List endpoints accept `limit` (1 to 200, default 50) and `offset` (default 0). List responses: ```json { "data": [ "..." ], "meta": { "total": 42, "limit": 50, "offset": 0 } } ``` Single responses: ```json { "data": { "...": "..." } } ``` ```ts export interface Page { data: T[]; meta: { total: number; limit: number; offset: number }; } ``` ## Errors Errors are returned as `{ "error": code, "message": text }`. - 400 `invalid_request`: The body failed validation. The message lists the fields. - 401 `unauthorized`: The X-API-Key header is missing or the key is invalid. - 403 `forbidden`: The key lacks the scope this endpoint needs. - 404 `not_found`: The resource does not exist or is not owned by the key's account. - 429 `rate_limited`: Too many requests. Wait for Retry-After seconds, then retry. - 500 `server_error`: Something went wrong on our side. ## Endpoints ### Pets Pet profiles. Each pet belongs to the account that owns the key. Model: ```ts export interface Pet { id: string; name: string; description: string; type?: string; breed?: string; dateOfBirth?: string; // YYYY-MM-DD weight?: string; // "9kg" sex?: "male" | "female" | "unknown"; } ``` #### GET /pets: List pets Returns the pets on the key's account. Required scope: `pets:read` Query parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | limit | integer | no | Items per page, 1 to 200. Default 50. | | offset | integer | no | Items to skip. Default 0. | cURL: ```bash curl "https://app.loki.pet/public-api/v1/pets" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/pets", { headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "data": [ { "id": "a1b2c3d4-...", "name": "Luna", "type": "dog", "breed": "Labrador Retriever", "description": "Loves fetch and belly rubs", "dateOfBirth": "2022-03-15", "weight": "28kg", "sex": "female" } ], "meta": { "total": 1, "limit": 50, "offset": 0 } } ``` #### GET /pets/:id: Get a pet Returns one pet. Required scope: `pets:read` Path parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | yes | The pet id. | cURL: ```bash curl "https://app.loki.pet/public-api/v1/pets/PET_ID" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/pets/PET_ID", { headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "data": { "id": "a1b2c3d4-...", "name": "Luna", "type": "dog", "breed": "Labrador Retriever", "description": "Loves fetch and belly rubs", "dateOfBirth": "2022-03-15", "weight": "28kg", "sex": "female" } } ``` #### POST /pets: Create a pet Creates a pet on the key's account. name and description are required. Required scope: `pets:write` Body (JSON): | Name | Type | Required | Description | | --- | --- | --- | --- | | name | string | yes | 1 to 100 characters. | | description | string | yes | 1 to 500 characters. | | type | string | no | For example dog or cat. | | breed | string | no | Up to 100 characters. | | dateOfBirth | string (YYYY-MM-DD) | no | Date of birth. | | weight | string | no | A string with its unit, for example "28kg". | | sex | enum | no | male, female or unknown. | cURL: ```bash curl -X POST "https://app.loki.pet/public-api/v1/pets" \ -H "X-API-Key: $LOKI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Milo", "description": "Indoor cat, very curious", "type": "cat", "breed": "Maine Coon" }' ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/pets", { method: "POST", headers: { "X-API-Key": process.env.LOKI_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ "name": "Milo", "description": "Indoor cat, very curious", "type": "cat", "breed": "Maine Coon" }), }); const json = await res.json(); ``` Example response: ```json { "data": { "id": "e5f6a7b8-...", "name": "Milo", "type": "cat", "breed": "Maine Coon", "description": "Indoor cat, very curious" } } ``` #### PUT /pets/:id: Update a pet Updates a pet. Same fields as creating, all optional. Required scope: `pets:write` Path parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | yes | The pet id. | Body (JSON): | Name | Type | Required | Description | | --- | --- | --- | --- | | name | string | no | 1 to 100 characters. | | description | string | no | 1 to 500 characters. | | type | string | no | For example dog or cat. | | breed | string | no | Up to 100 characters. | | dateOfBirth | string (YYYY-MM-DD) | no | Date of birth. | | weight | string | no | A string with its unit, for example "28kg". | | sex | enum | no | male, female or unknown. | cURL: ```bash curl -X PUT "https://app.loki.pet/public-api/v1/pets/PET_ID" \ -H "X-API-Key: $LOKI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "weight": "28kg" }' ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/pets/PET_ID", { method: "PUT", headers: { "X-API-Key": process.env.LOKI_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ "weight": "28kg" }), }); const json = await res.json(); ``` Returns the updated pet as { data: {...} }. #### DELETE /pets/:id: Delete a pet Deletes a pet. Required scope: `pets:write` Path parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | yes | The pet id. | cURL: ```bash curl -X DELETE "https://app.loki.pet/public-api/v1/pets/PET_ID" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/pets/PET_ID", { method: "DELETE", headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "success": true } ``` ### Care calendar Feedings, medication, vet visits, grooming and exercise, with recurrence and reminders. Model: ```ts export type CareItemType = | "feeding" | "medication" | "vet_visit" | "grooming" | "exercise" | "other"; export interface CareItem { id: string; title: string; itemType: CareItemType; startsAt: string; // ISO 8601, UTC endsAt?: string; allDay?: boolean; petIds: string[]; recurrenceType?: "once" | "daily" | "weekly" | "monthly"; reminderEnabled?: boolean; reminderLeadMinutes?: number; metadata?: Record; } ``` #### GET /care-items: List care items Returns care items, optionally for one pet. Required scope: `care:read` Query parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | petId | string | no | Only return items for this pet. | | limit | integer | no | Items per page, 1 to 200. Default 50. | | offset | integer | no | Items to skip. Default 0. | cURL: ```bash curl "https://app.loki.pet/public-api/v1/care-items?petId=PET_ID" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/care-items?petId=PET_ID", { headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "data": [ { "id": "f1e2d3c4-...", "title": "Morning feeding", "itemType": "feeding", "startsAt": "2026-01-15T08:00:00.000Z", "allDay": false, "recurrenceType": "daily", "petIds": [ "a1b2c3d4-..." ] } ], "meta": { "total": 1, "limit": 50, "offset": 0 } } ``` #### GET /care-items/:id: Get a care item Returns one care item. Required scope: `care:read` Path parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | yes | The care item id. | cURL: ```bash curl "https://app.loki.pet/public-api/v1/care-items/CARE_ITEM_ID" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/care-items/CARE_ITEM_ID", { headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "data": { "id": "f1e2d3c4-...", "title": "Morning feeding", "itemType": "feeding", "startsAt": "2026-01-15T08:00:00.000Z", "allDay": false, "recurrenceType": "daily", "petIds": [ "a1b2c3d4-..." ] } } ``` #### POST /care-items: Create a care item Creates a care item. title, itemType and startsAt are required. Required scope: `care:write` Body (JSON): | Name | Type | Required | Description | | --- | --- | --- | --- | | title | string | yes | 1 to 200 characters. | | itemType | enum | yes | feeding, medication, vet_visit, grooming, exercise or other. | | startsAt | string (ISO 8601) | yes | When the item starts. | | endsAt | string (ISO 8601) | no | When the item ends. | | allDay | boolean | no | Default false. | | description | string | no | Free text. | | petIds | string[] | no | The pets this item is for. | | recurrenceType | enum | no | once (default), daily, weekly or monthly. | | recurrenceInterval | integer | no | For example 2 with weekly means every two weeks. | | recurrenceEndDate | string (ISO 8601) | no | When the recurrence stops. | | reminderEnabled | boolean | no | Default false. | | reminderLeadMinutes | integer | no | Minutes before the item to send the reminder. | | metadata | object | no | For example dosage or clinicName. | cURL: ```bash curl -X POST "https://app.loki.pet/public-api/v1/care-items" \ -H "X-API-Key: $LOKI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "Vet checkup", "itemType": "vet_visit", "startsAt": "2026-02-01T10:30:00Z", "petIds": [ "a1b2c3d4-..." ], "metadata": { "clinicName": "Happy Paws Veterinary" } }' ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/care-items", { method: "POST", headers: { "X-API-Key": process.env.LOKI_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ "title": "Vet checkup", "itemType": "vet_visit", "startsAt": "2026-02-01T10:30:00Z", "petIds": [ "a1b2c3d4-..." ], "metadata": { "clinicName": "Happy Paws Veterinary" } }), }); const json = await res.json(); ``` Returns the created care item as { data: {...} }. #### PUT /care-items/:id: Update a care item Updates a care item. Same fields as creating, all optional. Required scope: `care:write` Path parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | yes | The care item id. | Body (JSON): | Name | Type | Required | Description | | --- | --- | --- | --- | | title | string | no | 1 to 200 characters. | | itemType | enum | no | feeding, medication, vet_visit, grooming, exercise or other. | | startsAt | string (ISO 8601) | no | When the item starts. | | endsAt | string (ISO 8601) | no | When the item ends. | | allDay | boolean | no | Default false. | | description | string | no | Free text. | | petIds | string[] | no | The pets this item is for. | | recurrenceType | enum | no | once (default), daily, weekly or monthly. | | recurrenceInterval | integer | no | For example 2 with weekly means every two weeks. | | recurrenceEndDate | string (ISO 8601) | no | When the recurrence stops. | | reminderEnabled | boolean | no | Default false. | | reminderLeadMinutes | integer | no | Minutes before the item to send the reminder. | | metadata | object | no | For example dosage or clinicName. | cURL: ```bash curl -X PUT "https://app.loki.pet/public-api/v1/care-items/CARE_ITEM_ID" \ -H "X-API-Key: $LOKI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "reminderEnabled": true, "reminderLeadMinutes": 10 }' ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/care-items/CARE_ITEM_ID", { method: "PUT", headers: { "X-API-Key": process.env.LOKI_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ "reminderEnabled": true, "reminderLeadMinutes": 10 }), }); const json = await res.json(); ``` Returns the updated care item as { data: {...} }. #### DELETE /care-items/:id: Delete a care item Deletes a care item. Required scope: `care:write` Path parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | yes | The care item id. | cURL: ```bash curl -X DELETE "https://app.loki.pet/public-api/v1/care-items/CARE_ITEM_ID" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/care-items/CARE_ITEM_ID", { method: "DELETE", headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "success": true } ``` ### Journal Read only. Entries are moments Loki captures from conversations. Model: ```ts export interface JournalEntry { id: string; petId: string; title: string; content: string; createdAt: string; // ISO 8601, UTC } ``` #### GET /journal-entries: List journal entries Returns journal entries, optionally for one pet. Required scope: `journal:read` Query parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | petId | string | no | Only return items for this pet. | | limit | integer | no | Items per page, 1 to 200. Default 50. | | offset | integer | no | Items to skip. Default 0. | cURL: ```bash curl "https://app.loki.pet/public-api/v1/journal-entries?petId=PET_ID" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/journal-entries?petId=PET_ID", { headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "data": [ { "id": "d4e5f6a7-...", "petId": "a1b2c3d4-...", "title": "First trip to the beach", "content": "Luna was hesitant at first but ended up sprinting along the shoreline for twenty minutes straight.", "createdAt": "2026-01-10T14:22:00.000Z" } ], "meta": { "total": 1, "limit": 50, "offset": 0 } } ``` ### Photos Read only. Pet photos with captions. Model: ```ts export interface Photo { id: string; petId: string; url: string; caption: string; } ``` #### GET /photos: List photos Returns photos. Required scope: `photos:read` Query parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | limit | integer | no | Items per page, 1 to 200. Default 50. | | offset | integer | no | Items to skip. Default 0. | cURL: ```bash curl "https://app.loki.pet/public-api/v1/photos" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/photos", { headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "data": [ { "id": "c3b2a1f0-...", "petId": "a1b2c3d4-...", "url": "https://storage.example.com/photos/luna-beach.jpg", "caption": "Luna at the beach" } ], "meta": { "total": 1, "limit": 50, "offset": 0 } } ``` #### GET /photos/:id: Get a photo Returns one photo. Required scope: `photos:read` Path parameters: | Name | Type | Required | Description | | --- | --- | --- | --- | | id | string | yes | The photo id. | cURL: ```bash curl "https://app.loki.pet/public-api/v1/photos/PHOTO_ID" \ -H "X-API-Key: $LOKI_API_KEY" ``` JavaScript: ```js const res = await fetch("https://app.loki.pet/public-api/v1/photos/PHOTO_ID", { headers: { "X-API-Key": process.env.LOKI_API_KEY, }, }); const json = await res.json(); ``` Example response: ```json { "data": { "id": "c3b2a1f0-...", "petId": "a1b2c3d4-...", "url": "https://storage.example.com/photos/luna-beach.jpg", "caption": "Luna at the beach" } } ``` ## Machine-readable - llms.txt: https://loki.pet/llms.txt - OpenAPI 3.1: https://loki.pet/developers/openapi.json