{
  "openapi": "3.1.1",
  "info": {
    "title": "Hello Sparks API",
    "version": "1.0.0",
    "summary": "The two endpoints the Hello Sparks lessons call from the learner’s browser.",
    "description": "Hello Sparks (https://hellosparks.app) is a free website where children learn how AI works by building a robot. These are the app’s own endpoints, used by its lessons in the learner’s browser. They are same-origin only (a request without an Origin header, or whose Origin header names another site, is refused), limited in how many requests they take, and may be switched off at any time: both are off unless the site owner switches them on.\n\nThis is not a general-purpose language model API, and it has no keys, accounts or other endpoints.\n\nEvery error this API itself returns is JSON: `{\"status\": \"...\", \"error\": {\"code\": \"...\", \"message\": \"...\", \"hint\": \"...\"}}`. Branch on `error.code`. Any other address under /api/ answers 404 with the code `not_found`, for any method (see `#/components/responses/NotFound`).",
    "contact": {
      "name": "Hello Sparks",
      "email": "smartsoftworks@gmail.com",
      "url": "https://hellosparks.app"
    }
  },
  "servers": [{"url": "https://hellosparks.app"}],
  "tags": [
    {
      "name": "Robot",
      "description": "The robot’s live language model (Meet your robot: its replies when a learner talks to it, its tool choices in every activity where it uses tools, and a challenge for a friend)."
    },
    {"name": "Usage counts", "description": "Privacy-first, content-free usage counts."}
  ],
  "paths": {
    "/api/robot": {
      "post": {
        "operationId": "stepRobot",
        "tags": ["Robot"],
        "summary": "Ask the robot’s language model for one step",
        "description": "This is the site’s own endpoint, called by the lessons running in the learner’s browser on https://hellosparks.app. It is not a general-purpose API. One request is one model step and carries everything the model needs; the server keeps nothing between steps. For `reply` (talking to the robot) the model answers with a short reply. For `act` (every activity where the robot uses tools, and a challenge for a friend) it names one tool from the request’s toolbox by id, or null to finish; it never moves the robot itself. The app runs the tool and sends the next step with what happened.\n\nOff unless the site owner switches it on (until then it answers 503 `disabled`). Requests without an Origin header, or whose Origin header names another host, are refused (403), as are requests whose Sec-Fetch-Site is `cross-site` or `same-site`; the body must be `application/json`. Each client address may send a burst of 60 steps, refilled at one every 2 seconds, with at most 8 at once; each server instance answers at most 24 at once and 5000 a day. These limits are per server instance and reset when it restarts. Answers for a rate limit, a busy server, the daily limit, a spending pause or a busy model say how long to wait in Retry-After.\n\nLearner text is limited to 80 characters, the toolbox to 6 tools and the history to 8 actions; the whole body to 16000 bytes. A held key is not also on the floor (when `holding` is true, `key` must be null), and tool ids must be unique. Unknown fields are refused.",
        "parameters": [
          {
            "name": "Origin",
            "in": "header",
            "required": true,
            "description": "Sent by browsers with every POST, same-origin ones included. It must name this site’s host; a request without it, or naming another host, is refused with 403.",
            "schema": {"type": "string", "format": "uri"}
          },
          {
            "name": "Sec-Fetch-Site",
            "in": "header",
            "required": false,
            "description": "Sent by most browsers. When present it must not be `cross-site` or `same-site`, or the request is refused with 403.",
            "schema": {"type": "string"}
          }
        ],
        "requestBody": {
          "required": true,
          "description": "One model step. At most 16000 bytes of UTF-8 JSON.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "reply",
                        "description": "Talking to the robot: it replies with words only."
                      },
                      "text": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80,
                        "description": "What the learner typed. It is treated as words to answer, never as instructions."
                      }
                    },
                    "required": ["kind", "text"],
                    "additionalProperties": false,
                    "description": "Talking to the robot: one message in, one short reply out."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "act",
                        "description": "Using tools, in every activity where the robot has them and in a challenge for a friend: the robot chooses a tool, or finishes."
                      },
                      "mode": {
                        "type": "string",
                        "enum": ["ask", "goal", "request"],
                        "description": "`ask`: one request, at most one tool. `goal`: pick up the key, one tool per step, sending the next step with what happened. `request`: do what the learner asked in their own words, one tool per step; the app checks the result itself."
                      },
                      "text": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80,
                        "description": "What the learner typed. It is treated as words to answer, never as instructions."
                      },
                      "tools": {
                        "maxItems": 6,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "description": "The tool’s id; unique in the toolbox."
                            },
                            "name": {
                              "type": "string",
                              "maxLength": 20,
                              "description": "The tool’s name, written by the learner."
                            },
                            "desc": {
                              "type": "string",
                              "maxLength": 80,
                              "description": "What the tool does, written by the learner. The model goes by this."
                            }
                          },
                          "required": ["id", "name", "desc"],
                          "additionalProperties": false,
                          "description": "One tool the robot may choose."
                        },
                        "description": "The toolbox, in order. Tool ids must be unique."
                      },
                      "room": {
                        "type": "object",
                        "properties": {
                          "pos": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 6,
                            "description": "The robot’s square, counted from 0 at the left."
                          },
                          "key": {
                            "anyOf": [
                              {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "state": {"type": "string", "const": "on"},
                                      "square": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "maximum": 6,
                                        "description": "The square the robot believes the key is on, counted from 0."
                                      },
                                      "source": {
                                        "type": "string",
                                        "enum": ["room", "look", "reach", "learner"],
                                        "description": "`room`: the app told it; `look`, `reach`: it found the key; `learner`: the learner said so, and could be wrong."
                                      }
                                    },
                                    "required": ["state", "square", "source"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {"state": {"type": "string", "const": "unknown"}},
                                    "required": ["state"],
                                    "additionalProperties": false,
                                    "description": "Not told, and not found."
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "state": {"type": "string", "const": "not-ahead"},
                                      "from": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "maximum": 6,
                                        "description": "The square it looked from, counted from 0."
                                      }
                                    },
                                    "required": ["state", "from"],
                                    "additionalProperties": false,
                                    "description": "It looked ahead to the wall and saw no key in front."
                                  },
                                  {
                                    "type": "object",
                                    "properties": {"state": {"type": "string", "const": "held"}},
                                    "required": ["state"],
                                    "additionalProperties": false,
                                    "description": "It is holding the key."
                                  },
                                  {
                                    "type": "object",
                                    "properties": {"state": {"type": "string", "const": "none"}},
                                    "required": ["state"],
                                    "additionalProperties": false,
                                    "description": "The app told it the room has no key."
                                  }
                                ],
                                "description": "What the robot knows about the key."
                              },
                              {
                                "anyOf": [
                                  {"type": "integer", "minimum": 0, "maximum": 6},
                                  {"type": "null"}
                                ],
                                "description": "The older shape, accepted for one release: the key’s square, or null when the robot holds it or the room has none."
                              }
                            ],
                            "description": "What the robot knows about the key. It is never read from the room as it is: before the robot is told or finds out, it is unknown."
                          },
                          "holding": {
                            "type": "boolean",
                            "description": "Whether the robot holds the key. True exactly when the key is held (or null)."
                          }
                        },
                        "required": ["pos", "key", "holding"],
                        "additionalProperties": false,
                        "description": "The room as it is now: a row of squares with the robot facing right."
                      },
                      "done": {
                        "maxItems": 8,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "toolId": {
                              "type": "string",
                              "maxLength": 64,
                              "description": "The id of the tool that was used."
                            },
                            "result": {
                              "type": "string",
                              "maxLength": 400,
                              "description": "What the app says happened."
                            }
                          },
                          "required": ["toolId", "result"],
                          "additionalProperties": false,
                          "description": "One tool action already taken in this run."
                        },
                        "description": "The tool actions this run has taken so far, oldest first."
                      }
                    },
                    "required": ["kind", "mode", "text", "tools", "room", "done"],
                    "additionalProperties": false,
                    "description": "Using tools, and a challenge for a friend: the next step of a run."
                  }
                ]
              },
              "examples": {
                "reply": {
                  "summary": "Talking to the robot: a message",
                  "value": {"kind": "reply", "text": "Hello robot! What can you do?"}
                },
                "act": {
                  "summary": "Using tools: the next step of a run",
                  "value": {
                    "kind": "act",
                    "mode": "goal",
                    "text": "Pick up the key.",
                    "tools": [
                      {
                        "id": "right",
                        "name": "Move right",
                        "desc": "Moves the robot right one square."
                      },
                      {"id": "grab", "name": "Grab", "desc": "Reaches out and closes the claw."}
                    ],
                    "room": {"pos": 0, "key": 3, "holding": false},
                    "done": []
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The model answered.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "ok",
                          "description": "The model answered."
                        },
                        "reply": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 280,
                          "description": "The robot’s reply, as plain text on one line. Show it as text, never HTML."
                        }
                      },
                      "required": ["status", "reply"],
                      "additionalProperties": false,
                      "description": "The answer to a `reply` request."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "ok",
                          "description": "The model answered."
                        },
                        "call": {
                          "anyOf": [
                            {"type": "string", "minLength": 1, "maxLength": 64},
                            {"type": "null"}
                          ],
                          "description": "The id of the tool to run next, from the request; null to finish."
                        },
                        "say": {
                          "type": "string",
                          "maxLength": 240,
                          "description": "What the robot says about its choice, as plain text; may be empty."
                        }
                      },
                      "required": ["status", "call", "say"],
                      "additionalProperties": false,
                      "description": "The answer to an `act` request."
                    }
                  ]
                },
                "examples": {
                  "reply": {
                    "summary": "A reply (talking to the robot)",
                    "value": {
                      "status": "ok",
                      "reply": "Hi! I am your robot. I can only talk for now."
                    }
                  },
                  "act": {
                    "summary": "A tool choice (using tools)",
                    "value": {"status": "ok", "call": "right", "say": ""}
                  },
                  "finish": {
                    "summary": "Finishing a run",
                    "value": {"status": "ok", "call": null, "say": "I picked up the key!"}
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request. `invalid_json` (status `invalid`): The body is not UTF-8 JSON. `invalid_request` (status `invalid`): The body does not match the request schema.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "invalid",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "invalid_json",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body is not UTF-8 JSON."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "invalid",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "invalid_request",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body does not match the request schema."
                    }
                  ]
                },
                "examples": {
                  "notJson": {
                    "summary": "The body is not UTF-8 JSON.",
                    "value": {
                      "status": "invalid",
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body is not valid UTF-8 JSON.",
                        "hint": "Send one JSON object encoded as UTF-8."
                      }
                    }
                  },
                  "invalid": {
                    "summary": "The body does not match the request schema.",
                    "value": {
                      "status": "invalid",
                      "error": {
                        "code": "invalid_request",
                        "message": "The request body does not match what this endpoint accepts.",
                        "hint": "Check the request body schema in https://hellosparks.app/openapi.json; unknown fields are refused."
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden. `forbidden_origin` (status `forbidden`): The Origin header is missing or names a different host, or Sec-Fetch-Site is cross-site or same-site.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "forbidden",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "forbidden_origin",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The Origin header is missing or names a different host, or Sec-Fetch-Site is cross-site or same-site."
                },
                "examples": {
                  "forbidden": {
                    "summary": "The Origin header is missing or names a different host, or Sec-Fetch-Site is cross-site or same-site.",
                    "value": {
                      "status": "forbidden",
                      "error": {
                        "code": "forbidden_origin",
                        "message": "This endpoint only answers requests from pages on this same site.",
                        "hint": "It is the site’s own endpoint, called by its pages; requests with no Origin, or whose Origin is another site, are refused."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. `method_not_allowed` (status `method`): The request is not a POST.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              },
              "Allow": {
                "description": "The accepted method.",
                "required": true,
                "schema": {"type": "string", "const": "POST"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "method",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "method_not_allowed",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The request is not a POST."
                },
                "examples": {
                  "method": {
                    "summary": "The request is not a POST.",
                    "value": {
                      "status": "method",
                      "error": {
                        "code": "method_not_allowed",
                        "message": "This endpoint only accepts POST.",
                        "hint": "Send a POST request with a JSON body; the Allow header lists the accepted method."
                      }
                    }
                  }
                }
              }
            }
          },
          "408": {
            "description": "Request timeout. `request_timeout` (status `unavailable`): The body did not arrive in time. `body_read_failed` (status `unavailable`): The body broke off before it was all read.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "unavailable",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "request_timeout",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body did not arrive in time."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "unavailable",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "body_read_failed",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body broke off before it was all read."
                    }
                  ]
                },
                "examples": {
                  "bodyTimeout": {
                    "summary": "The body did not arrive in time.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "request_timeout",
                        "message": "The request body did not arrive in time.",
                        "hint": "Send the whole body promptly, then try again."
                      }
                    }
                  },
                  "bodyRead": {
                    "summary": "The body broke off before it was all read.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "body_read_failed",
                        "message": "The request body broke off before it was all read.",
                        "hint": "Send the request again."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large. `payload_too_large` (status `too-large`): The body is larger than the limit.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "too-large",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "payload_too_large",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The body is larger than the limit."
                },
                "examples": {
                  "tooLarge": {
                    "summary": "The body is larger than the limit.",
                    "value": {
                      "status": "too-large",
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "hint": "Keep the body within the size limit given in https://hellosparks.app/openapi.json."
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Unsupported media type. `unsupported_media_type` (status `media-type`): The Content-Type is not application/json.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "media-type",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "unsupported_media_type",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The Content-Type is not application/json."
                },
                "examples": {
                  "mediaType": {
                    "summary": "The Content-Type is not application/json.",
                    "value": {
                      "status": "media-type",
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "The request body must be JSON.",
                        "hint": "Send the header Content-Type: application/json."
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. `rate_limited` (status `rate-limited`): This address has asked too often. `busy` (status `busy`): Too many steps are running at once, for this address or for this server instance.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              },
              "Retry-After": {
                "description": "Seconds to wait before trying again. Sent with: `rate_limited`, `busy`.",
                "required": true,
                "schema": {"type": "integer", "minimum": 1}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "rate-limited",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "rate_limited",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "This address has asked too often."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "busy",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "busy",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "Too many steps are running at once, for this address or for this server instance."
                    }
                  ]
                },
                "examples": {
                  "rateLimited": {
                    "summary": "This address has asked too often.",
                    "value": {
                      "status": "rate-limited",
                      "error": {
                        "code": "rate_limited",
                        "message": "Too many requests from this address.",
                        "hint": "Wait for the number of seconds in the Retry-After header, then try again."
                      }
                    }
                  },
                  "busy": {
                    "summary": "Too many steps are running at once, for this address or for this server instance.",
                    "value": {
                      "status": "busy",
                      "error": {
                        "code": "busy",
                        "message": "This endpoint is busy with other requests.",
                        "hint": "Try again shortly. If a Retry-After header is present, wait that many seconds first."
                      }
                    }
                  }
                }
              }
            }
          },
          "499": {
            "description": "Client closed request. `client_closed_request` (status `unavailable`): The caller went away before the step finished.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "unavailable",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "client_closed_request",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The caller went away before the step finished."
                },
                "examples": {
                  "clientClosed": {
                    "summary": "The caller went away before the step finished.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "client_closed_request",
                        "message": "The request was cancelled before it finished.",
                        "hint": "Nothing was done. Send it again if it is still wanted."
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. `internal_error` (status `unavailable`): A fault in this service.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "unavailable",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "internal_error",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "A fault in this service."
                },
                "examples": {
                  "internal": {
                    "summary": "A fault in this service.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "internal_error",
                        "message": "Something went wrong on the server.",
                        "hint": "Try again later."
                      }
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway. `model_no_answer` (status `unavailable`): The model answered with nothing usable.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "unavailable",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "model_no_answer",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The model answered with nothing usable."
                },
                "examples": {
                  "modelNoAnswer": {
                    "summary": "The model answered with nothing usable.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "model_no_answer",
                        "message": "The language model gave no usable answer.",
                        "hint": "Try again, perhaps with different words."
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable. `disabled` (status `disabled`): The live robot is switched off on this deployment (the default). `paused` (status `paused`): The live robot is paused by its kill switch. `misconfigured` (status `unavailable`): The live robot is switched on but has no model it can use. `spend_paused` (status `resting`): The model’s spending budget ran out recently; the robot rests for a while. `daily_limit` (status `daily-limit`): This server instance has answered its daily number of steps. `model_busy` (status `busy`): The model provider is rate limiting or overloaded. `model_unavailable` (status `unavailable`): The model provider could not answer.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              },
              "Retry-After": {
                "description": "Seconds to wait before trying again. Sent with: `spend_paused`, `daily_limit`, `model_busy`.",
                "required": false,
                "schema": {"type": "integer", "minimum": 1}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "disabled",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "disabled",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The live robot is switched off on this deployment (the default)."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "paused",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "paused",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The live robot is paused by its kill switch."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "unavailable",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "misconfigured",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The live robot is switched on but has no model it can use."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "resting",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "spend_paused",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The model’s spending budget ran out recently; the robot rests for a while."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "daily-limit",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "daily_limit",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "This server instance has answered its daily number of steps."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "busy",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "model_busy",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The model provider is rate limiting or overloaded."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "unavailable",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "model_unavailable",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The model provider could not answer."
                    }
                  ]
                },
                "examples": {
                  "disabled": {
                    "summary": "The live robot is switched off on this deployment (the default).",
                    "value": {
                      "status": "disabled",
                      "error": {
                        "code": "disabled",
                        "message": "This endpoint is switched off on this deployment.",
                        "hint": "Nothing to fix on your side. It may be switched on later."
                      }
                    }
                  },
                  "paused": {
                    "summary": "The live robot is paused by its kill switch.",
                    "value": {
                      "status": "paused",
                      "error": {
                        "code": "paused",
                        "message": "This endpoint is paused for now.",
                        "hint": "Try again later."
                      }
                    }
                  },
                  "noModel": {
                    "summary": "The live robot is switched on but has no model it can use.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "misconfigured",
                        "message": "This endpoint is switched on but not fully set up.",
                        "hint": "Nothing to fix on your side, and trying again will not help until the site owner finishes setting it up."
                      }
                    }
                  },
                  "spendPaused": {
                    "summary": "The model’s spending budget ran out recently; the robot rests for a while.",
                    "value": {
                      "status": "resting",
                      "error": {
                        "code": "spend_paused",
                        "message": "The language model’s spending budget is used up for now.",
                        "hint": "Wait for the number of seconds in the Retry-After header, then try again."
                      }
                    }
                  },
                  "dailyCap": {
                    "summary": "This server instance has answered its daily number of steps.",
                    "value": {
                      "status": "daily-limit",
                      "error": {
                        "code": "daily_limit",
                        "message": "Today’s allowance of requests for this endpoint is used up.",
                        "hint": "Wait for the number of seconds in the Retry-After header, then try again."
                      }
                    }
                  },
                  "modelBusy": {
                    "summary": "The model provider is rate limiting or overloaded.",
                    "value": {
                      "status": "busy",
                      "error": {
                        "code": "model_busy",
                        "message": "The language model is busy.",
                        "hint": "Wait for the number of seconds in the Retry-After header, then try again."
                      }
                    }
                  },
                  "modelUnavailable": {
                    "summary": "The model provider could not answer.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "model_unavailable",
                        "message": "The language model could not answer.",
                        "hint": "Try again later."
                      }
                    }
                  }
                }
              }
            }
          },
          "504": {
            "description": "Gateway timeout. `model_timeout` (status `unavailable`): The model did not answer in time.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "unavailable",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "model_timeout",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The model did not answer in time."
                },
                "examples": {
                  "modelTimeout": {
                    "summary": "The model did not answer in time.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "model_timeout",
                        "message": "The language model took too long to answer.",
                        "hint": "Try again; a shorter request may help."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/analytics": {
      "post": {
        "operationId": "recordUsageCount",
        "tags": ["Usage counts"],
        "summary": "Count one page view or action, with no content",
        "description": "This is the site’s own endpoint, called by the lessons running in the learner’s browser on https://hellosparks.app. It is not a general-purpose API. It passes one anonymous count to the site’s analytics service without forwarding cookies, IP address, user agent or any other browser header. Every field comes from a fixed list or is a random page id kept only in memory; nothing a learner writes can be sent.\n\nOff unless the site owner switches it on (until then it answers 503 `disabled`). The Origin header must be exactly this site’s origin, and cross-site requests are refused (403). A request with `Sec-GPC: 1` is answered 204 and not counted. The body must be `application/json` and at most 512 bytes; each server instance passes on at most 8 counts at once (429 `busy` beyond that). Unknown fields are refused.",
        "parameters": [
          {
            "name": "Origin",
            "in": "header",
            "required": true,
            "description": "Must be exactly this site’s origin, as browsers send it.",
            "schema": {"type": "string", "format": "uri"}
          },
          {
            "name": "Sec-GPC",
            "in": "header",
            "required": false,
            "description": "Global Privacy Control. `1` means do not count: the answer is 204.",
            "schema": {"type": "string", "enum": ["1"]}
          }
        ],
        "requestBody": {
          "required": true,
          "description": "One count. At most 512 bytes of UTF-8 JSON.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "pageview",
                        "description": "A page was viewed."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "referrer": {
                        "type": "string",
                        "enum": [
                          "direct",
                          "internal",
                          "google",
                          "bing",
                          "duckduckgo",
                          "github",
                          "other"
                        ],
                        "description": "Where the visit came from, as a fixed category, never a URL."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": ["kind", "path", "referrer", "pageId"],
                    "additionalProperties": false,
                    "description": "A page view."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "action",
                        "description": "Something was done in the app."
                      },
                      "name": {
                        "type": "string",
                        "enum": [
                          "lesson_started",
                          "project_downloaded",
                          "project_opened",
                          "robot_reply_received",
                          "robot_reply_failed",
                          "splash_viewed",
                          "robot_tool_saved",
                          "robot_goal_reached"
                        ],
                        "description": "Which action, from a fixed list."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": ["kind", "name", "path", "pageId"],
                    "additionalProperties": false,
                    "description": "An action that carries nothing more than its name."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "action",
                        "description": "Something was done in the app."
                      },
                      "name": {
                        "type": "string",
                        "const": "splash_cta_clicked",
                        "description": "Which action."
                      },
                      "detail": {
                        "type": "string",
                        "enum": [
                          "header_creations",
                          "header_grownups",
                          "hero_start",
                          "hero_continue",
                          "hero_which",
                          "hero_creations",
                          "hero_play_garden",
                          "lesson_start",
                          "lesson_continue",
                          "lesson_new_robot",
                          "pick_garden_continue",
                          "pick_robot_start",
                          "pick_garden_start",
                          "pick_creations",
                          "end_start",
                          "end_continue",
                          "end_which",
                          "end_creations",
                          "footer_glossary",
                          "grownups_guide"
                        ],
                        "description": "The action's cta, from a fixed list."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": ["kind", "name", "detail", "path", "pageId"],
                    "additionalProperties": false,
                    "description": "The splash_cta_clicked action, with its one detail."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "action",
                        "description": "Something was done in the app."
                      },
                      "name": {
                        "type": "string",
                        "const": "robot_lesson_started",
                        "description": "Which action."
                      },
                      "detail": {
                        "type": "string",
                        "enum": [
                          "words",
                          "move",
                          "grab",
                          "next",
                          "fix",
                          "find-out",
                          "after-look",
                          "lights-out"
                        ],
                        "description": "The action's lesson, from a fixed list."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": ["kind", "name", "detail", "path", "pageId"],
                    "additionalProperties": false,
                    "description": "The robot_lesson_started action, with its one detail."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "action",
                        "description": "Something was done in the app."
                      },
                      "name": {
                        "type": "string",
                        "const": "robot_tool_tested",
                        "description": "Which action."
                      },
                      "detail": {
                        "type": "string",
                        "enum": ["supplied", "own"],
                        "description": "The action's tool, from a fixed list."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": ["kind", "name", "detail", "path", "pageId"],
                    "additionalProperties": false,
                    "description": "The robot_tool_tested action, with its one detail."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "action",
                        "description": "Something was done in the app."
                      },
                      "name": {
                        "type": "string",
                        "const": "robot_model_used_tool",
                        "description": "Which action."
                      },
                      "detail": {
                        "type": "string",
                        "enum": ["supplied", "own"],
                        "description": "The action's tool, from a fixed list."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": ["kind", "name", "detail", "path", "pageId"],
                    "additionalProperties": false,
                    "description": "The robot_model_used_tool action, with its one detail."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "action",
                        "description": "Something was done in the app."
                      },
                      "name": {
                        "type": "string",
                        "const": "robot_experiment_tried",
                        "description": "Which action."
                      },
                      "detail": {
                        "type": "string",
                        "enum": ["right", "wrong"],
                        "description": "The action's prediction, from a fixed list."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": ["kind", "name", "detail", "path", "pageId"],
                    "additionalProperties": false,
                    "description": "The robot_experiment_tried action, with its one detail."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "attempt",
                        "description": "A mission attempt ended."
                      },
                      "mission": {
                        "type": "string",
                        "enum": [
                          "robot-connect",
                          "robot-tool",
                          "robot-build",
                          "robot-key",
                          "robot-observe",
                          "garden-rules",
                          "garden-teach"
                        ],
                        "description": "Which mission, from a fixed list."
                      },
                      "version": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 999,
                        "description": "The version of that mission’s content."
                      },
                      "variant": {
                        "type": "string",
                        "enum": [
                          "first",
                          "supplied",
                          "grab",
                          "start-key",
                          "moved-key",
                          "changed-room",
                          "changed-order",
                          "stray-step",
                          "fault-again",
                          "fault-unpointed",
                          "told",
                          "find-key",
                          "out-of-reach",
                          "lights-out",
                          "starter",
                          "zero-health",
                          "visitor-rule",
                          "changed-effect",
                          "own-drawings",
                          "visitor-cloud",
                          "new-style",
                          "windy-rain"
                        ],
                        "description": "Which of the mission’s challenges, from a fixed list."
                      },
                      "role": {
                        "type": "string",
                        "enum": ["practice", "transfer"],
                        "description": "Whether the challenge was practice or a changed challenge."
                      },
                      "concept": {
                        "type": "string",
                        "enum": [
                          "model-and-tool",
                          "recipe-and-description",
                          "information",
                          "training",
                          "prediction-and-rule",
                          "testing"
                        ],
                        "description": "Which idea it is about, from a fixed list."
                      },
                      "action": {
                        "type": "string",
                        "enum": [
                          "sent-request",
                          "tested-tool",
                          "built-tool",
                          "repaired-recipe",
                          "restored-capability",
                          "supplied-information",
                          "predicted",
                          "added-examples",
                          "trained",
                          "changed-words",
                          "removed-examples",
                          "changed-rule",
                          "tested-unfamiliar",
                          "explained"
                        ],
                        "description": "What kind of thing the learner did, from a fixed list."
                      },
                      "outcome": {
                        "type": "string",
                        "enum": ["succeeded", "not-yet", "stopped", "system-failure"],
                        "description": "What happened, including whether the app or model failed rather than the learner."
                      },
                      "guidance": {
                        "type": "string",
                        "enum": ["none", "goal-reminder", "nudge", "clue", "demonstration"],
                        "description": "The most help the app showed, from a fixed list."
                      },
                      "mode": {
                        "type": "string",
                        "enum": ["live", "scripted", "browser-classifier", "none"],
                        "description": "What answered: a live model, the scripted demo, or none."
                      },
                      "path": {
                        "type": "string",
                        "enum": ["/"],
                        "description": "The page the count is for. Only the home page is counted."
                      },
                      "pageId": {
                        "type": "string",
                        "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
                        "description": "A random version 4 UUID made for this page view and kept only in memory; it is not stored or linked to a person."
                      }
                    },
                    "required": [
                      "kind",
                      "mission",
                      "version",
                      "variant",
                      "role",
                      "concept",
                      "action",
                      "outcome",
                      "guidance",
                      "mode",
                      "path",
                      "pageId"
                    ],
                    "additionalProperties": false,
                    "description": "A mission attempt, as fixed fields only. It never says what the learner made, typed or drew."
                  }
                ]
              },
              "examples": {
                "pageview": {
                  "summary": "A page view",
                  "value": {
                    "kind": "pageview",
                    "path": "/",
                    "referrer": "direct",
                    "pageId": "0b9e3c2a-5f1d-4e7a-9c3b-2d4f6a8e1b7c"
                  }
                },
                "action": {
                  "summary": "An action with its detail",
                  "value": {
                    "kind": "action",
                    "name": "robot_lesson_started",
                    "detail": "words",
                    "path": "/",
                    "pageId": "0b9e3c2a-5f1d-4e7a-9c3b-2d4f6a8e1b7c"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Counted, or deliberately not counted because the request carried `Sec-GPC: 1`. No body.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            }
          },
          "400": {
            "description": "Bad request. `invalid_json` (status `invalid`): The body is not UTF-8 JSON. `invalid_request` (status `invalid`): The body does not match the request schema.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "invalid",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "invalid_json",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body is not UTF-8 JSON."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "invalid",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "invalid_request",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body does not match the request schema."
                    }
                  ]
                },
                "examples": {
                  "notJson": {
                    "summary": "The body is not UTF-8 JSON.",
                    "value": {
                      "status": "invalid",
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body is not valid UTF-8 JSON.",
                        "hint": "Send one JSON object encoded as UTF-8."
                      }
                    }
                  },
                  "invalid": {
                    "summary": "The body does not match the request schema.",
                    "value": {
                      "status": "invalid",
                      "error": {
                        "code": "invalid_request",
                        "message": "The request body does not match what this endpoint accepts.",
                        "hint": "Check the request body schema in https://hellosparks.app/openapi.json; unknown fields are refused."
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden. `forbidden_origin` (status `forbidden`): The Origin header is missing or is not this site, or the request is cross-site.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "forbidden",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "forbidden_origin",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The Origin header is missing or is not this site, or the request is cross-site."
                },
                "examples": {
                  "forbidden": {
                    "summary": "The Origin header is missing or is not this site, or the request is cross-site.",
                    "value": {
                      "status": "forbidden",
                      "error": {
                        "code": "forbidden_origin",
                        "message": "This endpoint only answers requests from pages on this same site.",
                        "hint": "It is the site’s own endpoint, called by its pages; requests with no Origin, or whose Origin is another site, are refused."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed. `method_not_allowed` (status `method`): The request is not a POST.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              },
              "Allow": {
                "description": "The accepted method.",
                "required": true,
                "schema": {"type": "string", "const": "POST"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "method",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "method_not_allowed",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The request is not a POST."
                },
                "examples": {
                  "method": {
                    "summary": "The request is not a POST.",
                    "value": {
                      "status": "method",
                      "error": {
                        "code": "method_not_allowed",
                        "message": "This endpoint only accepts POST.",
                        "hint": "Send a POST request with a JSON body; the Allow header lists the accepted method."
                      }
                    }
                  }
                }
              }
            }
          },
          "408": {
            "description": "Request timeout. `request_timeout` (status `timeout`): The body did not arrive in time. `body_read_failed` (status `timeout`): The body broke off before it was all read.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "timeout",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "request_timeout",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body did not arrive in time."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "timeout",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "body_read_failed",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The body broke off before it was all read."
                    }
                  ]
                },
                "examples": {
                  "timeout": {
                    "summary": "The body did not arrive in time.",
                    "value": {
                      "status": "timeout",
                      "error": {
                        "code": "request_timeout",
                        "message": "The request body did not arrive in time.",
                        "hint": "Send the whole body promptly, then try again."
                      }
                    }
                  },
                  "bodyRead": {
                    "summary": "The body broke off before it was all read.",
                    "value": {
                      "status": "timeout",
                      "error": {
                        "code": "body_read_failed",
                        "message": "The request body broke off before it was all read.",
                        "hint": "Send the request again."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large. `payload_too_large` (status `too-large`): The body is larger than the limit.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "too-large",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "payload_too_large",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The body is larger than the limit."
                },
                "examples": {
                  "tooLarge": {
                    "summary": "The body is larger than the limit.",
                    "value": {
                      "status": "too-large",
                      "error": {
                        "code": "payload_too_large",
                        "message": "The request body is too large.",
                        "hint": "Keep the body within the size limit given in https://hellosparks.app/openapi.json."
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Unsupported media type. `unsupported_media_type` (status `media-type`): The Content-Type is not application/json.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "media-type",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "unsupported_media_type",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The Content-Type is not application/json."
                },
                "examples": {
                  "mediaType": {
                    "summary": "The Content-Type is not application/json.",
                    "value": {
                      "status": "media-type",
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "The request body must be JSON.",
                        "hint": "Send the header Content-Type: application/json."
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. `busy` (status `busy`): Too many counts are being passed on at once by this server instance.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "busy",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "busy",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "Too many counts are being passed on at once by this server instance."
                },
                "examples": {
                  "busy": {
                    "summary": "Too many counts are being passed on at once by this server instance.",
                    "value": {
                      "status": "busy",
                      "error": {
                        "code": "busy",
                        "message": "This endpoint is busy with other requests.",
                        "hint": "Try again shortly. If a Retry-After header is present, wait that many seconds first."
                      }
                    }
                  }
                }
              }
            }
          },
          "499": {
            "description": "Client closed request. `client_closed_request` (status `cancelled`): The caller went away before the count was passed on.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "cancelled",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "client_closed_request",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "The caller went away before the count was passed on."
                },
                "examples": {
                  "cancelled": {
                    "summary": "The caller went away before the count was passed on.",
                    "value": {
                      "status": "cancelled",
                      "error": {
                        "code": "client_closed_request",
                        "message": "The request was cancelled before it finished.",
                        "hint": "Nothing was done. Send it again if it is still wanted."
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. `internal_error` (status `unavailable`): A fault in this service.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "unavailable",
                      "description": "The short status word the app’s own pages read. Kept for compatibility."
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "internal_error",
                          "description": "Stable, machine-readable reason. Branch on this, not on the message."
                        },
                        "message": {
                          "type": "string",
                          "description": "What went wrong, in plain words."
                        },
                        "hint": {
                          "type": "string",
                          "description": "What the caller can do about it."
                        }
                      },
                      "required": ["code", "message", "hint"],
                      "additionalProperties": false,
                      "description": "Why there is no answer."
                    }
                  },
                  "required": ["status", "error"],
                  "additionalProperties": false,
                  "description": "A fault in this service."
                },
                "examples": {
                  "internal": {
                    "summary": "A fault in this service.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "internal_error",
                        "message": "Something went wrong on the server.",
                        "hint": "Try again later."
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable. `misconfigured` (status `misconfigured`): Counting is switched on but its server settings are incomplete. `disabled` (status `disabled`): Counting is switched off on this deployment (the default). `unavailable` (status `unavailable`): The counting service did not accept the count, or could not be reached in time.",
            "headers": {
              "Cache-Control": {
                "description": "Always `no-store`: answers are never cached.",
                "schema": {"type": "string", "const": "no-store"}
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "misconfigured",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "misconfigured",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "Counting is switched on but its server settings are incomplete."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "disabled",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "disabled",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "Counting is switched off on this deployment (the default)."
                    },
                    {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "const": "unavailable",
                          "description": "The short status word the app’s own pages read. Kept for compatibility."
                        },
                        "error": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "const": "unavailable",
                              "description": "Stable, machine-readable reason. Branch on this, not on the message."
                            },
                            "message": {
                              "type": "string",
                              "description": "What went wrong, in plain words."
                            },
                            "hint": {
                              "type": "string",
                              "description": "What the caller can do about it."
                            }
                          },
                          "required": ["code", "message", "hint"],
                          "additionalProperties": false,
                          "description": "Why there is no answer."
                        }
                      },
                      "required": ["status", "error"],
                      "additionalProperties": false,
                      "description": "The counting service did not accept the count, or could not be reached in time."
                    }
                  ]
                },
                "examples": {
                  "misconfigured": {
                    "summary": "Counting is switched on but its server settings are incomplete.",
                    "value": {
                      "status": "misconfigured",
                      "error": {
                        "code": "misconfigured",
                        "message": "This endpoint is switched on but not fully set up.",
                        "hint": "Nothing to fix on your side, and trying again will not help until the site owner finishes setting it up."
                      }
                    }
                  },
                  "disabled": {
                    "summary": "Counting is switched off on this deployment (the default).",
                    "value": {
                      "status": "disabled",
                      "error": {
                        "code": "disabled",
                        "message": "This endpoint is switched off on this deployment.",
                        "hint": "Nothing to fix on your side. It may be switched on later."
                      }
                    }
                  },
                  "unavailable": {
                    "summary": "The counting service did not accept the count, or could not be reached in time.",
                    "value": {
                      "status": "unavailable",
                      "error": {
                        "code": "unavailable",
                        "message": "This endpoint cannot answer right now.",
                        "hint": "Try again later."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "A short status word, kept for compatibility."
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "not_found",
                  "method_not_allowed",
                  "disabled",
                  "paused",
                  "misconfigured",
                  "unavailable",
                  "forbidden_origin",
                  "unsupported_media_type",
                  "payload_too_large",
                  "invalid_json",
                  "invalid_request",
                  "request_timeout",
                  "body_read_failed",
                  "client_closed_request",
                  "rate_limited",
                  "busy",
                  "daily_limit",
                  "spend_paused",
                  "model_busy",
                  "model_unavailable",
                  "model_timeout",
                  "model_no_answer",
                  "internal_error"
                ],
                "description": "Stable, machine-readable reason. Branch on this, not on the message."
              },
              "message": {"type": "string", "description": "What went wrong, in plain words."},
              "hint": {"type": "string", "description": "What the caller can do about it."}
            },
            "required": ["code", "message", "hint"],
            "additionalProperties": false,
            "description": "Why there is no answer."
          }
        },
        "required": ["status", "error"],
        "additionalProperties": false,
        "description": "The shape of every error this API itself returns."
      }
    },
    "responses": {
      "NotFound": {
        "description": "Any /api/* address with no endpoint, for any method. The hint points to https://hellosparks.app/openapi.json.",
        "headers": {
          "Cache-Control": {
            "description": "Always `no-store`: answers are never cached.",
            "schema": {"type": "string", "const": "no-store"}
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string",
                  "const": "not-found",
                  "description": "The short status word the app’s own pages read. Kept for compatibility."
                },
                "error": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string",
                      "const": "not_found",
                      "description": "Stable, machine-readable reason. Branch on this, not on the message."
                    },
                    "message": {
                      "type": "string",
                      "description": "What went wrong, in plain words."
                    },
                    "hint": {"type": "string", "description": "What the caller can do about it."}
                  },
                  "required": ["code", "message", "hint"],
                  "additionalProperties": false,
                  "description": "Why there is no answer."
                }
              },
              "required": ["status", "error"],
              "additionalProperties": false,
              "description": "There is no endpoint at this address."
            },
            "example": {
              "status": "not-found",
              "error": {
                "code": "not_found",
                "message": "There is no API endpoint at this address.",
                "hint": "See https://hellosparks.app/openapi.json for the endpoints this site has."
              }
            }
          }
        }
      }
    }
  }
}
