{
  "openapi": "3.1.0",
  "info": {
    "title": "Shiur Reader API",
    "version": "1",
    "summary": "Turn a Torah text and a shiur recording into a Reader, or into word Timings.",
    "description": "An Organization's software creates Builds with an API Key. A Build from a PDF makes a Reader\n(a page that highlights each printed word as it is spoken); a Build from a Word List makes Timings\n(the start and end of each word, for your own player).\n\nEvery error has the same shape: `{\"error\": {\"code\", \"message\", \"field\"?, \"problems\"?}}`.\nBranch on `code`, never on `message`.\n\nDocumentation: https://app.shiurreader.com/docs\n",
    "contact": {
      "name": "Shiur Reader",
      "url": "https://app.shiurreader.com/docs"
    }
  },
  "servers": [
    {
      "url": "https://app.shiurreader.com/api/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Builds",
      "description": "Create a Build and follow it until it is done or failed."
    },
    {
      "name": "Timings",
      "description": "The result of a Word List Build."
    },
    {
      "name": "Readers",
      "description": "Rename a Reader, set its Visibility, delete it, or get its data for a player of your own."
    }
  ],
  "paths": {
    "/builds": {
      "post": {
        "tags": [
          "Builds"
        ],
        "operationId": "createBuild",
        "summary": "Create a Build",
        "description": "Starts a Build and answers at once (202) with the Build. Poll its `url`, or pass a `webhook_url`.\n\nSend exactly one Source Text (`pdf`, `pdf_url` or `word_list`) and one Recording (`recording` or\n`recording_url`). Files need `multipart/form-data`; links and Word Lists can also be sent as JSON.\nA `pdf_url`, and a `recording_url` for a Stored Recording, are downloaded during this request.\n\nIf this month's Spending Cap is reached the Build is still accepted, with status `waiting` and\n`waiting_reason` `spending_cap_reached`.\n",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/CreateBuildForm"
              },
              "encoding": {
                "pdf": {
                  "contentType": "application/pdf"
                },
                "recording": {
                  "contentType": "audio/*"
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/CreateBuildLinksForm"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBuildJson"
              },
              "examples": {
                "pdfLinks": {
                  "summary": "PDF and Recording links",
                  "value": {
                    "title": "Lehavin 6",
                    "pdf_url": "https://example.org/files/lehavin-6.pdf",
                    "recording_url": "https://example.org/files/lehavin-6.mp3",
                    "visibility": "restricted"
                  }
                },
                "wordList": {
                  "summary": "A Word List with a Linked Recording",
                  "value": {
                    "title": "Bereishis 1",
                    "word_list": [
                      "בראשית",
                      "ברא",
                      "אלהים"
                    ],
                    "recording_url": "https://example.org/audio/bereishis-1.mp3",
                    "webhook_url": "https://example.org/hooks/shiur-reader"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The Build was accepted.",
            "headers": {
              "Location": {
                "description": "The Build's path, `/api/v1/builds/{build_id}`.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Build"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/builds/{build_id}": {
      "get": {
        "tags": [
          "Builds"
        ],
        "operationId": "getBuild",
        "summary": "Get a Build",
        "description": "The Build's status, progress and, once done, its Reader or Timings link.",
        "parameters": [
          {
            "$ref": "#/components/parameters/BuildId"
          }
        ],
        "responses": {
          "200": {
            "description": "The Build.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Build"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/builds/{build_id}/timings": {
      "get": {
        "tags": [
          "Timings"
        ],
        "operationId": "getTimings",
        "summary": "Get a Word List Build's Timings",
        "description": "One entry per word sent, in the same order. `position` is the word's index in the Word List\n(0 is the first word). A PDF Build has no Timings (404 `not_found`): get its words from\n`GET /readers/{reader_id}/data` (the Build's `reader_data_url`). A Build that is not done yet\nanswers 409 `not_ready`.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/BuildId"
          }
        ],
        "responses": {
          "200": {
            "description": "The Timings.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Timings"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`not_ready`: the Build is not done yet.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/readers/{reader_id}": {
      "patch": {
        "tags": [
          "Readers"
        ],
        "operationId": "changeReader",
        "summary": "Rename a Reader or set its Visibility",
        "description": "Send `title`, `visibility` or both, as JSON or a form. The Reader's link stays the same.\nIf any field is refused, nothing changes.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/ReaderId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeReader"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/ChangeReader"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/ChangeReader"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The Reader after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reader"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "tags": [
          "Readers"
        ],
        "operationId": "deleteReader",
        "summary": "Delete a Reader",
        "description": "Takes the Reader offline at once (its link then answers 410) and removes its files.\nAudio Hours are not refunded. The id is never reused; deleting again answers 404.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/ReaderId"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted. No body."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/readers/{reader_id}/data": {
      "get": {
        "tags": [
          "Readers"
        ],
        "operationId": "getReaderData",
        "summary": "Get Reader data, for a player of your own",
        "description": "Everything needed to show a Reader in your own player: page sizes, each printed word's text,\nbox and time, and links to the PDF and the audio. Works for Public and Restricted Readers alike:\nthe API Key is the authorization (no Allowed Site check).\n\nBoxes are in page pixels (the page rendered at 250 dpi); scale them by your rendered page width\ndivided by the page's `width`. `audio_url` and `pdf_url` are short-lived signed links: ask again\nafter `links_expire_at`. A Linked Recording's `audio_url` is your own address, which does not expire.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/ReaderId"
          }
        ],
        "responses": {
          "200": {
            "description": "The Reader data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReaderData"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API Key (`sr_...`), created by an Owner on the API Keys page."
      }
    },
    "parameters": {
      "BuildId": {
        "name": "build_id",
        "in": "path",
        "required": true,
        "description": "The Build's `id`.",
        "schema": {
          "type": "string",
          "example": "cd4e2fd751c84d659936cdf0e0002da0"
        }
      },
      "ReaderId": {
        "name": "reader_id",
        "in": "path",
        "required": true,
        "description": "The Reader's short id, `reader.id` in the Build (the end of its link).",
        "schema": {
          "type": "string",
          "example": "0dibrutk"
        }
      }
    },
    "schemas": {
      "Title": {
        "type": "string",
        "minLength": 1,
        "maxLength": 300,
        "description": "Shown on the Reader. Blank is `missing_title`; over 300 characters is `invalid_request`."
      },
      "Visibility": {
        "type": "string",
        "enum": [
          "public",
          "restricted"
        ],
        "description": "Public (anyone with the link) or Restricted (only embedded on the Organization's Allowed Sites)."
      },
      "WordList": {
        "type": "array",
        "minItems": 1,
        "maxItems": 100000,
        "items": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "description": "The Source Text as words in reading order, in Hebrew script (Hebrew or Aramaic)."
      },
      "RecordingStorage": {
        "type": "string",
        "enum": [
          "stored",
          "linked"
        ],
        "description": "`stored`: we keep a copy. `linked`: never copied; the Build and the Reader use `recording_url`.\nDefault: `linked` for a Word List sent with a `recording_url` and no file, otherwise `stored`.\n"
      },
      "HttpUrl": {
        "type": "string",
        "format": "uri",
        "maxLength": 2000
      },
      "CreateBuildJson": {
        "type": "object",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "$ref": "#/components/schemas/Title"
          },
          "visibility": {
            "$ref": "#/components/schemas/Visibility"
          },
          "pdf_url": {
            "$ref": "#/components/schemas/HttpUrl"
          },
          "word_list": {
            "$ref": "#/components/schemas/WordList"
          },
          "recording_url": {
            "$ref": "#/components/schemas/HttpUrl"
          },
          "recording_storage": {
            "$ref": "#/components/schemas/RecordingStorage"
          },
          "webhook_url": {
            "$ref": "#/components/schemas/HttpUrl"
          }
        }
      },
      "CreateBuildLinksForm": {
        "type": "object",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "$ref": "#/components/schemas/Title"
          },
          "visibility": {
            "$ref": "#/components/schemas/Visibility"
          },
          "pdf_url": {
            "$ref": "#/components/schemas/HttpUrl"
          },
          "word_list": {
            "type": "string",
            "description": "The Word List as JSON text, e.g. `[\"בראשית\",\"ברא\"]`."
          },
          "recording_url": {
            "$ref": "#/components/schemas/HttpUrl"
          },
          "recording_storage": {
            "$ref": "#/components/schemas/RecordingStorage"
          },
          "webhook_url": {
            "$ref": "#/components/schemas/HttpUrl"
          }
        }
      },
      "CreateBuildForm": {
        "type": "object",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "$ref": "#/components/schemas/Title"
          },
          "visibility": {
            "$ref": "#/components/schemas/Visibility"
          },
          "pdf": {
            "type": "string",
            "contentMediaType": "application/pdf",
            "description": "The PDF file (at most 25 pages and 50 MB)."
          },
          "pdf_url": {
            "$ref": "#/components/schemas/HttpUrl"
          },
          "word_list": {
            "type": "string",
            "description": "The Word List as JSON text, e.g. `[\"בראשית\",\"ברא\"]`."
          },
          "recording": {
            "type": "string",
            "contentMediaType": "audio/*",
            "description": "The Recording file (at most 4 hours and 300 MB). Always Stored."
          },
          "recording_url": {
            "$ref": "#/components/schemas/HttpUrl"
          },
          "recording_storage": {
            "$ref": "#/components/schemas/RecordingStorage"
          },
          "webhook_url": {
            "$ref": "#/components/schemas/HttpUrl"
          }
        }
      },
      "Build": {
        "type": "object",
        "required": [
          "id",
          "url",
          "title",
          "status",
          "waiting_reason",
          "progress",
          "failure_reason",
          "audio_hours",
          "visibility",
          "reader",
          "match",
          "timings_url",
          "reader_data_url",
          "created_at",
          "finished_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Where to poll this Build."
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "waiting",
              "queued",
              "running",
              "done",
              "failed"
            ]
          },
          "waiting_reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "spending_cap_reached",
              null
            ],
            "description": "Why a Build is `waiting`; null otherwise."
          },
          "progress": {
            "type": "object",
            "required": [
              "percent",
              "message"
            ],
            "properties": {
              "percent": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "message": {
                "type": "string"
              }
            }
          },
          "failure_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the Build failed, written for people; null unless `failed`."
          },
          "audio_hours": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Audio Hours billed, as a decimal string (\"1.5\"); \"0\" when failed or when `match.mismatch`; null until finished.",
            "example": "1.5"
          },
          "visibility": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "public",
              "restricted",
              null
            ],
            "description": "The Visibility asked for; null means the Organization's default."
          },
          "reader": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BuildReader"
              },
              {
                "type": "null"
              }
            ],
            "description": "The Reader a done PDF Build made; null for a Word List Build or until done."
          },
          "match": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BuildMatch"
              },
              {
                "type": "null"
              }
            ],
            "description": "How well the Source Text matched the Recording; null until done (and for a failed Build)."
          },
          "timings_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Set once a Word List Build is done."
          },
          "reader_data_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "The Reader data (GET /readers/{reader_id}/data) while the Build's Reader lives; null otherwise."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "BuildMatch": {
        "type": "object",
        "required": [
          "words_timed",
          "words_total",
          "pages_read",
          "audio_minutes_matched",
          "reading_spans",
          "mismatch"
        ],
        "properties": {
          "words_timed": {
            "type": "integer",
            "minimum": 0,
            "description": "Words heard in the Recording (timed, or filled between heard words)."
          },
          "words_total": {
            "type": "integer",
            "minimum": 0,
            "description": "All the words of the Source Text."
          },
          "pages_read": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1
            },
            "description": "PDF pages (1 is the first) with at least one heard word; empty for a Word List."
          },
          "audio_minutes_matched": {
            "type": "number",
            "minimum": 0,
            "description": "Minutes of the Recording inside `reading_spans`, to a tenth of a minute."
          },
          "reading_spans": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "minItems": 2,
              "maxItems": 2
            },
            "description": "Where in the Recording the reading was found, as [start, end] seconds, in order. Heard words less than 60 seconds apart are one span, so explanations between read lines stay inside it."
          },
          "mismatch": {
            "type": "boolean",
            "description": "The Source Text clearly does not match the Recording (fewer than 5% of its words and fewer than 30 words heard). The Reader or Timings are still made, but the Build counts 0 Audio Hours."
          }
        }
      },
      "BuildReader": {
        "type": "object",
        "required": [
          "id",
          "url",
          "deleted"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The Reader's short id, for /readers/{reader_id}."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "The Reader's link; null once the Reader is deleted."
          },
          "deleted": {
            "type": "boolean"
          }
        }
      },
      "Timings": {
        "type": "object",
        "required": [
          "build_id",
          "words"
        ],
        "properties": {
          "build_id": {
            "type": "string"
          },
          "words": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WordTiming"
            }
          }
        }
      },
      "WordTiming": {
        "type": "object",
        "required": [
          "position",
          "start",
          "end",
          "status"
        ],
        "properties": {
          "position": {
            "type": "integer",
            "minimum": 0,
            "description": "The word's index in the Word List (0 is the first word)."
          },
          "start": {
            "type": [
              "number",
              "null"
            ],
            "description": "Seconds from the start of the Recording; null when `not_read`."
          },
          "end": {
            "type": [
              "number",
              "null"
            ],
            "description": "Seconds from the start of the Recording; null when `not_read`."
          },
          "status": {
            "type": "string",
            "enum": [
              "timed",
              "filled",
              "not_read"
            ],
            "description": "`timed`: heard. `filled`: given the short gap between heard neighbours. `not_read`: not found in the Recording."
          }
        }
      },
      "ChangeReader": {
        "type": "object",
        "properties": {
          "title": {
            "$ref": "#/components/schemas/Title"
          },
          "visibility": {
            "$ref": "#/components/schemas/Visibility"
          }
        }
      },
      "Reader": {
        "type": "object",
        "required": [
          "id",
          "url",
          "title",
          "visibility"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "visibility": {
            "$ref": "#/components/schemas/Visibility"
          }
        }
      },
      "ReaderData": {
        "type": "object",
        "required": [
          "id",
          "title",
          "build_id",
          "duration_seconds",
          "visibility",
          "reader_url",
          "audio_url",
          "pdf_url",
          "links_expire_at",
          "pages",
          "words",
          "timing_status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The Reader's short id."
          },
          "title": {
            "type": "string"
          },
          "build_id": {
            "type": "string",
            "description": "The Build whose result the Reader shows (the latest Rebuild, if any)."
          },
          "duration_seconds": {
            "type": [
              "number",
              "null"
            ],
            "description": "The Recording's length in seconds."
          },
          "visibility": {
            "$ref": "#/components/schemas/Visibility"
          },
          "reader_url": {
            "type": "string",
            "format": "uri",
            "description": "The hosted Reader page."
          },
          "audio_url": {
            "type": "string",
            "format": "uri",
            "description": "A signed link to the audio (MP3) until `links_expire_at`, or a Linked Recording's own address."
          },
          "pdf_url": {
            "type": "string",
            "format": "uri",
            "description": "A signed link to the original PDF until `links_expire_at`."
          },
          "links_expire_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the signed links stop working (6 hours after the request). Ask again for fresh ones."
          },
          "pages": {
            "type": "array",
            "description": "The size of each page that has words, in the same pixel space as the word boxes.",
            "items": {
              "type": "object",
              "required": [
                "page",
                "width",
                "height"
              ],
              "properties": {
                "page": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "The PDF page number, from 1."
                },
                "width": {
                  "type": "integer"
                },
                "height": {
                  "type": "integer"
                }
              }
            }
          },
          "words": {
            "type": "array",
            "description": "Every printed word, in reading order.",
            "items": {
              "$ref": "#/components/schemas/ReaderWord"
            }
          },
          "timing_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "How the times were made. Today always `automatic_unverified` (no person has checked them)."
          }
        }
      },
      "ReaderWord": {
        "type": "object",
        "required": [
          "position",
          "text",
          "page",
          "box",
          "start",
          "end",
          "status"
        ],
        "properties": {
          "position": {
            "type": "integer",
            "minimum": 0,
            "description": "The word's index in reading order (0 is the first word); `words[i].position == i`."
          },
          "text": {
            "type": "string",
            "description": "The word as printed, with its vowels and punctuation."
          },
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "box": {
            "type": "object",
            "required": [
              "x",
              "y",
              "width",
              "height"
            ],
            "description": "The word's rectangle on its page, in page pixels from the top left corner.",
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              },
              "width": {
                "type": "number"
              },
              "height": {
                "type": "number"
              }
            }
          },
          "start": {
            "type": [
              "number",
              "null"
            ],
            "description": "Seconds from the start of the Recording; null when `not_read`."
          },
          "end": {
            "type": [
              "number",
              "null"
            ],
            "description": "Seconds from the start of the Recording; null when `not_read`."
          },
          "status": {
            "type": "string",
            "enum": [
              "timed",
              "filled",
              "not_read"
            ],
            "description": "As in Timings."
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "enum": [
          "invalid_request",
          "missing_title",
          "missing_source_text",
          "invalid_word_list",
          "invalid_recording_storage",
          "missing_recording",
          "invalid_visibility",
          "link_unreachable",
          "not_available_yet",
          "invalid_webhook_url",
          "unsupported_language",
          "invalid_api_key",
          "plan_required",
          "payment_overdue",
          "spending_cap_reached",
          "not_found",
          "not_ready",
          "file_too_large",
          "pdf_too_many_pages",
          "recording_too_long",
          "rate_limited"
        ]
      },
      "Problem": {
        "type": "object",
        "required": [
          "code",
          "message",
          "field"
        ],
        "properties": {
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "message": {
            "type": "string"
          },
          "field": {
            "type": "string",
            "enum": [
              "pdf",
              "recording",
              "word_list"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "$ref": "#/components/schemas/ErrorCode"
              },
              "message": {
                "type": "string",
                "description": "For people. Do not branch on it; it may change."
              },
              "field": {
                "type": "string",
                "description": "The request field the error is about, when there is one."
              },
              "problems": {
                "type": "array",
                "description": "Every limit an upload breaks, when it breaks more than one.",
                "items": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request was refused; see `error.code` and `error.field`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "missing_title",
                "message": "Give the Build a title.",
                "field": "title"
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "`invalid_api_key`: the API Key is missing, unknown or revoked.",
        "headers": {
          "WWW-Authenticate": {
            "schema": {
              "type": "string",
              "const": "Bearer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "`plan_required` (the Free Trial is used up) or `payment_overdue` (the Grace Period is over).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "`not_found`: no such Build or Reader in your Organization (or the Reader was deleted).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooLarge": {
        "description": "`file_too_large`, `pdf_too_many_pages` or `recording_too_long`. `problems` lists every limit broken.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "`rate_limited`: too many requests with this API Key.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before the next request.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "buildFinished": {
      "post": {
        "summary": "A Build is done or failed",
        "description": "Sent to the Build's `webhook_url`. Verify `Shiur-Reader-Signature` before trusting the body:\n`t=<unix seconds>,v1=<hex HMAC-SHA256(secret, \"<t>.\" + raw body)>`, and reject a `t` more than\n300 seconds away. Answer 2xx; otherwise we retry after 1 minute, 5 minutes, 30 minutes, 2 hours\nand 8 hours. `Shiur-Reader-Delivery` is the same on every retry.\n",
        "parameters": [
          {
            "name": "Shiur-Reader-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "example": "t=1791709200,v1=549e4e3a63e05fa87d1f61d4b6cce3a1805c5d61c5f028bd8029ddfb3c4ad7cf"
            }
          },
          {
            "name": "Shiur-Reader-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "build.done",
                "build.failed"
              ]
            }
          },
          {
            "name": "Shiur-Reader-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "event",
                  "delivery_id",
                  "created_at",
                  "build"
                ],
                "properties": {
                  "event": {
                    "type": "string",
                    "enum": [
                      "build.done",
                      "build.failed"
                    ]
                  },
                  "delivery_id": {
                    "type": "string"
                  },
                  "created_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "build": {
                    "$ref": "#/components/schemas/Build"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Any other answer (or none within 10 seconds) is retried."
          }
        }
      }
    }
  }
}