{
  "openapi": "3.1.0",
  "info": {
    "title": "KidCanvas AI API",
    "version": "1",
    "description": "A conversation and portfolio companion for children's drawings. Send one to three photos of a drawing and get the colours and page use measured in the picture, a list of what is visibly there for the adult to confirm, edit or reject, neutral things to ask, and a private timeline that can be shared. The child's own words are kept verbatim next to it. KidCanvas never infers feelings, personality, development or anything about the child, and has no score, grade or ranking. Authenticate with an API key (Authorization: Bearer <key> or X-API-Key). Only starting a reading is billed, once, after it is delivered; everything else is free. Errors are RFC 7807 problems with a stable code."
  },
  "servers": [
    {
      "url": "https://kidcanvas.sensifai.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Children",
      "description": "Nickname and age band only."
    },
    {
      "name": "Drawings",
      "description": "Photo in, confirmed record out."
    },
    {
      "name": "Jobs",
      "description": "Readings run in the background."
    },
    {
      "name": "Timeline",
      "description": "Aggregates and neutral comparison."
    },
    {
      "name": "Sharing",
      "description": "Read-only, expiring links."
    }
  ],
  "paths": {
    "/api/v1/children": {
      "get": {
        "operationId": "listChildren",
        "tags": [
          "Children"
        ],
        "summary": "List children",
        "description": "Lists the children of the account (nickname and age band only; there is no legal name or birth date anywhere).",
        "responses": {
          "200": {
            "description": "The children.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "children": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Child"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createChild",
        "tags": [
          "Children"
        ],
        "summary": "Create a child",
        "description": "Adds a child by nickname and age band (4-6, 7-9 or 10-12). Do not send a legal name.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChildInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The child.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Child"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT: the limit of children is reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/children/{id}": {
      "delete": {
        "operationId": "deleteChild",
        "tags": [
          "Children"
        ],
        "summary": "Delete a child",
        "description": "Deletes the child with every drawing, revision, note, share link and timeline row. This cannot be undone.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Child id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/children/{id}/drawings": {
      "post": {
        "operationId": "createDrawing",
        "tags": [
          "Drawings"
        ],
        "summary": "Start a reading of a drawing",
        "description": "Uploads one to three photos of one drawing (multipart field `images`, JPEG or PNG, checked by content) and starts a reading. Send `consent=true` the first time to record that you are the child's parent or guardian and agree to the drawing being processed. Optional `drawing_prompt` (what the child was asked to draw) and `child_words` (the child's own explanation, kept verbatim). Answers 202 with a job to poll. Send an `Idempotency-Key` header so a retry never starts a second reading. One unit is billed after the reading is delivered, under the identifier minted here; a photo that is not a drawing, an unusable photo, a request for more input and any failure are never charged.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Child id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A unique key per reading; the same key returns the same job.",
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "images"
                ],
                "properties": {
                  "images": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 3,
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  },
                  "drawing_prompt": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "child_words": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "consent": {
                    "type": "boolean"
                  },
                  "save": {
                    "type": "boolean",
                    "description": "Keep the thumbnail in the portfolio; default is the account setting."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "402": {
            "description": "PAYMENT_REQUIRED: the prepaid wallet is empty (top_up_url).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "NEEDS_CONSENT, or no active subscription (subscribe_url).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: the child.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "A photo is larger than the limit.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "415": {
            "description": "UNSUPPORTED: not a JPEG or PNG.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT: a field or an unusable photo.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/children/{id}/timeline": {
      "get": {
        "operationId": "childTimeline",
        "tags": [
          "Timeline"
        ],
        "summary": "Timeline of a child",
        "description": "Aggregates computed from the saved drawings: drawings per month, colour families (every drawing, measured) and the things adults confirmed (confirmed drawings only), with the recurring ones. Descriptive only.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Child id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "First day, YYYY-MM-DD.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Last day, YYYY-MM-DD.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The timeline.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Timeline"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/children/{id}/compare": {
      "get": {
        "operationId": "compareDrawings",
        "tags": [
          "Timeline"
        ],
        "summary": "Compare two confirmed drawings",
        "description": "Neutral side-by-side of two drawings of one child, using each drawing's latest confirmed revision: what appears in both, only in the older, only in the newer. Never a ranking, never progress. Refused when the drawings were captured with different numbers of photos or one photo was unusable (`comparable` false with a reason).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Child id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "a",
            "in": "query",
            "required": false,
            "description": "First drawing id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "b",
            "in": "query",
            "required": false,
            "description": "Second drawing id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The comparison.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Comparison"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "NOT_CONFIRMED: a drawing has no confirmed revision.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/children/{id}/shares": {
      "post": {
        "operationId": "createShare",
        "tags": [
          "Sharing"
        ],
        "summary": "Create a read-only share link",
        "description": "Creates an expiring (7, 30 or 90 days), revocable link to one drawing's latest confirmed revision for a counsellor, teacher or relative. The url and token are returned once. Needs the sharing consent on record (`consent_sharing=true` records it).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Child id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShareInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareCreated"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "NEEDS_CONSENT.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "NOT_CONFIRMED.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/drawings": {
      "get": {
        "operationId": "listDrawings",
        "tags": [
          "Drawings"
        ],
        "summary": "List drawings",
        "description": "Newest first, with pagination.",
        "parameters": [
          {
            "name": "child_id",
            "in": "query",
            "required": false,
            "description": "Only this child.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "draft or confirmed.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-100 (default 30).",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Offset.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of drawings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "drawings": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DrawingSummary"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/drawings/{id}": {
      "get": {
        "operationId": "getDrawing",
        "tags": [
          "Drawings"
        ],
        "summary": "Get a drawing",
        "description": "The drawing with its latest revision (or `?revision=N`): measured colours and page use, the observations (each proposed, confirmed, edited, rejected or added by the adult), conversation prompts, activities, the child's own words verbatim, notes, revisions, shares and the 30 independent checks.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Drawing id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "revision",
            "in": "query",
            "required": false,
            "description": "Revision number.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The drawing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Drawing"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteDrawing",
        "tags": [
          "Drawings"
        ],
        "summary": "Delete a drawing",
        "description": "Deletes the drawing, its revisions, notes, share links, thumbnail and timeline row.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Drawing id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/drawings/{id}/notes": {
      "patch": {
        "operationId": "addNote",
        "tags": [
          "Drawings"
        ],
        "summary": "Add a note",
        "description": "Adds a note (at most 2000 characters) by the child or the parent. The text is scanned locally against a reviewed support list; a match returns `concern` with support guidance. Nothing is sent to anyone.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Drawing id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoteInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The note.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "note": {
                      "$ref": "#/components/schemas/Note"
                    },
                    "concern": {
                      "type": [
                        "object",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/drawings/{id}/observations": {
      "patch": {
        "operationId": "editObservations",
        "tags": [
          "Drawings"
        ],
        "summary": "Confirm, edit, reject or add observations",
        "description": "Applies the adult's edits and returns the drawing with a new draft revision. Wording is safety-filtered: a description that grades, diagnoses or talks about the child is not applied and a line appears in `report.notes`. Conversation prompts are re-derived from the confirmed observations, without any AI call.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Drawing id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EditsInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The drawing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Drawing"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "INVALID_INPUT.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/drawings/{id}/confirm": {
      "post": {
        "operationId": "confirmDrawing",
        "tags": [
          "Drawings"
        ],
        "summary": "Confirm a drawing",
        "description": "Marks the latest draft as the adult's confirmed revision. Exports, share links and comparisons use only confirmed revisions.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Drawing id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The drawing with a confirmed revision.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Drawing"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/drawings/{id}/exports": {
      "post": {
        "operationId": "exportDrawing",
        "tags": [
          "Drawings"
        ],
        "summary": "Export a PDF",
        "description": "A PDF keepsake of the latest confirmed revision: thumbnail if kept, confirmed observations, the child's words if included, colour swatches, things to ask, activities and a provenance block.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Drawing id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "include_narration": {
                    "type": "boolean"
                  },
                  "include_colors": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "NOT_CONFIRMED.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{id}": {
      "get": {
        "operationId": "getJob",
        "tags": [
          "Jobs"
        ],
        "summary": "Get a reading job",
        "description": "States: queued, running, needs_input (usable photos but nothing could be listed: add a note and send again, free), completed (drawing_id is set), failed, cancelled. Only completed readings are charged.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Job id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{id}/cancel": {
      "post": {
        "operationId": "cancelJob",
        "tags": [
          "Jobs"
        ],
        "summary": "Cancel a reading job",
        "description": "Stops a queued job at once; a running one is discarded before it is kept or billed.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Job id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "QUOTA_EXCEEDED: an hourly limit was reached.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such id, or it belongs to someone else.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "CONFLICT: already finished.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "required": [
          "code",
          "status"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "enum": [
              "INVALID_INPUT",
              "NEEDS_CONSENT",
              "UNSUPPORTED",
              "QUOTA_EXCEEDED",
              "PROVIDER_UNAVAILABLE",
              "NOT_FOUND",
              "NOT_CONFIRMED",
              "CONFLICT",
              "GONE",
              "UNAUTHORIZED",
              "FORBIDDEN",
              "PAYMENT_REQUIRED"
            ]
          },
          "detail": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "timestamp": {
            "type": "integer"
          }
        }
      },
      "ChildInput": {
        "type": "object",
        "required": [
          "nickname",
          "age_band"
        ],
        "properties": {
          "nickname": {
            "type": "string",
            "maxLength": 40
          },
          "age_band": {
            "type": "string",
            "enum": [
              "4-6",
              "7-9",
              "10-12"
            ]
          }
        }
      },
      "Child": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "nickname": {
            "type": "string"
          },
          "age_band": {
            "type": "string"
          },
          "age_label": {
            "type": "string"
          },
          "archived": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "drawings": {
            "type": "integer"
          },
          "confirmed": {
            "type": "integer"
          },
          "last_drawing_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Accepted": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "drawing_id": {
            "type": "null"
          },
          "state": {
            "type": "string"
          },
          "poll": {
            "type": "string"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "needs_input",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "message": {
            "type": "string"
          },
          "drawing_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "child_id": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "charged": {
            "type": "boolean"
          },
          "units": {
            "type": "integer"
          }
        }
      },
      "DrawingSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "child_id": {
            "type": "string"
          },
          "child_nickname": {
            "type": "string"
          },
          "age_band": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "confirmed"
            ]
          },
          "saved": {
            "type": "boolean"
          },
          "has_thumbnail": {
            "type": "boolean"
          },
          "captured_at": {
            "type": "string",
            "format": "date-time"
          },
          "revision_no": {
            "type": "integer"
          },
          "observations_total": {
            "type": "integer"
          },
          "observations_confirmed": {
            "type": "integer"
          },
          "colors": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "support": {
            "type": "boolean"
          }
        }
      },
      "Drawing": {
        "type": "object",
        "properties": {
          "drawing": {
            "$ref": "#/components/schemas/DrawingSummary"
          },
          "report": {
            "$ref": "#/components/schemas/Report"
          },
          "quality": {
            "type": "object",
            "properties": {
              "score": {
                "type": "integer"
              },
              "usable": {
                "type": "boolean"
              },
              "problems": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "revision_no": {
            "type": "integer"
          },
          "revisions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "no": {
                  "type": "integer"
                },
                "status": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "confirmed_revision_no": {
            "type": [
              "integer",
              "null"
            ]
          },
          "notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Note"
            }
          },
          "saved": {
            "type": "boolean"
          },
          "thumbnail": {
            "type": [
              "string",
              "null"
            ],
            "description": "Base64 JPEG, at most 480 px."
          },
          "shares": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "concern": {
            "type": [
              "object",
              "null"
            ]
          },
          "can_export": {
            "type": "boolean"
          },
          "can_share": {
            "type": "boolean"
          }
        }
      },
      "Report": {
        "type": "object",
        "description": "The reading. Colours, page use and counts are measured in code; every AI observation is labelled source ai and stays proposed until an adult confirms it.",
        "properties": {
          "version": {
            "type": "string"
          },
          "revision": {
            "type": "integer"
          },
          "confirmed": {
            "type": "boolean"
          },
          "age_band": {
            "type": "string"
          },
          "images": {
            "type": "integer"
          },
          "drawing_prompt": {
            "type": "string"
          },
          "narration": {
            "type": "object",
            "description": "The child's words, verbatim.",
            "properties": {
              "text": {
                "type": "string"
              },
              "author": {
                "type": "string"
              },
              "sha256": {
                "type": "string"
              }
            }
          },
          "colors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "hex": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "family": {
                  "type": "string"
                },
                "share_percent": {
                  "type": "integer"
                }
              }
            }
          },
          "composition": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "measured": {
            "type": "object"
          },
          "observations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Observation"
            }
          },
          "prompt_hints": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "prompts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "template_id": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                },
                "observation_id": {
                  "type": "string"
                }
              }
            }
          },
          "activities": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "unknowns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          },
          "description_by_ai": {
            "type": "boolean"
          },
          "concern": {
            "type": "object"
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "ok": {
                  "type": "boolean"
                },
                "detail": {
                  "type": "string"
                }
              }
            }
          },
          "checks_passed": {
            "type": "boolean"
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "identifying_text_visible": {
            "type": "boolean"
          }
        }
      },
      "Observation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "figure",
              "building",
              "plant",
              "animal",
              "vehicle",
              "sky_weather",
              "food",
              "object",
              "pattern",
              "landscape",
              "writing",
              "other"
            ]
          },
          "text": {
            "type": "string"
          },
          "evidence": {
            "type": "string"
          },
          "region": {
            "type": "object"
          },
          "count": {
            "type": "integer"
          },
          "source": {
            "type": "string",
            "enum": [
              "ai",
              "measured",
              "adult"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "proposed",
              "confirmed",
              "edited",
              "rejected",
              "added"
            ]
          }
        }
      },
      "EditsInput": {
        "type": "object",
        "required": [
          "edits"
        ],
        "properties": {
          "edits": {
            "type": "array",
            "minItems": 1,
            "maxItems": 30,
            "items": {
              "type": "object",
              "required": [
                "op"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "op": {
                  "type": "string",
                  "enum": [
                    "confirm",
                    "text",
                    "reject",
                    "reset",
                    "add"
                  ]
                },
                "text": {
                  "type": "string",
                  "maxLength": 120
                },
                "kind": {
                  "type": "string"
                },
                "count": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "NoteInput": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 2000
          },
          "author_role": {
            "type": "string",
            "enum": [
              "child",
              "parent"
            ]
          },
          "include_in_share": {
            "type": "boolean"
          }
        }
      },
      "Note": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "drawing_id": {
            "type": "string"
          },
          "author_role": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "include_in_share": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Timeline": {
        "type": "object",
        "properties": {
          "child": {
            "$ref": "#/components/schemas/Child"
          },
          "keep_history": {
            "type": "boolean"
          },
          "timeline": {
            "type": "object"
          },
          "drawings": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Comparison": {
        "type": "object",
        "properties": {
          "comparable": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          },
          "sentences": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "colors_both": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "colors_only_older": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "colors_only_newer": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "older": {
            "type": "object"
          },
          "newer": {
            "type": "object"
          }
        }
      },
      "ShareInput": {
        "type": "object",
        "required": [
          "drawing_id",
          "days"
        ],
        "properties": {
          "drawing_id": {
            "type": "string"
          },
          "days": {
            "type": "integer",
            "enum": [
              7,
              30,
              90
            ]
          },
          "include_narration": {
            "type": "boolean"
          },
          "include_notes": {
            "type": "boolean"
          },
          "include_colors": {
            "type": "boolean"
          },
          "consent_sharing": {
            "type": "boolean"
          }
        }
      },
      "ShareCreated": {
        "type": "object",
        "properties": {
          "share": {
            "type": "object"
          },
          "url": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}
