{
  "openapi": "3.0.3",
  "info": {
    "title": "ManualLens API",
    "version": "1.0.0",
    "description": "Answers about your household devices from your own manual, with the page. Save a device, add its manual, ask a question such as \"E4 flashes, what do I do?\" and get an answer in which every quote is copied from the manual and every citation names the page it is printed on, checked in code before you see it. Unsafe requests (gas, mains electricity, refrigerant, opening the casing, bypassing safety devices) are refused with a fixed safety notice, and when the manual does not say, the answer says so. One unit is billed per delivered answer; refused and unanswered questions, reading photos, manuals, feedback and confirming are free. Authenticate with an API key created on your dashboard (Authorization: Bearer or X-API-Key).",
    "contact": {
      "name": "Sensifai BV",
      "url": "https://manuallens.sensifai.com"
    }
  },
  "servers": [
    {
      "url": "https://manuallens.sensifai.com/api/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "apiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Devices"
    },
    {
      "name": "Manuals"
    },
    {
      "name": "Questions"
    },
    {
      "name": "Jobs"
    }
  ],
  "paths": {
    "/devices": {
      "get": {
        "operationId": "listDevices",
        "summary": "List your devices",
        "description": "Every device you saved, with whether questions can be asked yet.",
        "tags": [
          "Devices"
        ],
        "responses": {
          "200": {
            "description": "Devices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "devices": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Device"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "0"
              ]
            },
            "description": "0 hides archived devices."
          }
        ]
      },
      "post": {
        "operationId": "createDevice",
        "summary": "Save a device",
        "description": "Save a device by its confirmed brand and model (typed, or read from a label photo on the dashboard and confirmed). `confirmed` must be true.",
        "tags": [
          "Devices"
        ],
        "responses": {
          "201": {
            "description": "The device",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Device"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/NotConfirmed"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceInput"
              }
            }
          }
        }
      }
    },
    "/devices/{id}": {
      "get": {
        "operationId": "getDevice",
        "summary": "Get a device",
        "description": "One device with its manuals.",
        "tags": [
          "Devices"
        ],
        "responses": {
          "200": {
            "description": "The device and its manuals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "device": {
                      "$ref": "#/components/schemas/Device"
                    },
                    "manuals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Manual"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Device id"
          }
        ]
      },
      "delete": {
        "operationId": "deleteDevice",
        "summary": "Delete a device",
        "description": "Deletes the device with its manuals, questions and history.",
        "tags": [
          "Devices"
        ],
        "responses": {
          "200": {
            "description": "What was removed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "$ref": "#/components/schemas/Removed"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Device id"
          }
        ]
      }
    },
    "/devices/{id}/manuals": {
      "get": {
        "operationId": "listManuals",
        "summary": "List a device's manuals",
        "description": "The manuals of one device, with how each matched its model.",
        "tags": [
          "Manuals"
        ],
        "responses": {
          "200": {
            "description": "Manuals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "manuals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Manual"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Device id"
          }
        ]
      },
      "post": {
        "operationId": "addManual",
        "summary": "Add a manual",
        "description": "Add the device's manual as a PDF (multipart, field `file`), as pasted text or as an allowed https link (JSON). You attest that you may use the document. A manual that does not name the device's model is stored but never used for answers (`reason`); pages without readable text come back as `advice`. Adding a manual is free. 200 for a manual already added.",
        "tags": [
          "Manuals"
        ],
        "responses": {
          "201": {
            "description": "The manual was added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddManualResult"
                }
              }
            }
          },
          "200": {
            "description": "The same manual was already added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddManualResult"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/NeedsConsent"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "415": {
            "$ref": "#/components/responses/Unsupported"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Device id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/AddManualUpload"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddManualText"
              }
            }
          }
        }
      }
    },
    "/manuals/{id}": {
      "delete": {
        "operationId": "deleteManual",
        "summary": "Delete a manual",
        "description": "Deletes one manual and its text.",
        "tags": [
          "Manuals"
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Manual id"
          }
        ]
      }
    },
    "/questions": {
      "post": {
        "operationId": "askQuestion",
        "summary": "Ask a question",
        "description": "Ask a question about a device, answered only from its manual. Unsafe requests are refused and questions the manual does not cover are abstained: both are answered at once (201) and never billed. Otherwise an answer job is queued (202); poll it. One unit is billed only when a verified answer (answered or partial) is delivered.",
        "tags": [
          "Questions"
        ],
        "responses": {
          "201": {
            "description": "Decided at once (refused or abstained), not billed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Question"
                }
              }
            }
          },
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "A retry with the same key returns the job it started, never a second one."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AskInput"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listQuestions",
        "summary": "List questions",
        "description": "Your questions, newest first.",
        "tags": [
          "Questions"
        ],
        "responses": {
          "200": {
            "description": "Questions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "questions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/QuestionSummary"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "device",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only this device."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only this state."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Text search."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "description": "Page size (default 30)."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Rows to skip."
          }
        ]
      }
    },
    "/questions/{id}": {
      "get": {
        "operationId": "getQuestion",
        "summary": "Get a question",
        "description": "The question with its verified result: answers, quotes copied from the manual, citations with page numbers, steps, safety notice and the 30 checks.",
        "tags": [
          "Questions"
        ],
        "responses": {
          "200": {
            "description": "The question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Question"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Question id"
          },
          {
            "name": "revision",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "A specific revision number."
          }
        ]
      },
      "delete": {
        "operationId": "deleteQuestion",
        "summary": "Delete a question",
        "description": "Deletes the question, its revisions, feedback and history row.",
        "tags": [
          "Questions"
        ],
        "responses": {
          "200": {
            "description": "What was removed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "$ref": "#/components/schemas/Removed"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Question id"
          }
        ]
      }
    },
    "/questions/{id}/feedback": {
      "post": {
        "operationId": "questionFeedback",
        "summary": "Send feedback",
        "description": "Tell us whether the answer helped. Free.",
        "tags": [
          "Questions"
        ],
        "responses": {
          "201": {
            "description": "Recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Feedback"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Invalid"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Question id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackInput"
              }
            }
          }
        }
      }
    },
    "/questions/{id}/confirm": {
      "post": {
        "operationId": "confirmQuestion",
        "summary": "Confirm an answer",
        "description": "Makes the latest revision final. Refused while a hard check fails, and for abstained or refused results. Free.",
        "tags": [
          "Questions"
        ],
        "responses": {
          "200": {
            "description": "The confirmed question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Question"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/NotConfirmed"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Question id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "description": "Send {} with Content-Type: application/json (writes are JSON)."
              }
            }
          }
        }
      }
    },
    "/questions/{id}/recheck": {
      "post": {
        "operationId": "recheckQuestion",
        "summary": "Ask again",
        "description": "Asks the stored question again, against the current manual or the one named. Billed like a new question, only when a verified answer is delivered.",
        "tags": [
          "Questions"
        ],
        "responses": {
          "201": {
            "description": "Decided at once, not billed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Question"
                }
              }
            }
          },
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Accepted"
                }
              }
            }
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Question id"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "A retry with the same key returns the job it started, never a second one."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecheckInput"
              }
            }
          }
        }
      }
    },
    "/jobs/{id}": {
      "get": {
        "operationId": "getJob",
        "summary": "Get a job",
        "description": "Poll a job. An answer job ends succeeded (the question holds the result), failed or cancelled; neither of the last two is charged.",
        "tags": [
          "Jobs"
        ],
        "responses": {
          "200": {
            "description": "The job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Job id"
          }
        ]
      }
    },
    "/jobs/{id}/cancel": {
      "post": {
        "operationId": "cancelJob",
        "summary": "Cancel a job",
        "description": "Stops a queued or running job. A cancelled job bills nothing.",
        "tags": [
          "Jobs"
        ],
        "responses": {
          "200": {
            "description": "The job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooMany"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Job id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "description": "Send {} with Content-Type: application/json (writes are JSON)."
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer $MANUALLENS_KEY"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "INVALID_INPUT",
              "NEEDS_CONSENT",
              "UNSUPPORTED",
              "QUOTA_EXCEEDED",
              "PROVIDER_UNAVAILABLE",
              "NOT_FOUND",
              "NOT_CONFIRMED",
              "CONFLICT",
              "GONE",
              "PAYMENT_REQUIRED",
              "FORBIDDEN",
              "UNAUTHORIZED",
              "INTERNAL"
            ]
          },
          "timestamp": {
            "type": "integer"
          },
          "subscribe_url": {
            "type": "string",
            "description": "Where to subscribe (403 without an active subscription)."
          },
          "top_up_url": {
            "type": "string",
            "description": "Where to top up the prepaid wallet (402)."
          }
        },
        "required": [
          "title",
          "status",
          "code"
        ],
        "description": "RFC 7807 problem (application/problem+json) with a stable code."
      },
      "Device": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "nickname": {
            "type": "string"
          },
          "brand": {
            "type": "string"
          },
          "model": {
            "type": "string",
            "description": "The model string the customer confirmed; it never changes."
          },
          "model_norm": {
            "type": "string",
            "description": "The model string normalised for matching."
          },
          "region": {
            "type": "string"
          },
          "revision": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "typed",
              "label",
              "label_edited"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "manuals": {
            "type": "integer"
          },
          "questions": {
            "type": "integer"
          },
          "last_question_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "current_manual_id": {
            "type": "string",
            "description": "The manual questions are answered from; empty until a matching manual is added."
          },
          "can_ask": {
            "type": "boolean",
            "description": "True once the device has a current manual that names its model."
          },
          "ask_blocker": {
            "type": "string",
            "description": "One sentence saying what is missing when can_ask is false."
          }
        },
        "required": [
          "id",
          "brand",
          "model",
          "source",
          "can_ask"
        ]
      },
      "DeviceInput": {
        "type": "object",
        "properties": {
          "nickname": {
            "type": "string"
          },
          "brand": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "revision": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "typed",
              "label",
              "label_edited"
            ]
          },
          "confirmed": {
            "type": "boolean",
            "description": "Must be true: nothing is ever answered about a guessed model."
          }
        },
        "required": [
          "brand",
          "model",
          "confirmed"
        ]
      },
      "MatchResult": {
        "type": "object",
        "properties": {
          "level": {
            "type": "string",
            "enum": [
              "exact",
              "family",
              "mismatch"
            ],
            "description": "exact: the model string is printed in the manual; family: only its base is (the customer confirms it before asking); mismatch: stored but never used for answers."
          },
          "pages": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "found": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "confirmed": {
            "type": "boolean",
            "description": "family only: the customer confirmed it is the manual of their model (needed before asking)."
          }
        },
        "required": [
          "level"
        ]
      },
      "Manual": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "device_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "version_label": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "pdf",
              "text",
              "ocr",
              "url"
            ]
          },
          "source_url": {
            "type": "string"
          },
          "rights_state": {
            "type": "string"
          },
          "content_hash": {
            "type": "string"
          },
          "bytes": {
            "type": "integer"
          },
          "page_count": {
            "type": "integer"
          },
          "readable_pages": {
            "type": "integer"
          },
          "empty_pages": {
            "type": "integer"
          },
          "garble_pages": {
            "type": "integer"
          },
          "page_quality": {
            "type": "string",
            "description": "One letter per page: o readable, e empty (a scan), g unreadable text layer."
          },
          "language": {
            "type": "string"
          },
          "error_codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "match": {
            "$ref": "#/components/schemas/MatchResult"
          },
          "current": {
            "type": "boolean"
          },
          "has_pdf": {
            "type": "boolean",
            "description": "True when the original PDF is kept (only on request)."
          },
          "chunks": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "match_level": {
            "type": "string"
          },
          "needs_confirmation": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "device_id",
          "match",
          "current"
        ]
      },
      "AddManualText": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "The pasted text of the manual (at most 2 MB)."
          },
          "url": {
            "type": "string",
            "description": "An https link on an allowed host (instead of text)."
          },
          "title": {
            "type": "string"
          },
          "version_label": {
            "type": "string"
          },
          "rights_attested": {
            "type": "boolean",
            "description": "Must be true: you may use this document for your own device."
          },
          "consent": {
            "type": "boolean",
            "description": "Grants the manuals consent if it is not active yet."
          },
          "keep_pdf": {
            "type": "boolean"
          }
        },
        "required": [
          "rights_attested"
        ]
      },
      "AddManualUpload": {
        "type": "object",
        "properties": {
          "file": {
            "type": "string",
            "format": "binary",
            "description": "The manual as a PDF (checked by its bytes)."
          },
          "title": {
            "type": "string"
          },
          "version_label": {
            "type": "string"
          },
          "rights_attested": {
            "type": "string",
            "enum": [
              "true"
            ]
          },
          "consent": {
            "type": "string"
          },
          "keep_pdf": {
            "type": "string"
          }
        },
        "required": [
          "file",
          "rights_attested"
        ]
      },
      "AddManualResult": {
        "type": "object",
        "properties": {
          "manual": {
            "$ref": "#/components/schemas/Manual"
          },
          "duplicate": {
            "type": "boolean"
          },
          "current": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "description": "Set when the manual was stored but is not used for answers (it does not name the model)."
          },
          "advice": {
            "type": "string",
            "description": "Set when some pages have no readable text: photograph them."
          }
        },
        "required": [
          "manual",
          "duplicate",
          "current"
        ]
      },
      "AskInput": {
        "type": "object",
        "properties": {
          "device_id": {
            "type": "string"
          },
          "question": {
            "type": "string",
            "maxLength": 500
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "de",
              "fa"
            ]
          },
          "manual_id": {
            "type": "string",
            "description": "Ask against this manual of the device instead of the current one."
          },
          "consent": {
            "type": "boolean",
            "description": "Grants the analysis consent if it is not active yet."
          }
        },
        "required": [
          "device_id",
          "question"
        ]
      },
      "RecheckInput": {
        "type": "object",
        "properties": {
          "manual_id": {
            "type": "string"
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "de",
              "fa"
            ]
          },
          "consent": {
            "type": "boolean"
          }
        },
        "description": "May be {}; the body must still be JSON."
      },
      "FeedbackInput": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "helpful",
              "wrong_page",
              "unsafe",
              "unclear",
              "not_answered"
            ]
          },
          "note": {
            "type": "string",
            "maxLength": 300
          }
        },
        "required": [
          "kind"
        ]
      },
      "Feedback": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "question_id": {
            "type": "string"
          },
          "revision_no": {
            "type": "integer"
          },
          "kind": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "kind"
        ]
      },
      "Accepted": {
        "type": "object",
        "properties": {
          "job_id": {
            "type": "string"
          },
          "question_id": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "poll": {
            "type": "string",
            "description": "The job to poll (also in the Location header)."
          }
        },
        "required": [
          "job_id",
          "state",
          "poll"
        ]
      },
      "ReadResult": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "label",
              "display",
              "pages"
            ]
          },
          "readable": {
            "type": "boolean"
          },
          "brand": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "model_printed": {
            "type": "boolean",
            "description": "True when the model string occurs in the lines read; a proposal only, never saved as confirmed."
          },
          "revision": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "transcript": {
            "type": "string"
          },
          "unknowns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "read",
              "answer"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed",
              "needs_input",
              "cancelled"
            ]
          },
          "message": {
            "type": "string",
            "description": "Why a job failed or was cancelled; nothing is charged for either."
          },
          "mode": {
            "type": "string"
          },
          "device_id": {
            "type": "string"
          },
          "question_id": {
            "type": "string",
            "nullable": true
          },
          "read": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ReadResult"
              }
            ],
            "description": "For a succeeded read: a proposal to confirm, never saved as confirmed."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "charged": {
            "type": "boolean",
            "description": "True when this job reported usage (a delivered answer)."
          },
          "units": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "kind",
          "state",
          "charged",
          "units"
        ]
      },
      "AnswerItem": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "chunk_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "quote": {
            "type": "string",
            "description": "Copied verbatim from the manual, at most 25 words."
          },
          "quote_from": {
            "type": "string"
          }
        }
      },
      "Citation": {
        "type": "object",
        "properties": {
          "chunk_id": {
            "type": "string"
          },
          "page": {
            "type": "integer",
            "description": "The page of the manual the passage is printed on."
          },
          "heading": {
            "type": "string"
          },
          "excerpt": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "pdf",
              "text",
              "ocr"
            ]
          }
        }
      },
      "Step": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "chunk_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "done": {
            "type": "boolean",
            "description": "Your own tick."
          }
        }
      },
      "Unknown": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          }
        }
      },
      "Safety": {
        "type": "object",
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "refused": {
            "type": "boolean"
          },
          "service_advised": {
            "type": "boolean"
          },
          "notice": {
            "type": "string",
            "description": "A fixed, reviewed safety sentence."
          },
          "dropped_steps": {
            "type": "integer"
          }
        }
      },
      "RetrievedRef": {
        "type": "object",
        "properties": {
          "chunk_id": {
            "type": "string"
          },
          "page": {
            "type": "integer"
          },
          "score": {
            "type": "number"
          },
          "code_hit": {
            "type": "boolean"
          }
        }
      },
      "Provenance": {
        "type": "object",
        "properties": {
          "engine": {
            "type": "string"
          },
          "retrieval": {
            "type": "string"
          },
          "schema": {
            "type": "string"
          },
          "prompt": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "manual_hash": {
            "type": "string"
          },
          "manual_version": {
            "type": "string"
          }
        }
      },
      "Check": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "ok": {
            "type": "boolean"
          },
          "hard": {
            "type": "boolean",
            "description": "A failing hard check blocks confirm."
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "Result": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "answered",
              "partial",
              "abstained",
              "refused"
            ],
            "description": "Only answered and partial are billed."
          },
          "question": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnswerItem"
            }
          },
          "citations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Citation"
            }
          },
          "next_steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Step"
            }
          },
          "unknowns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Unknown"
            }
          },
          "safety": {
            "$ref": "#/components/schemas/Safety"
          },
          "retrieved": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RetrievedRef"
            }
          },
          "error_codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "match": {
            "$ref": "#/components/schemas/MatchResult"
          },
          "provenance": {
            "$ref": "#/components/schemas/Provenance"
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            },
            "description": "The 30 independent checks re-derived for this revision."
          },
          "notes": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "status",
          "checks"
        ]
      },
      "QuestionSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "device_id": {
            "type": "string"
          },
          "device_name": {
            "type": "string"
          },
          "manual_id": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "answering",
              "answered",
              "partial",
              "abstained",
              "refused",
              "failed"
            ]
          },
          "question": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "dashboard",
              "api"
            ]
          },
          "summary": {
            "type": "object",
            "description": "Counts for lists: status, answers, steps, pages, error codes, checks."
          },
          "revision_no": {
            "type": "integer"
          },
          "final_revision_no": {
            "type": "integer",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "job_id": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id",
          "device_id",
          "state",
          "question"
        ]
      },
      "Revision": {
        "type": "object",
        "properties": {
          "no": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "final"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Question": {
        "type": "object",
        "properties": {
          "question": {
            "$ref": "#/components/schemas/QuestionSummary"
          },
          "result": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Result"
              }
            ],
            "nullable": true,
            "description": "Null while the answer is being written."
          },
          "notice": {
            "type": "string"
          },
          "revisions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Revision"
            }
          },
          "final_revision_no": {
            "type": "integer",
            "nullable": true
          },
          "can_confirm": {
            "type": "boolean"
          },
          "can_export": {
            "type": "boolean"
          },
          "blockers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "billable": {
            "type": "boolean",
            "description": "True when this result is the kind that is billed (answered or partial)."
          },
          "feedback": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Feedback"
            }
          }
        },
        "required": [
          "question",
          "revisions",
          "can_confirm",
          "billable"
        ]
      },
      "Removed": {
        "type": "object",
        "properties": {
          "question_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "revisions": {
            "type": "integer"
          },
          "feedback": {
            "type": "integer"
          },
          "manuals": {
            "type": "integer"
          },
          "chunks": {
            "type": "integer"
          }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "No valid API key",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "TooMany": {
        "description": "QUOTA_EXCEEDED: the hourly limit was reached (Retry-After)",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "NotFound": {
        "description": "NOT_FOUND: no such object for your account",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Invalid": {
        "description": "INVALID_INPUT",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Conflict": {
        "description": "CONFLICT: for example the device has no manual that names its model",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "NotConfirmed": {
        "description": "NOT_CONFIRMED",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "NeedsConsent": {
        "description": "NEEDS_CONSENT",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Forbidden": {
        "description": "No active subscription (subscribe_url) or NEEDS_CONSENT",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "The prepaid wallet is empty (top_up_url)",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "TooLarge": {
        "description": "INVALID_INPUT: the file is too large",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Unsupported": {
        "description": "UNSUPPORTED: not a PDF, or not JSON",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    }
  }
}
