{
  "openapi": "3.1.0",
  "info": {
    "title": "FilesOkay API",
    "version": "1.0.0",
    "summary": "Upload files, run operations on them and download the results.",
    "description": "Every call is HTTPS and sends and receives JSON. Files never pass through this API: you\nupload each one in parts straight to storage, using the links an upload gives you, and you\ndownload results from the links a finished job gives you.\n\n**Authentication.** Send an API key from your Workspace's Settings as a Bearer token:\n`Authorization: Bearer filesokay_…`. A key acts in its own Workspace, so `workspace_id` is\nnever needed; if you send one, it must be the key's. The Workspace needs an active\nsubscription. `GET /v1/operations` needs no key.\n\n**IDs** start with what they name: `job_`, `task_`, `file_`, `wh_`, `msg_`. Send them back\nexactly as you received them.\n\n**Errors** are problem details (RFC 9457), with `Content-Type: application/problem+json`.\nAct on `code`, which never changes; `detail` is a sentence for people and may.\n\n**Safe retries.** `POST /v1/jobs` and `POST /v1/uploads` take an `Idempotency-Key` header.\nA retry with the same key and the same body does nothing twice, and is marked with\n`Idempotent-Replayed: true`. A retried upload gets the first answer again; a retried job\ngets the job as it is now, with status 200.\n\n**Rate limits.** Calls are counted per Workspace, per minute. Over the limit, the answer is\n429 with `Retry-After`, in seconds.\n",
    "contact": {
      "name": "FilesOkay",
      "url": "https://filesokay.com"
    }
  },
  "servers": [
    {
      "url": "https://api.filesokay.com"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Operations",
      "description": "What the API can do to files, and the settings each operation takes."
    },
    {
      "name": "Uploads",
      "description": "Getting files to us. Each file goes in parts, straight to storage."
    },
    {
      "name": "Files",
      "description": "An uploaded file, its check and its download link."
    },
    {
      "name": "Jobs",
      "description": "Running an operation on files. One job holds one task per file it runs."
    },
    {
      "name": "Credits",
      "description": "The Workspace's balance. Jobs reserve credits when they start and are charged when they end."
    },
    {
      "name": "Webhooks",
      "description": "Addresses we send a signed message to when a job ends or credits run low."
    }
  ],
  "paths": {
    "/v1/operations": {
      "get": {
        "tags": [
          "Operations"
        ],
        "operationId": "listOperations",
        "summary": "List the operations",
        "description": "Every operation, without its settings schema. Needs no key, and is the same for everyone.",
        "security": [],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "description": "Only this category's operations, such as `video`.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Only operations whose ID, name or description contains these words.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The operations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "operations"
                  ],
                  "properties": {
                    "operations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Operation"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/v1/operations/{id}": {
      "get": {
        "tags": [
          "Operations"
        ],
        "operationId": "getOperation",
        "summary": "Get an operation",
        "description": "One operation, with the JSON Schema its `settings` follow. Needs no key.",
        "security": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The operation's ID, such as `video.compress`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The operation.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Operation"
                    }
                  ],
                  "required": [
                    "settings_schema"
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/uploads": {
      "post": {
        "tags": [
          "Uploads"
        ],
        "operationId": "createUploads",
        "summary": "Start uploads",
        "description": "Starts one upload per file and gives the first part links for each. A file of up to 5 GB\ngets one link for the whole file: send it with `PUT` in one request. A larger file, or any\nfile when `multipart` is true, goes in parts: send each part with `PUT` to its `url`, as\nthe raw bytes of that part. Every part is `part_size` bytes except the last. Then call\ncomplete. The sizes and types are checked now, before anything is sent; the file's\ncontent is checked when it's complete.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "operation",
                  "files"
                ],
                "properties": {
                  "workspace_id": {
                    "$ref": "#/components/schemas/WorkspaceID"
                  },
                  "operation": {
                    "type": "string",
                    "description": "The operation the files are for. It decides the types and sizes allowed."
                  },
                  "files": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "name",
                        "size"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "The file's name, with its extension."
                        },
                        "size": {
                          "type": "integer",
                          "format": "int64",
                          "minimum": 1,
                          "description": "Its size in bytes."
                        },
                        "type": {
                          "type": "string",
                          "description": "Its media type, such as `video/mp4`, if you know it."
                        }
                      }
                    }
                  },
                  "multipart": {
                    "type": "boolean",
                    "default": false,
                    "description": "Send every file in parts, whatever its size. Without it, a file of up to 5 GB gets one link for the whole file."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The uploads, with each one's first part links.",
            "headers": {
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/IdempotentReplayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "files"
                  ],
                  "properties": {
                    "files": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Upload"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict",
            "description": "`idempotency_key_in_use`: a request with this Idempotency-Key is still running."
          },
          "413": {
            "$ref": "#/components/responses/FileProblems",
            "description": "`file_too_large`: a file is larger than the operation takes. `files` names each file\nwith a problem by its position in the request.\n"
          },
          "415": {
            "$ref": "#/components/responses/FileProblems",
            "description": "`unsupported_type`, or `file_too_large` when the first file with a problem is too\nlarge. `files` names each file with a problem by its position in the request.\n"
          },
          "422": {
            "$ref": "#/components/responses/FileProblems",
            "description": "`too_many_files`, `file_too_large`, `empty_file` or `unsupported_type`. `files` names\neach file with a problem by its position in the request. `idempotency_key_reused`:\nthis Idempotency-Key was used with a different body.\n"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/uploads/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/FileID"
        }
      ],
      "get": {
        "tags": [
          "Uploads"
        ],
        "operationId": "getUpload",
        "summary": "Get an upload's progress",
        "description": "The parts storage already has, so an interrupted upload sends only the missing ones.\nOnce the upload is complete, the answer is the file.\n",
        "responses": {
          "200": {
            "description": "The upload's progress, or the file once it's complete.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/UploadProgress"
                    },
                    {
                      "$ref": "#/components/schemas/File"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "tags": [
          "Uploads"
        ],
        "operationId": "cancelUpload",
        "summary": "Cancel an upload",
        "description": "Cancels the upload and discards the parts already sent.",
        "responses": {
          "204": {
            "description": "Cancelled."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/uploads/{id}/parts": {
      "parameters": [
        {
          "$ref": "#/components/parameters/FileID"
        }
      ],
      "post": {
        "tags": [
          "Uploads"
        ],
        "operationId": "getPartLinks",
        "summary": "Get more part links",
        "description": "Links for up to 100 parts at once, for a large file or links that expired.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "part_numbers"
                ],
                "properties": {
                  "part_numbers": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "type": "integer",
                      "minimum": 1
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The links.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "parts",
                    "links_expire_at"
                  ],
                  "properties": {
                    "parts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PartLink"
                      }
                    },
                    "links_expire_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict",
            "description": "`already_uploaded`: the upload is complete."
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/uploads/{id}/complete": {
      "parameters": [
        {
          "$ref": "#/components/parameters/FileID"
        }
      ],
      "post": {
        "tags": [
          "Uploads"
        ],
        "operationId": "completeUpload",
        "summary": "Complete an upload",
        "description": "Joins the parts and checks the file's content. The answer is the file with its check:\n`proceed` means an operation can use it. Calling it again gives the same answer.\nA part missing or of the wrong length is named in a 409 answer.\n",
        "responses": {
          "200": {
            "description": "The file and its check.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "`upload_incomplete`: some parts haven't arrived, or have the wrong length.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "missing_parts": {
                          "type": "array",
                          "items": {
                            "type": "integer"
                          },
                          "description": "Up to 100 of the missing parts."
                        },
                        "missing_count": {
                          "type": "integer"
                        },
                        "wrong_parts": {
                          "type": "array",
                          "items": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/v1/files/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/FileID"
        }
      ],
      "get": {
        "tags": [
          "Files"
        ],
        "operationId": "getFile",
        "summary": "Get a file",
        "description": "The file, its check and, once it's uploaded, a fresh download link. Each call gives a\nnew link, valid for the shorter of 7 days and the time left before the file is deleted.\n",
        "responses": {
          "200": {
            "description": "The file.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "delete": {
        "tags": [
          "Files"
        ],
        "operationId": "deleteFile",
        "summary": "Delete a file",
        "description": "Deletes the file now, from storage too.",
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/estimates": {
      "post": {
        "tags": [
          "Jobs"
        ],
        "operationId": "createEstimate",
        "summary": "Estimate a job",
        "description": "The same body as `POST /v1/jobs`. Answers the most the job can cost, which is what\nstarting it would reserve, and what would happen to each input, without running or\nreserving anything.\n",
        "requestBody": {
          "$ref": "#/components/requestBodies/Job"
        },
        "responses": {
          "200": {
            "description": "The estimate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Estimate"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/FilesUnusable",
            "description": "`files_unusable`: an operation that combines its files can't use one of them;\n`inputs` says which and why.\n"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable",
            "description": "`settings_invalid`: the settings don't match the operation's settings schema.\n`too_many_files`: more inputs than the operation takes.\n"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/jobs": {
      "post": {
        "tags": [
          "Jobs"
        ],
        "operationId": "createJob",
        "summary": "Start a job",
        "description": "Runs an operation on files: one task per input that runs, with its credits reserved.\nAn input that can't be used, or that the operation wouldn't change with these\nsettings, is skipped with its reason and costs nothing. When no input would run, the\nanswer is 422 `nothing_to_run`. Send an `Idempotency-Key`, so a retry never starts a\nsecond job.\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/Job"
        },
        "responses": {
          "200": {
            "description": "A retry with the same Idempotency-Key and body. The job, as it is now.",
            "headers": {
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/IdempotentReplayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "201": {
            "description": "The new job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "`insufficient_credits`: the Workspace hasn't enough credits for the reservation.\n`subscription_required`: it has no active subscription.\n",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "required_credits": {
                          "type": "integer",
                          "format": "int64"
                        },
                        "available_credits": {
                          "type": "integer",
                          "format": "int64"
                        },
                        "shortfall": {
                          "type": "integer",
                          "format": "int64"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/FilesUnusable"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests",
            "description": "`rate_limited`: wait the seconds in Retry-After. `too_many_file_operations`: the\nWorkspace already runs 100 jobs; start this one when one ends. This answer has no\nRetry-After.\n"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "get": {
        "tags": [
          "Jobs"
        ],
        "operationId": "listJobs",
        "summary": "List jobs",
        "description": "The jobs the Workspace's API keys started, newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "How many jobs a page holds.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "The `next_cursor` of the page before.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "client_reference",
            "in": "query",
            "description": "Only the jobs started with this `client_reference`.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          },
          {
            "$ref": "#/components/parameters/WorkspaceQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of jobs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "jobs",
                    "next_cursor"
                  ],
                  "properties": {
                    "jobs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Job"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Send it as `cursor` for the next page. Null on the last page."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/jobs/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/JobID"
        }
      ],
      "get": {
        "tags": [
          "Jobs"
        ],
        "operationId": "getJob",
        "summary": "Get a job",
        "description": "The job and its tasks. A completed task lists its results with download links, each\nvalid for up to 7 days; ask again for fresh ones. Webhooks tell you when a job ends,\nso you needn't ask repeatedly.\n",
        "responses": {
          "200": {
            "description": "The job.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/jobs/{id}/cancel": {
      "parameters": [
        {
          "$ref": "#/components/parameters/JobID"
        }
      ],
      "post": {
        "tags": [
          "Jobs"
        ],
        "operationId": "cancelJob",
        "summary": "Cancel a job",
        "description": "Stops the tasks still waiting or processing. A task that hadn't started costs nothing;\none that had is charged for the time it ran. Cancelling an ended job changes nothing.\n",
        "responses": {
          "202": {
            "description": "Cancelling. The job, as it is now.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/jobs/{id}/files": {
      "parameters": [
        {
          "$ref": "#/components/parameters/JobID"
        }
      ],
      "delete": {
        "tags": [
          "Jobs"
        ],
        "operationId": "deleteJobFiles",
        "summary": "Delete a job's files",
        "description": "Deletes the job's input and result files now, once it has ended. An input another\nrunning job uses is left to that job. The job and its record of credits stay.\n",
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict",
            "description": "`still_running`: cancel the job first."
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/credits": {
      "get": {
        "tags": [
          "Credits"
        ],
        "operationId": "getCredits",
        "summary": "Get the balance",
        "description": "The credits the Workspace can spend now. Credits reserved by running jobs aren't included.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "The balance.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "available_credits"
                  ],
                  "properties": {
                    "available_credits": {
                      "type": "integer",
                      "format": "int64",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/webhooks": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "createWebhook",
        "summary": "Add a webhook endpoint",
        "description": "Adds an HTTPS address on the public internet that we send signed messages to. The\nanswer holds the endpoint's signing secret: keep it, to check each message's\nsignature. A Workspace has up to 20 endpoints.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "url"
                ],
                "properties": {
                  "workspace_id": {
                    "$ref": "#/components/schemas/WorkspaceID"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "An `https://` address. Addresses on private networks are refused."
                  },
                  "events": {
                    "type": "array",
                    "description": "The events to send. Leave it out for all of them.",
                    "items": {
                      "$ref": "#/components/schemas/EventType"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The endpoint, with its signing secret, shown this once.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    }
                  ],
                  "required": [
                    "secret"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict",
            "description": "`too_many_webhooks`: the Workspace has 20 endpoints."
          },
          "422": {
            "description": "`url_invalid`: the address isn't HTTPS (`reason: not_https`), isn't on the public\ninternet (`not_public`) or isn't a valid address (`invalid`).\n`events_invalid`: an event isn't one we send; `events` lists those we do.\n",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "reason": {
                          "enum": [
                            "not_https",
                            "not_public",
                            "invalid"
                          ]
                        },
                        "events": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/EventType"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhooks",
        "summary": "List the webhook endpoints",
        "description": "The Workspace's endpoints, without their secrets.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WorkspaceQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "webhooks"
                  ],
                  "properties": {
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/webhooks/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "$ref": "#/components/schemas/WebhookID"
          }
        },
        {
          "$ref": "#/components/parameters/WorkspaceQuery"
        }
      ],
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteWebhook",
        "summary": "Remove a webhook endpoint",
        "description": "Removes the endpoint. Messages still waiting for it aren't sent.",
        "responses": {
          "204": {
            "description": "Removed."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    }
  },
  "webhooks": {
    "job.completed": {
      "post": {
        "summary": "A job ended and every task completed, apart from any that were cancelled",
        "description": "`data` is the job, as `GET /v1/jobs/{id}` returns it, with fresh download links.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookIDHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestampHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookSignatureHeader"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/JobMessage"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/WebhookReceived"
          }
        }
      }
    },
    "job.partly_failed": {
      "post": {
        "summary": "A job ended with some tasks completed and some failed",
        "description": "`data` is the job. Failed tasks aren't charged.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookIDHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestampHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookSignatureHeader"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/JobMessage"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/WebhookReceived"
          }
        }
      }
    },
    "job.failed": {
      "post": {
        "summary": "A job ended with every task failed, apart from any that were cancelled",
        "description": "`data` is the job. Failed tasks aren't charged; each gives its reason.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookIDHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestampHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookSignatureHeader"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/JobMessage"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/WebhookReceived"
          }
        }
      }
    },
    "job.cancelled": {
      "post": {
        "summary": "A job was cancelled before any task completed",
        "description": "`data` is the job.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookIDHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestampHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookSignatureHeader"
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/JobMessage"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/WebhookReceived"
          }
        }
      }
    },
    "credits.low": {
      "post": {
        "summary": "The Workspace's credits fell below its alert level",
        "description": "Sent once each time the balance drops below the level set in the Workspace's Billing settings. It's sent with the low-credit email, so turning that email off stops it too.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookIDHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestampHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookSignatureHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/MessageEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "credits.low"
                      },
                      "data": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "workspace_id",
                          "available_credits",
                          "alert_level"
                        ],
                        "properties": {
                          "workspace_id": {
                            "$ref": "#/components/schemas/WorkspaceID"
                          },
                          "available_credits": {
                            "type": "integer",
                            "format": "int64"
                          },
                          "alert_level": {
                            "type": "integer",
                            "format": "int64"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/WebhookReceived"
          }
        }
      }
    },
    "webhook.test": {
      "post": {
        "summary": "A test message, sent from the endpoint's page in Settings",
        "description": "Sent only when someone asks for it, whatever events the endpoint listens for.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookIDHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookTimestampHeader"
          },
          {
            "$ref": "#/components/parameters/WebhookSignatureHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/MessageEnvelope"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "webhook.test"
                      },
                      "data": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "message"
                        ],
                        "properties": {
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/WebhookReceived"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key from the Workspace's Settings, such as `filesokay_4fQ…`."
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "description": "Any unique text, such as a UUID, sent again unchanged with every retry of the same\nrequest. Kept for 24 hours.\n",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      },
      "WorkspaceQuery": {
        "name": "workspace_id",
        "in": "query",
        "description": "Not needed with an API key. If sent, it must be the key's Workspace.",
        "schema": {
          "$ref": "#/components/schemas/WorkspaceID"
        }
      },
      "FileID": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/FileID"
        }
      },
      "JobID": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/JobID"
        }
      },
      "WebhookIDHeader": {
        "name": "webhook-id",
        "in": "header",
        "required": true,
        "description": "The message's ID, the same on every retry. Use it to process each message once.",
        "schema": {
          "$ref": "#/components/schemas/MessageID"
        }
      },
      "WebhookTimestampHeader": {
        "name": "webhook-timestamp",
        "in": "header",
        "required": true,
        "description": "When this attempt was sent, in Unix seconds. Refuse a message more than 5 minutes old.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9]+$"
        }
      },
      "WebhookSignatureHeader": {
        "name": "webhook-signature",
        "in": "header",
        "required": true,
        "description": "`v1,` and the Base64 HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{body}`, keyed\nwith the Base64-decoded part of the secret after `whsec_`. Any Standard Webhooks\nlibrary checks it.\n",
        "schema": {
          "type": "string"
        }
      }
    },
    "headers": {
      "IdempotentReplayed": {
        "description": "`true` when this is the saved answer to an earlier request with the same Idempotency-Key.",
        "schema": {
          "const": "true"
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait before trying again.",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "requestBodies": {
      "Job": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/JobRequest"
            }
          }
        }
      },
      "JobMessage": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/MessageEnvelope"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Job"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "`bad_request`: the body isn't valid JSON for this endpoint, or a value is out of range. `unknown_operation`: there's no such operation.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "`unauthorized`: the API key is missing, unknown or revoked.",
        "headers": {
          "WWW-Authenticate": {
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "`subscription_required`: the key's Workspace has no active subscription.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Forbidden": {
        "description": "`not_cancellable`, `not_deletable` or `forbidden`: this caller may not change it.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "NotFound": {
        "description": "`not_found`: there's no such thing in this Workspace.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Conflict": {
        "description": "`idempotency_key_in_use`: a request with this Idempotency-Key is still running.\n`already_uploaded`: the upload is complete. `still_running`: cancel the job first.\n`too_many_webhooks`: the Workspace has 20 endpoints.\n",
        "content": {
          "application/problem+json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Problem"
                },
                {
                  "type": "object",
                  "properties": {
                    "limit": {
                      "type": "integer"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "Gone": {
        "description": "`upload_gone`: storage no longer has the upload's parts, so it can't be completed. Start it again.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "FileProblems": {
        "description": "`too_many_files`, `file_too_large`, `empty_file` or `unsupported_type`. `files` names\neach file with a problem by its position in the request.\n",
        "content": {
          "application/problem+json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Problem"
                },
                {
                  "type": "object",
                  "properties": {
                    "limit": {
                      "type": "integer"
                    },
                    "remaining": {
                      "type": "integer"
                    },
                    "files": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "index",
                          "code"
                        ],
                        "properties": {
                          "index": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "code": {
                            "type": "string"
                          },
                          "limit_bytes": {
                            "type": "integer",
                            "format": "int64"
                          }
                        }
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "FilesUnusable": {
        "description": "`files_unusable`: an operation that combines its files can't use one of them;\n`inputs` says which and why. `idempotency_key_in_use`: a request with this key is\nstill running.\n",
        "content": {
          "application/problem+json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Problem"
                },
                {
                  "type": "object",
                  "properties": {
                    "inputs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/UnusableInput"
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "Unprocessable": {
        "description": "`settings_invalid`: the settings don't match the operation's settings schema.\n`too_many_files`: more inputs than the operation takes. `nothing_to_run`: no input\nwould run; `inputs` gives each one's reason. `idempotency_key_reused`: this\nIdempotency-Key was used with a different body.\n",
        "content": {
          "application/problem+json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Problem"
                },
                {
                  "type": "object",
                  "properties": {
                    "limit": {
                      "type": "integer"
                    },
                    "inputs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/UnusableInput"
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "`rate_limited`: wait the seconds in Retry-After.",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Problem"
                },
                {
                  "type": "object",
                  "properties": {
                    "limit": {
                      "type": "integer"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "Unavailable": {
        "description": "`storage_unavailable` or `unavailable`: a problem on our side. Try again in a few minutes.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "WebhookReceived": {
        "description": "Any 2xx answer within 15 seconds means received. Any other answer, a redirect or no\nanswer is tried again, up to 9 more times over about 3 days. An endpoint failing for 72 hours is\nswitched off, and the Workspace's Admins are emailed.\n"
      }
    },
    "schemas": {
      "WorkspaceID": {
        "type": "string",
        "pattern": "^org_[A-Za-z0-9]+$",
        "description": "The Workspace's ID."
      },
      "FileID": {
        "type": "string",
        "pattern": "^file_[0-9a-f]{32}$"
      },
      "JobID": {
        "type": "string",
        "pattern": "^job_[0-9a-f]{32}$"
      },
      "TaskID": {
        "type": "string",
        "pattern": "^task_[0-9a-f]{32}$"
      },
      "WebhookID": {
        "type": "string",
        "pattern": "^wh_[0-9a-f]{32}$"
      },
      "MessageID": {
        "type": "string",
        "pattern": "^msg_[0-9a-f]{32}$"
      },
      "EventType": {
        "enum": [
          "job.completed",
          "job.partly_failed",
          "job.failed",
          "job.cancelled",
          "credits.low"
        ]
      },
      "Problem": {
        "type": "object",
        "description": "An error, as RFC 9457 problem details, with our `code`.",
        "required": [
          "type",
          "title",
          "status",
          "code",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "Always `about:blank`."
          },
          "title": {
            "type": "string",
            "description": "The HTTP status's name."
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "description": "What went wrong, as a code that never changes."
          },
          "detail": {
            "type": "string",
            "description": "A sentence for people."
          },
          "request_id": {
            "type": "string",
            "description": "Quote it if you contact us about this request."
          }
        }
      },
      "Operation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "category",
          "name",
          "description",
          "grouping",
          "output",
          "max_files",
          "input_formats",
          "limits"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Its ID, such as `video.compress`."
          },
          "category": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "grouping": {
            "enum": [
              "separate",
              "together"
            ],
            "description": "`separate`: one task per input file. `together`: one task for all of them."
          },
          "output": {
            "type": "string",
            "description": "What each task makes, such as `file`."
          },
          "max_files": {
            "type": "integer",
            "minimum": 1,
            "description": "The most input files one job takes."
          },
          "input_formats": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The file extensions it takes."
          },
          "limits": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "max_file_bytes"
            ],
            "properties": {
              "max_file_bytes": {
                "type": "integer",
                "format": "int64",
                "description": "The largest input file, in bytes."
              }
            }
          },
          "settings_schema": {
            "type": "object",
            "description": "The JSON Schema its `settings` follow. Only on `GET /v1/operations/{id}`."
          }
        }
      },
      "PartLink": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "number",
          "url"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "minimum": 1
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Send the part's bytes here with `PUT`. The link works for one hour."
          }
        }
      },
      "Upload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "size",
          "part_size",
          "part_count",
          "parts",
          "links_expire_at",
          "delete_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/FileID"
          },
          "name": {
            "type": "string",
            "description": "The name, cleaned of anything unsafe."
          },
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "part_size": {
            "type": "integer",
            "format": "int64",
            "description": "The size of every part except the last; the file's size when it goes in one request."
          },
          "part_count": {
            "type": "integer",
            "minimum": 1
          },
          "parts": {
            "type": "array",
            "description": "Links for the first parts. Ask for the rest with `POST /v1/uploads/{id}/parts`.",
            "items": {
              "$ref": "#/components/schemas/PartLink"
            }
          },
          "links_expire_at": {
            "type": "string",
            "format": "date-time"
          },
          "delete_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the file is deleted if no job uses it."
          }
        }
      },
      "UploadProgress": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "state",
          "size",
          "part_size",
          "part_count",
          "parts_received",
          "delete_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/FileID"
          },
          "state": {
            "const": "uploading"
          },
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "part_size": {
            "type": "integer",
            "format": "int64"
          },
          "part_count": {
            "type": "integer"
          },
          "parts_received": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "number",
                "size"
              ],
              "properties": {
                "number": {
                  "type": "integer"
                },
                "size": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            }
          },
          "delete_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "File": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "operation",
          "state",
          "size",
          "created_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/FileID"
          },
          "name": {
            "type": "string"
          },
          "operation": {
            "type": "string",
            "description": "The operation it was uploaded for."
          },
          "state": {
            "enum": [
              "uploading",
              "uploaded"
            ]
          },
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "uploaded_at": {
            "type": "string",
            "format": "date-time"
          },
          "delete_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it's deleted. Left out while a job uses it."
          },
          "check": {
            "$ref": "#/components/schemas/Check"
          },
          "download_url": {
            "type": "string",
            "format": "uri",
            "description": "Only on `GET /v1/files/{id}`, once it's uploaded."
          },
          "download_expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Check": {
        "type": "object",
        "description": "The check of the file's content when its upload completed.",
        "additionalProperties": false,
        "required": [
          "state"
        ],
        "properties": {
          "state": {
            "enum": [
              "checking",
              "proceed",
              "refuse",
              "couldnt_read",
              "check_failed"
            ],
            "description": "`proceed`: an operation can use it. `refuse`: it can't, for `reason`.\n`couldnt_read`: the check couldn't read all of it; a job reads it in full.\n`check_failed`: a problem on our side; complete the upload again to retry.\n"
          },
          "reason": {
            "type": "string"
          },
          "detail": {
            "type": "object"
          },
          "kind": {
            "type": "string",
            "description": "What the file really is, such as `video`."
          },
          "type": {
            "type": "string",
            "description": "Its real format, such as `mp4`, whatever its name says."
          },
          "facts": {
            "type": "object",
            "description": "What the check read, such as a video's length, size and codecs."
          },
          "facts_complete": {
            "type": "boolean"
          }
        }
      },
      "JobRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation",
          "inputs"
        ],
        "properties": {
          "workspace_id": {
            "$ref": "#/components/schemas/WorkspaceID"
          },
          "operation": {
            "type": "string",
            "description": "The operation's ID, from `GET /v1/operations`."
          },
          "inputs": {
            "type": "array",
            "minItems": 1,
            "description": "The input files, in order. Up to the operation's `max_files`.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "file_id"
              ],
              "properties": {
                "file_id": {
                  "$ref": "#/components/schemas/FileID"
                }
              }
            }
          },
          "settings": {
            "type": "object",
            "description": "The operation's settings, following its `settings_schema`. Leave it out for the defaults."
          },
          "client_reference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Your own reference, returned with the job and its webhooks, and searchable in `GET /v1/jobs`."
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "operation"
              ],
              "properties": {
                "operation": {
                  "const": "video.compress"
                }
              }
            },
            "then": {
              "properties": {
                "settings": {
                  "$ref": "#/components/schemas/VideoCompressSettings"
                }
              }
            }
          }
        ]
      },
      "UnusableInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "file_id",
          "reason"
        ],
        "properties": {
          "file_id": {
            "type": "string",
            "description": "The ID as you sent it."
          },
          "name": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "description": "Why it can't be used: `not_found`, `not_ready`, `refused`, `check_failed`,\n`other_operation`, `file_in_use` or `repeated`, or the operation's own reason for\nnot running it with these settings, such as a video already smaller than its target.\n"
          },
          "details": {
            "type": "object"
          }
        }
      },
      "Estimate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation",
          "settings",
          "reserved_credits",
          "available_credits",
          "shortfall",
          "tasks"
        ],
        "properties": {
          "operation": {
            "type": "string"
          },
          "settings": {
            "type": "object",
            "description": "The settings with every default filled in."
          },
          "reserved_credits": {
            "type": "integer",
            "format": "int64",
            "description": "The most the job can cost, which starting it reserves. It's charged only what it uses."
          },
          "available_credits": {
            "type": "integer",
            "format": "int64"
          },
          "shortfall": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "How many credits are missing to start it."
          },
          "tasks": {
            "type": "array",
            "description": "One per input, in order.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "status",
                "inputs"
              ],
              "properties": {
                "status": {
                  "enum": [
                    "waiting",
                    "skipped"
                  ],
                  "description": "`waiting`: it would run. `skipped`: it wouldn't, for `reason`."
                },
                "inputs": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskInput"
                  }
                },
                "reserved_credits": {
                  "type": "integer",
                  "format": "int64"
                },
                "reason": {
                  "type": "string"
                },
                "details": {
                  "type": "object"
                },
                "preview": {
                  "type": "object",
                  "description": "What the operation would do, such as the output format, codec and picture size."
                }
              }
            }
          }
        }
      },
      "TaskInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "file_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "TaskOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "file_id",
          "name",
          "size"
        ],
        "properties": {
          "file_id": {
            "$ref": "#/components/schemas/FileID"
          },
          "name": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "download_url": {
            "type": "string",
            "format": "uri",
            "description": "The result, as a download, valid until `download_expires_at`."
          },
          "download_expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Task": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "status",
          "progress",
          "inputs",
          "outputs"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/TaskID",
            "description": "Left out of a skipped input, which never became a task."
          },
          "status": {
            "enum": [
              "waiting",
              "processing",
              "completed",
              "failed",
              "cancelled",
              "skipped"
            ]
          },
          "progress": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "stage": {
            "type": "string",
            "description": "What it's doing now, such as `processing` or `uploading`."
          },
          "reason": {
            "type": "string",
            "description": "Why it failed or was skipped."
          },
          "details": {
            "type": "object"
          },
          "reserved_credits": {
            "type": "integer",
            "format": "int64"
          },
          "charged_credits": {
            "type": "integer",
            "format": "int64"
          },
          "inputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskInput"
            }
          },
          "outputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskOutput"
            }
          }
        }
      },
      "Job": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "operation",
          "status",
          "client_reference",
          "settings",
          "created_at",
          "reserved_credits",
          "charged_credits",
          "tasks"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/JobID"
          },
          "operation": {
            "type": "string"
          },
          "status": {
            "enum": [
              "waiting",
              "processing",
              "completed",
              "partly_failed",
              "failed",
              "cancelled"
            ],
            "description": "`waiting`: no task is running, and at least one is still waiting to start.\n`completed`: every task completed, apart from any that were cancelled.\n`partly_failed`: some completed and some failed. `failed`: every task failed, apart\nfrom any that were cancelled. `cancelled`: cancelled before any completed.\n"
          },
          "client_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "settings": {
            "type": "object"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": "string",
            "format": "date-time"
          },
          "reserved_credits": {
            "type": "integer",
            "format": "int64"
          },
          "charged_credits": {
            "type": "integer",
            "format": "int64"
          },
          "tasks": {
            "type": "array",
            "description": "One per input, in the request's order, skipped inputs among them.",
            "items": {
              "$ref": "#/components/schemas/Task"
            }
          }
        }
      },
      "WebhookEndpoint": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "url",
          "events",
          "enabled",
          "disabled_at",
          "created_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/WebhookID"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventType"
            }
          },
          "enabled": {
            "type": "boolean",
            "description": "False once it was switched off after 72 hours of failed deliveries. An Admin switches it back on in Settings."
          },
          "disabled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "secret": {
            "type": "string",
            "pattern": "^whsec_[A-Za-z0-9+/=]+$",
            "description": "The signing secret. Only in the answer that adds the endpoint."
          }
        }
      },
      "MessageEnvelope": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "timestamp",
          "data"
        ],
        "properties": {
          "type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EventType"
              },
              {
                "const": "webhook.test"
              }
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When the message was built."
          },
          "data": {
            "type": "object"
          }
        }
      },
      "VideoCompressSettings": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "title": "Video Compressor settings",
        "description": "Video Compressor's settings. A setting left out takes its default, and a job shows every setting with its default filled in. One set of settings covers every file in a job.",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "method": {
            "description": "quality: choose a level, and each file's size follows from its video. target_size: choose the size to reach.",
            "enum": [
              "quality",
              "target_size"
            ],
            "default": "quality"
          },
          "level": {
            "description": "With the quality method only: smaller for a smaller file, balanced, or higher for higher quality.",
            "enum": [
              "smaller",
              "balanced",
              "higher"
            ],
            "default": "balanced"
          },
          "target": {
            "description": "With the target_size method only: the size to reach, for each file. In MB, where 1 MB is 1,000,000 bytes, from 0.1 up to the file's own size; or as a percentage of the file's own size, from 1 to 99.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "unit",
              "value"
            ],
            "properties": {
              "unit": {
                "enum": [
                  "mb",
                  "percent"
                ]
              },
              "value": {
                "type": "number"
              }
            },
            "allOf": [
              {
                "if": {
                  "properties": {
                    "unit": {
                      "const": "mb"
                    }
                  }
                },
                "then": {
                  "properties": {
                    "value": {
                      "minimum": 0.1
                    }
                  }
                }
              },
              {
                "if": {
                  "properties": {
                    "unit": {
                      "const": "percent"
                    }
                  }
                },
                "then": {
                  "properties": {
                    "value": {
                      "minimum": 1,
                      "maximum": 99
                    }
                  }
                }
              }
            ],
            "default": {
              "unit": "percent",
              "value": 60
            }
          },
          "resolution": {
            "description": "original keeps each video's size. auto, allowed only with the target_size method and its default there, lowers the size when that helps reach the target. A height lowers the video's shorter side to it, keeping the aspect ratio; a video already at or below it keeps its own size. original is the default with the quality method.",
            "enum": [
              "original",
              "auto",
              "2160",
              "1440",
              "1080",
              "720",
              "480",
              "360",
              "240"
            ]
          },
          "codec": {
            "description": "same keeps each video's codec when its output format can hold it, and otherwise uses that format's usual codec. A chosen codec the output format can't hold falls back to the same rule.",
            "enum": [
              "same",
              "h264",
              "hevc",
              "av1",
              "vp9",
              "mpeg4"
            ],
            "default": "same"
          },
          "frame_rate": {
            "description": "original keeps each video's frame rate. A number lowers it to that rate; a video already at or below it keeps its own.",
            "enum": [
              "original",
              "60",
              "30",
              "24"
            ],
            "default": "original"
          },
          "audio": {
            "description": "keep keeps the sound; remove takes it out.",
            "enum": [
              "keep",
              "remove"
            ],
            "default": "keep"
          },
          "output_format": {
            "description": "same keeps each file's own format, or gives MP4 where that format can't be written.",
            "enum": [
              "same",
              "mp4",
              "mov",
              "mkv",
              "webm"
            ],
            "default": "same"
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "method"
              ],
              "properties": {
                "method": {
                  "const": "target_size"
                }
              }
            },
            "then": {
              "not": {
                "required": [
                  "level"
                ]
              }
            },
            "else": {
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "target"
                    ]
                  },
                  {
                    "required": [
                      "resolution"
                    ],
                    "properties": {
                      "resolution": {
                        "const": "auto"
                      }
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}
