{
  "openapi": "3.1.0",
  "info": {
    "title": "InstaHost API",
    "version": "0.1.0",
    "description": "Instant hosting and sharing for AI agents. Create an artifact with a manifest, PUT each file to its presigned URL replaying the signed headers, then complete. Every credential is a Bearer token; the API uses no cookies and sends no CORS headers. POST and DELETE requests whose Sec-Fetch-Site is cross-site or same-site are refused with 403 cross_site_request. Every error uses the Error envelope. Without the admin secret, admin routes answer 404. Documentation: https://instahost.dev/docs/"
  },
  "servers": [
    {
      "url": "https://instahost.dev"
    }
  ],
  "paths": {
    "/v1/artifacts": {
      "post": {
        "operationId": "createArtifact",
        "summary": "Create an artifact and get its first upload URLs",
        "security": [
          {},
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created; status pending.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "415": {
            "$ref": "#/components/responses/E415"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/artifacts/{id}/uploads": {
      "post": {
        "operationId": "issueUploadUrls",
        "summary": "Issue or re-issue upload URLs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ArtifactId"
            }
          }
        ],
        "security": [
          {
            "deleteToken": []
          },
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload URLs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "410": {
            "$ref": "#/components/responses/E410"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "415": {
            "$ref": "#/components/responses/E415"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/artifacts/{id}/complete": {
      "post": {
        "operationId": "completeArtifact",
        "summary": "Validate the uploads and publish (empty body)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ArtifactId"
            }
          }
        ],
        "security": [
          {
            "deleteToken": []
          },
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Published (idempotent).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorizedArtifactResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "410": {
            "$ref": "#/components/responses/E410"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/artifacts/{id}": {
      "get": {
        "operationId": "getArtifact",
        "summary": "Artifact metadata",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ArtifactId"
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "files"
              ]
            },
            "description": "files: add one page of the manifest (authorized view only)."
          },
          {
            "name": "files_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The files_next of the previous page."
          }
        ],
        "security": [
          {},
          {
            "deleteToken": []
          },
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "The authorized view, or the public view of a published, unexpired, non-private artifact.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArtifactResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "410": {
            "$ref": "#/components/responses/E410"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      },
      "delete": {
        "operationId": "deleteArtifact",
        "summary": "Delete (idempotent while the tombstone exists)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ArtifactId"
            }
          }
        ],
        "security": [
          {
            "deleteToken": []
          },
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted, or already blocked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/limits": {
      "get": {
        "operationId": "getLimits",
        "summary": "The limits in force",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "Limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Limits"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/admin/keys": {
      "post": {
        "operationId": "adminCreateKey",
        "summary": "Create an API key (operator)",
        "security": [
          {
            "adminSecret": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminKeyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created; the key is shown once.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "415": {
            "$ref": "#/components/responses/E415"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/admin/keys/{key_id}": {
      "delete": {
        "operationId": "adminRevokeKey",
        "summary": "Revoke an API key (operator)",
        "security": [
          {
            "adminSecret": []
          }
        ],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z2-7]{12}$"
            }
          },
          {
            "name": "block_artifacts",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1"
              ]
            },
            "description": "1: also block up to 200 of the key's artifacts per call."
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked (idempotent).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminRevokeResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/admin/artifacts/{id}/block": {
      "post": {
        "operationId": "adminBlockArtifact",
        "summary": "Take an artifact down (operator)",
        "security": [
          {
            "adminSecret": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/ArtifactId"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminBlockRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Blocked (idempotent).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminBlockResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "415": {
            "$ref": "#/components/responses/E415"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "deleteToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "The artifact's delete token (ihd_...), returned once by create."
      },
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key (ihk_<id>_<secret>) issued by the operator. Malformed, unknown or revoked keys get 401 invalid_api_key."
      },
      "adminSecret": {
        "type": "http",
        "scheme": "bearer",
        "description": "The operator's admin secret."
      }
    },
    "schemas": {
      "ArtifactId": {
        "type": "string",
        "pattern": "^[a-z2-7]{26}$"
      },
      "Timestamp": {
        "type": "string",
        "format": "date-time",
        "description": "RFC 3339 UTC, whole seconds."
      },
      "Artifact": {
        "type": "object",
        "description": "Public view.",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "access",
          "status",
          "url",
          "created_at",
          "expires_at",
          "published_at",
          "file_count",
          "total_bytes"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/ArtifactId"
          },
          "type": {
            "type": "string",
            "enum": [
              "file",
              "site"
            ]
          },
          "access": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "private"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "published",
              "failed",
              "deleted",
              "blocked",
              "expired"
            ],
            "description": "Effective status: a published artifact past expires_at reports expired."
          },
          "url": {
            "type": "string",
            "description": "Public URL on the files or sites host; final from create on."
          },
          "created_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "null for persistent artifacts. Fixed at create."
          },
          "published_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "file_count": {
            "type": "integer",
            "minimum": 1
          },
          "total_bytes": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "AuthorizedArtifact": {
        "type": "object",
        "description": "View for the delete token or the owner key (amendment 25 adds owner).",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "access",
          "status",
          "url",
          "created_at",
          "expires_at",
          "published_at",
          "file_count",
          "total_bytes",
          "owner"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/ArtifactId"
          },
          "type": {
            "type": "string",
            "enum": [
              "file",
              "site"
            ]
          },
          "access": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "private"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "published",
              "failed",
              "deleted",
              "blocked",
              "expired"
            ],
            "description": "Effective status: a published artifact past expires_at reports expired."
          },
          "url": {
            "type": "string",
            "description": "Public URL on the files or sites host; final from create on."
          },
          "created_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "null for persistent artifacts. Fixed at create."
          },
          "published_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "file_count": {
            "type": "integer",
            "minimum": 1
          },
          "total_bytes": {
            "type": "integer",
            "minimum": 0
          },
          "owner": {
            "type": [
              "string",
              "null"
            ],
            "description": "Owning API key id, or null for anonymous artifacts."
          },
          "files": {
            "type": "array",
            "description": "With ?include=files: one page of the manifest (100 entries) in path order.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "path",
                "size",
                "content_type"
              ],
              "properties": {
                "path": {
                  "type": "string"
                },
                "size": {
                  "type": "integer",
                  "minimum": 0
                },
                "content_type": {
                  "type": "string"
                }
              }
            }
          },
          "files_next": {
            "type": [
              "string",
              "null"
            ],
            "description": "With ?include=files: pass as files_after for the next page; null on the last page."
          }
        }
      },
      "ManifestFile": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "path",
          "size",
          "md5"
        ],
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "description": "File name (type=file, no /) or site-relative path. At most 512 UTF-8 bytes, 255 per segment, NFC; no empty, . or .. segment, no leading or trailing /, no backslash, controls or invisible characters; not a credential-like name."
          },
          "size": {
            "type": "integer",
            "minimum": 0
          },
          "md5": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{32}$",
            "description": "Required. Signed into the upload URL as content-md5."
          },
          "content_type": {
            "type": "string",
            "maxLength": 127,
            "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*$",
            "description": "type=file only; overrides the extension's type."
          }
        }
      },
      "CreateRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "files"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "file",
              "site"
            ]
          },
          "access": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "private"
            ],
            "default": "unlisted",
            "description": "private is for type=file only (422 private_sites_unsupported)."
          },
          "ttl_seconds": {
            "type": "integer",
            "description": "Default: default_ttl_seconds of /v1/limits. Excludes persistent."
          },
          "persistent": {
            "type": "boolean",
            "default": false,
            "description": "Never expires; needs an API key."
          },
          "files": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/ManifestFile"
            },
            "description": "Exactly one entry for type=file; 1 to max_files entries including a root index.html for type=site."
          }
        }
      },
      "UploadInstruction": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "path",
          "method",
          "url",
          "headers"
        ],
        "properties": {
          "path": {
            "type": "string"
          },
          "method": {
            "type": "string",
            "const": "PUT"
          },
          "url": {
            "type": "string",
            "description": "Presigned storage URL."
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Signed headers to replay exactly: if-none-match, content-md5, x-amz-storage-class, and content-length (always signed: R2 refuses a body of another length)."
          }
        }
      },
      "UploadBatch": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expires_at",
          "files"
        ],
        "properties": {
          "expires_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UploadInstruction"
            }
          }
        }
      },
      "CreateUpload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expires_at",
          "files",
          "batch_size",
          "remaining",
          "uploads_url",
          "complete_url"
        ],
        "properties": {
          "expires_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UploadInstruction"
            }
          },
          "batch_size": {
            "type": "integer",
            "minimum": 1
          },
          "remaining": {
            "type": "integer",
            "minimum": 0,
            "description": "Files still without an upload URL."
          },
          "uploads_url": {
            "type": "string"
          },
          "complete_url": {
            "type": "string"
          }
        }
      },
      "CreateResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact",
          "delete_token",
          "upload"
        ],
        "properties": {
          "artifact": {
            "$ref": "#/components/schemas/AuthorizedArtifact"
          },
          "delete_token": {
            "type": "string",
            "pattern": "^ihd_[A-Za-z0-9_-]{43}$",
            "description": "Shown once."
          },
          "access_token": {
            "type": "string",
            "pattern": "^iha_[A-Za-z0-9_-]{43}$",
            "description": "Private files only; shown once."
          },
          "access_url": {
            "type": "string",
            "description": "Private files only: the file URL with ?token=."
          },
          "upload": {
            "$ref": "#/components/schemas/CreateUpload"
          }
        }
      },
      "UploadsRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "paths"
        ],
        "properties": {
          "paths": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "uniqueItems": true,
            "items": {
              "type": "string"
            },
            "description": "1 to upload.batch_size manifest paths."
          }
        }
      },
      "UploadsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "upload"
        ],
        "properties": {
          "upload": {
            "$ref": "#/components/schemas/UploadBatch"
          }
        }
      },
      "AuthorizedArtifactResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact"
        ],
        "properties": {
          "artifact": {
            "$ref": "#/components/schemas/AuthorizedArtifact"
          }
        }
      },
      "ArtifactResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact"
        ],
        "properties": {
          "artifact": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AuthorizedArtifact"
              },
              {
                "$ref": "#/components/schemas/Artifact"
              }
            ]
          }
        },
        "description": "The authorized view for the delete token or owner key; the public view for anyone else."
      },
      "DeleteResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact"
        ],
        "properties": {
          "artifact": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "status"
            ],
            "properties": {
              "id": {
                "$ref": "#/components/schemas/ArtifactId"
              },
              "status": {
                "type": "string",
                "enum": [
                  "deleted",
                  "blocked"
                ]
              },
              "deleted_at": {
                "type": "string",
                "format": "date-time",
                "description": "Present when status is deleted."
              }
            }
          }
        }
      },
      "DailyQuota": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifacts",
          "files",
          "bytes"
        ],
        "properties": {
          "artifacts": {
            "type": "integer"
          },
          "files": {
            "type": "integer"
          },
          "bytes": {
            "type": "integer"
          }
        }
      },
      "IdentityLimits": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "max_ttl_seconds",
          "allow_persistent",
          "max_file_bytes",
          "max_artifact_bytes",
          "max_files",
          "daily",
          "upload"
        ],
        "properties": {
          "max_ttl_seconds": {
            "type": "integer"
          },
          "allow_persistent": {
            "type": "boolean"
          },
          "max_file_bytes": {
            "type": "integer"
          },
          "max_artifact_bytes": {
            "type": "integer"
          },
          "max_files": {
            "type": "integer"
          },
          "daily": {
            "$ref": "#/components/schemas/DailyQuota"
          },
          "upload": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "url_ttl_seconds",
              "pending_ttl_seconds"
            ],
            "properties": {
              "url_ttl_seconds": {
                "type": "integer"
              },
              "pending_ttl_seconds": {
                "type": "integer"
              }
            }
          }
        }
      },
      "AnonymousLimits": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "enabled",
          "max_ttl_seconds",
          "allow_persistent",
          "max_file_bytes",
          "max_artifact_bytes",
          "max_files",
          "daily",
          "upload"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Whether anonymous uploads are accepted."
          },
          "max_ttl_seconds": {
            "type": "integer"
          },
          "allow_persistent": {
            "type": "boolean"
          },
          "max_file_bytes": {
            "type": "integer"
          },
          "max_artifact_bytes": {
            "type": "integer"
          },
          "max_files": {
            "type": "integer"
          },
          "daily": {
            "$ref": "#/components/schemas/DailyQuota"
          },
          "upload": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "url_ttl_seconds",
              "pending_ttl_seconds"
            ],
            "properties": {
              "url_ttl_seconds": {
                "type": "integer"
              },
              "pending_ttl_seconds": {
                "type": "integer"
              }
            }
          }
        }
      },
      "Limits": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "anonymous",
          "api_key",
          "anonymous_global_daily",
          "default_ttl_seconds",
          "min_ttl_seconds",
          "upload",
          "sites",
          "max_path_bytes",
          "max_manifest_bytes",
          "rate_limit"
        ],
        "properties": {
          "anonymous": {
            "$ref": "#/components/schemas/AnonymousLimits"
          },
          "api_key": {
            "$ref": "#/components/schemas/IdentityLimits"
          },
          "anonymous_global_daily": {
            "$ref": "#/components/schemas/DailyQuota"
          },
          "default_ttl_seconds": {
            "type": "integer"
          },
          "min_ttl_seconds": {
            "type": "integer"
          },
          "upload": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "batch_size",
              "max_url_issues_per_file",
              "max_complete_attempts",
              "signs_content_length"
            ],
            "properties": {
              "batch_size": {
                "type": "integer"
              },
              "max_url_issues_per_file": {
                "type": "integer"
              },
              "max_complete_attempts": {
                "type": "integer"
              },
              "signs_content_length": {
                "type": "boolean"
              }
            }
          },
          "sites": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "url_mode",
              "private_supported"
            ],
            "properties": {
              "url_mode": {
                "type": "string",
                "enum": [
                  "path",
                  "subdomain"
                ]
              },
              "private_supported": {
                "type": "boolean",
                "const": false
              }
            }
          },
          "max_path_bytes": {
            "type": "integer"
          },
          "max_manifest_bytes": {
            "type": "integer"
          },
          "rate_limit": {
            "type": "string",
            "enum": [
              "binding",
              "d1",
              "none"
            ],
            "description": "The limiter in use: binding (Workers rate limiting). d1 is reserved for a database fallback that is not built. With none, anonymous uploads answer 503."
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "enum": [
          "invalid_json",
          "invalid_request",
          "invalid_path",
          "sensitive_file",
          "missing_index",
          "unknown_path",
          "unauthorized",
          "invalid_api_key",
          "forbidden",
          "anonymous_disabled",
          "persistent_requires_api_key",
          "cross_site_request",
          "not_found",
          "method_not_allowed",
          "upload_incomplete",
          "artifact_not_pending",
          "artifact_failed",
          "upload_url_limit",
          "complete_attempt_limit",
          "gone",
          "payload_too_large",
          "file_too_large",
          "artifact_too_large",
          "too_many_files",
          "unsupported_media_type",
          "upload_mismatch",
          "private_sites_unsupported",
          "ttl_too_short",
          "ttl_too_long",
          "rate_limited",
          "quota_exceeded",
          "internal_error",
          "service_misconfigured"
        ]
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "$ref": "#/components/schemas/ErrorCode"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object"
              }
            }
          }
        }
      },
      "AdminKeyRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "1 to 64 code points of printable text."
          }
        }
      },
      "AdminKeyResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key",
          "api_key"
        ],
        "properties": {
          "key": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "label",
              "created_at"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z2-7]{12}$"
              },
              "label": {
                "type": "string"
              },
              "created_at": {
                "$ref": "#/components/schemas/Timestamp"
              }
            }
          },
          "api_key": {
            "type": "string",
            "pattern": "^ihk_[a-z2-7]{12}_[A-Za-z0-9_-]{43}$",
            "description": "Shown once."
          }
        }
      },
      "AdminRevokeResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "revoked_at"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "revoked_at": {
                "$ref": "#/components/schemas/Timestamp"
              }
            }
          },
          "blocked_artifacts": {
            "type": "integer",
            "description": "With block_artifacts=1: artifacts blocked by this call (at most 200)."
          },
          "has_more": {
            "type": "boolean",
            "description": "With block_artifacts=1: repeat the call while true."
          }
        }
      },
      "AdminBlockRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reason"
        ],
        "properties": {
          "reason": {
            "type": "string",
            "description": "1 to 500 code points of printable text."
          }
        }
      },
      "AdminArtifact": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "access",
          "status",
          "block_reason",
          "blocked_at",
          "owner",
          "created_at",
          "expires_at",
          "purged"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/ArtifactId"
          },
          "type": {
            "type": "string",
            "enum": [
              "file",
              "site"
            ]
          },
          "access": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "private"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "published",
              "failed",
              "deleted",
              "blocked"
            ],
            "description": "Stored status."
          },
          "block_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "blocked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "owner": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "purged": {
            "type": "boolean",
            "description": "Whether the bytes were already purged by the sweeper."
          }
        }
      },
      "AdminBlockResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact"
        ],
        "properties": {
          "artifact": {
            "$ref": "#/components/schemas/AdminArtifact"
          }
        }
      }
    },
    "responses": {
      "E400": {
        "description": "Bad request: invalid_json, invalid_request, invalid_path, sensitive_file, missing_index, unknown_path.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E401": {
        "description": "Missing or invalid credential: unauthorized, invalid_api_key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E403": {
        "description": "Forbidden: forbidden, anonymous_disabled, persistent_requires_api_key, cross_site_request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E404": {
        "description": "Not found: not_found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E409": {
        "description": "Conflict: upload_incomplete, artifact_not_pending, artifact_failed, upload_url_limit, complete_attempt_limit.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E410": {
        "description": "Gone: gone.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E413": {
        "description": "Too large: payload_too_large, file_too_large, artifact_too_large, too_many_files.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E415": {
        "description": "Not application/json: unsupported_media_type.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E422": {
        "description": "Unprocessable: upload_mismatch, private_sites_unsupported, ttl_too_short, ttl_too_long.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E429": {
        "description": "Rate limited or over quota: rate_limited, quota_exceeded.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds to wait."
          }
        }
      },
      "E500": {
        "description": "Internal error: internal_error.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E503": {
        "description": "Service misconfigured: service_misconfigured.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
