{
  "openapi": "3.1.0",
  "info": {
    "title": "DocKiln API",
    "version": "1.1.0-review",
    "description": "Workspace-scoped document generation. All timestamps are Unix milliseconds unless documented otherwise. The parity additions in this review specification require the matching server build. Dynamic rendering also requires operator configuration."
  },
  "servers": [
    {
      "url": "https://dockiln.io",
      "description": "DocKiln hosted API"
    }
  ],
  "paths": {
    "/v1/library": {
      "get": {
        "summary": "Starter layouts",
        "security": [],
        "responses": {
          "200": {
            "description": "Starter layouts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Definition"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/register": {
      "post": {
        "summary": "Register",
        "security": [],
        "responses": {
          "201": {
            "description": "Register",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Credentials"
              }
            }
          }
        }
      }
    },
    "/v1/auth/login": {
      "post": {
        "summary": "Login",
        "security": [],
        "responses": {
          "200": {
            "description": "Login",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Credentials"
              }
            }
          }
        }
      }
    },
    "/v1/auth/logout": {
      "post": {
        "summary": "End session",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "204": {
            "description": "End session",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account": {
      "get": {
        "summary": "Account identity",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Account identity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "summary": "Monthly usage",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Monthly usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/keys": {
      "get": {
        "summary": "List key labels",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "List key labels",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Key"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create key and show its secret once",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "201": {
            "description": "Create key and show its secret once",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/keys/{id}": {
      "delete": {
        "summary": "Revoke key",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "204": {
            "description": "Revoke key",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      },
      "patch": {
        "summary": "Rename, enable or disable a key",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Rename, enable or disable a key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Key"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80,
                    "minLength": 1
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/templates": {
      "get": {
        "summary": "List workspace templates",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "List workspace templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Template"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create draft",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "201": {
            "description": "Create draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoredDefinition"
              }
            }
          }
        }
      }
    },
    "/v1/templates/{id}": {
      "get": {
        "summary": "Read draft",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Read draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "put": {
        "summary": "Save draft",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Save draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Template"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoredDefinition"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "if-unmodified-since-version",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Expected draft updated timestamp"
          }
        ]
      },
      "delete": {
        "summary": "Delete a workspace template and its versions",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "204": {
            "description": "Delete a workspace template and its versions",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/templates/{id}/publish": {
      "post": {
        "summary": "Snapshot current draft",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Snapshot current draft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "published": {
                      "type": "integer"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "if-unmodified-since-version",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Expected draft updated timestamp"
          }
        ]
      }
    },
    "/v1/templates/{id}/versions": {
      "get": {
        "summary": "Published snapshots",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Published snapshots",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Version"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/documents": {
      "get": {
        "summary": "Document history",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Document history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Job"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "before",
            "schema": {
              "type": "integer"
            }
          }
        ]
      },
      "post": {
        "summary": "Queue generation",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "202": {
            "description": "Queue generation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "Completed within the synchronous wait budget",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EncodedDocument"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Generation"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "Reuse exactly the same body to retrieve the original job without another quota charge."
          }
        ]
      }
    },
    "/v1/documents/{id}": {
      "get": {
        "summary": "Poll generation status",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Poll generation status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/v1/documents/{id}/pdf": {
      "get": {
        "summary": "Download generated file",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Download generated file",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EncodedDocument"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "encoding",
            "schema": {
              "type": "string",
              "enum": [
                "binary",
                "base64"
              ]
            }
          }
        ]
      }
    },
    "/v1/documents/{id}/file": {
      "get": {
        "summary": "Download generated file",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Download generated file",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EncodedDocument"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "query",
            "name": "encoding",
            "schema": {
              "type": "string",
              "enum": [
                "binary",
                "base64"
              ]
            }
          }
        ]
      }
    },
    "/v1/documents/{id}/link": {
      "get": {
        "summary": "Sign private S3 download for five minutes",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Sign private S3 download for five minutes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "expiresIn": {
                      "type": "integer"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ]
      }
    },
    "/v1/webhook": {
      "get": {
        "summary": "Endpoint and delivery history",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Endpoint and delivery history",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "deliveries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "job": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string"
                          },
                          "attempts": {
                            "type": "integer"
                          },
                          "next": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Set endpoint and rotate secret",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Set endpoint and rotate secret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  }
                },
                "required": [
                  "url"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Disable webhook",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "204": {
            "description": "Disable webhook",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/storage": {
      "get": {
        "summary": "Read destination metadata",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Read destination metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/S3Settings"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Configure encrypted S3 destination",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Configure encrypted S3 destination",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/S3Settings"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/S3Credentials"
                  },
                  {
                    "$ref": "#/components/schemas/R2Credentials"
                  },
                  {
                    "$ref": "#/components/schemas/GcsCredentials"
                  }
                ]
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Disable destination for future jobs",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "204": {
            "description": "Disable destination for future jobs",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/integrations": {
      "get": {
        "summary": "Provider configuration status",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Provider configuration status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ai": {
                      "type": "boolean"
                    },
                    "billing": {
                      "type": "boolean"
                    },
                    "object": {
                      "type": "boolean"
                    },
                    "webhooks": {
                      "type": "boolean"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/ai/template": {
      "post": {
        "summary": "Generate a structured draft",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Generate a structured draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Definition"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "prompt": {
                    "type": "string"
                  }
                },
                "required": [
                  "prompt"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/billing/test-checkout": {
      "post": {
        "summary": "Create Stripe test checkout",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Create Stripe test checkout",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string",
                      "enum": [
                        "test"
                      ]
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/preview-image": {
      "post": {
        "summary": "Preview private Open Graph image",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Preview private Open Graph image",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Validation, authorization, quota or service error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "definition": {
                    "$ref": "#/components/schemas/Definition"
                  },
                  "data": {
                    "type": "object",
                    "additionalProperties": true
                  }
                },
                "required": [
                  "definition",
                  "data"
                ]
              }
            }
          }
        }
      }
    },
    "/v1/templates/{id}/raw": {
      "get": {
        "summary": "Download published HTML source",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Download published HTML source",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "version",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    },
    "/v1/templates/{id}/html": {
      "post": {
        "summary": "Download HTML filled with JSON data",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Download HTML filled with JSON data",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "object"
                  }
                },
                "required": [
                  "data"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "version",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ]
      }
    },
    "/v1/documents/batch": {
      "post": {
        "summary": "Queue up to eight independently validated documents",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "207": {
            "description": "Queue up to eight independently validated documents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "integer"
                          },
                          "code": {
                            "type": "integer"
                          },
                          "id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "created": {
                            "type": "integer"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Generation"
                    },
                    "minItems": 1,
                    "maxItems": 8
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ]
      }
    },
    "/v1/logs": {
      "get": {
        "summary": "List the last 100 workspace requests",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "List the last 100 workspace requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RequestLog"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/logs/{id}": {
      "get": {
        "summary": "Inspect redacted request metadata",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect redacted request metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestLog"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/plan": {
      "get": {
        "summary": "Inspect UTC monthly allowances and rate limit",
        "security": [
          {
            "bearer": []
          },
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect UTC monthly allowances and rate limit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "unit": {
                      "type": "string"
                    },
                    "period": {
                      "type": "string"
                    },
                    "production": {
                      "$ref": "#/components/schemas/Usage"
                    },
                    "sandbox": {
                      "$ref": "#/components/schemas/Usage"
                    },
                    "requestsPerMinute": {
                      "type": "integer"
                    },
                    "overages": {
                      "type": "boolean"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/invoices": {
      "get": {
        "summary": "Read up to 25 linked Stripe test invoices",
        "security": [
          {
            "session": []
          }
        ],
        "responses": {
          "200": {
            "description": "Read up to 25 linked Stripe test invoices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "mode": {
                      "type": "string",
                      "enum": [
                        "test"
                      ]
                    },
                    "invoices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "number": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "amount_due": {
                            "type": "integer"
                          },
                          "created": {
                            "type": "integer",
                            "description": "Unix seconds from Stripe"
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation ID",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "session": {
        "type": "apiKey",
        "in": "cookie",
        "name": "dockiln"
      }
    },
    "schemas": {
      "Page": {
        "type": "object",
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "A4",
              "Letter",
              "Legal",
              "Label"
            ]
          },
          "margin": {
            "type": "integer",
            "minimum": 8,
            "maximum": 35
          },
          "landscape": {
            "type": "boolean"
          },
          "header": {
            "type": "string"
          },
          "footer": {
            "type": "string"
          }
        }
      },
      "Controls": {
        "type": "object",
        "properties": {
          "preset": {
            "type": "string",
            "enum": [
              "og",
              "square",
              "story"
            ]
          },
          "media": {
            "type": "string",
            "enum": [
              "screen",
              "print"
            ]
          },
          "width": {
            "type": "integer",
            "minimum": 160,
            "maximum": 2400
          },
          "height": {
            "type": "integer",
            "minimum": 100,
            "maximum": 2400
          },
          "fullPage": {
            "type": "boolean"
          },
          "waitFonts": {
            "type": "boolean"
          },
          "waitImages": {
            "type": "boolean"
          },
          "selector": {
            "type": "string"
          },
          "timeoutMs": {
            "type": "integer",
            "minimum": 100,
            "maximum": 5000
          },
          "css": {
            "type": "string"
          },
          "javascript": {
            "type": "boolean"
          },
          "script": {
            "type": "string",
            "maxLength": 12000
          },
          "predicate": {
            "type": "string",
            "maxLength": 1000
          },
          "lazyImages": {
            "type": "boolean"
          },
          "delayMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2000
          },
          "idleMs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          },
          "ignoreLongPolling": {
            "type": "boolean"
          },
          "transparent": {
            "type": "boolean"
          },
          "quality": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "pixelRatio": {
            "type": "integer",
            "enum": [
              1,
              2,
              4
            ]
          },
          "captureSelector": {
            "type": "string",
            "maxLength": 160
          },
          "clip": {
            "type": "object",
            "properties": {
              "x": {
                "type": "integer",
                "minimum": 0,
                "maximum": 6000
              },
              "y": {
                "type": "integer",
                "minimum": 0,
                "maximum": 6000
              },
              "width": {
                "type": "integer",
                "minimum": 1,
                "maximum": 6000
              },
              "height": {
                "type": "integer",
                "minimum": 1,
                "maximum": 6000
              }
            },
            "required": [
              "x",
              "y",
              "width",
              "height"
            ]
          }
        }
      },
      "Definition": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "subtitle": {
            "type": "string"
          },
          "person": {
            "type": "string"
          },
          "footer": {
            "type": "string"
          },
          "accent": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rows": {
            "type": "string"
          },
          "sample": {
            "type": "object",
            "additionalProperties": true
          },
          "page": {
            "$ref": "#/components/schemas/Page"
          },
          "slug": {
            "type": "string",
            "maxLength": 63
          }
        },
        "required": [
          "title",
          "subtitle",
          "person",
          "footer",
          "accent",
          "columns",
          "fields",
          "rows",
          "sample",
          "page"
        ]
      },
      "Template": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "draft": {
            "$ref": "#/components/schemas/StoredDefinition"
          },
          "published": {
            "type": [
              "integer",
              "null"
            ]
          },
          "updated": {
            "type": "integer"
          },
          "slug": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Version": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer"
          },
          "definition": {
            "$ref": "#/components/schemas/StoredDefinition"
          },
          "created": {
            "type": "integer"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed"
            ]
          },
          "format": {
            "type": "string",
            "enum": [
              "pdf",
              "png",
              "jpeg",
              "webp"
            ]
          },
          "created": {
            "type": "integer"
          },
          "updated": {
            "type": "integer"
          },
          "download": {
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "storage": {
            "description": "Workspace filesystem (local), private workspace bucket (gcs), or customer S3 (object). Null until persisted.",
            "enum": [
              "local",
              "gcs",
              "object",
              null
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "sandbox": {
            "type": "boolean"
          },
          "expiresAt": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "Generation": {
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string"
          },
          "version": {
            "type": "integer"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          },
          "html": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "format": {
            "type": "string",
            "enum": [
              "pdf",
              "png",
              "jpeg",
              "webp"
            ]
          },
          "page": {
            "$ref": "#/components/schemas/Page"
          },
          "controls": {
            "$ref": "#/components/schemas/Controls"
          },
          "delivery": {
            "type": "string",
            "enum": [
              "local",
              "object"
            ]
          },
          "compress": {
            "type": "boolean"
          },
          "externalAssets": {
            "type": "boolean"
          },
          "assetUrls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "maxItems": 16
          },
          "allowHttpErrors": {
            "type": "boolean"
          },
          "sourceAuth": {
            "$ref": "#/components/schemas/SourceAuth"
          },
          "print": {
            "$ref": "#/components/schemas/PrintOptions"
          },
          "processing": {
            "$ref": "#/components/schemas/Processing"
          },
          "sandbox": {
            "type": "boolean"
          },
          "ttlSeconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 2592000
          },
          "logRequest": {
            "type": "boolean"
          },
          "sensitive": {
            "type": "boolean"
          },
          "response": {
            "type": "string",
            "enum": [
              "async",
              "binary",
              "base64"
            ]
          },
          "filename": {
            "type": "string",
            "maxLength": 91
          },
          "webhook": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "secret": {
                "type": "string",
                "maxLength": 128,
                "minLength": 32,
                "writeOnly": true
              }
            },
            "required": [
              "url",
              "secret"
            ]
          }
        },
        "oneOf": [
          {
            "required": [
              "url"
            ]
          },
          {
            "required": [
              "html"
            ]
          },
          {
            "required": [
              "templateId"
            ]
          }
        ],
        "example": {
          "html": "<h1>Order confirmed</h1>",
          "format": "pdf",
          "page": {
            "format": "Letter",
            "footer": "Page {page} of {pages}"
          }
        }
      },
      "Credentials": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "password": {
            "type": "string",
            "minLength": 12,
            "maxLength": 128,
            "writeOnly": true
          }
        },
        "required": [
          "email",
          "password"
        ]
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string"
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "used": {
            "type": "integer"
          },
          "quota": {
            "type": "integer"
          },
          "resetsAt": {
            "type": "integer"
          }
        }
      },
      "Key": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "created": {
            "type": "integer"
          },
          "enabled": {
            "type": "integer",
            "enum": [
              0,
              1
            ]
          }
        }
      },
      "S3Settings": {
        "type": "object",
        "properties": {
          "bucket": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "s3",
              "r2",
              "gcs"
            ]
          },
          "accountId": {
            "type": "string"
          },
          "projectId": {
            "type": "string"
          }
        }
      },
      "S3Credentials": {
        "type": "object",
        "properties": {
          "bucket": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "accessKeyId": {
            "type": "string",
            "writeOnly": true
          },
          "secretAccessKey": {
            "type": "string",
            "writeOnly": true
          },
          "provider": {
            "type": "string",
            "enum": [
              "s3"
            ]
          }
        },
        "required": [
          "bucket",
          "region",
          "accessKeyId",
          "secretAccessKey"
        ]
      },
      "Problem": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "HtmlDefinition": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "html"
            ]
          },
          "title": {
            "type": "string",
            "maxLength": 100
          },
          "html": {
            "type": "string",
            "maxLength": 100000
          },
          "sample": {
            "type": "object"
          },
          "page": {
            "$ref": "#/components/schemas/Page"
          },
          "slug": {
            "type": "string",
            "maxLength": 63
          }
        },
        "required": [
          "kind",
          "title",
          "html",
          "sample"
        ]
      },
      "StoredDefinition": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/HtmlDefinition"
          },
          {
            "$ref": "#/components/schemas/Definition"
          }
        ]
      },
      "PrintOptions": {
        "type": "object",
        "properties": {
          "paper": {
            "type": "string",
            "enum": [
              "A0",
              "A1",
              "A2",
              "A3",
              "A4",
              "A5",
              "A6",
              "Letter",
              "Legal",
              "Ledger",
              "Tabloid"
            ]
          },
          "width": {
            "type": "string",
            "pattern": "^\\d{1,4}(\\.\\d{1,3})?(mm|cm|in|pt|px)$"
          },
          "height": {
            "oneOf": [
              {
                "type": "string",
                "pattern": "^\\d{1,4}(\\.\\d{1,3})?(mm|cm|in|pt|px)$"
              },
              {
                "type": "string",
                "enum": [
                  "auto"
                ]
              }
            ]
          },
          "margins": {
            "type": "object",
            "properties": {
              "left": {
                "type": "string",
                "pattern": "^\\d{1,4}(\\.\\d{1,3})?(mm|cm|in|pt|px)$"
              },
              "right": {
                "type": "string",
                "pattern": "^\\d{1,4}(\\.\\d{1,3})?(mm|cm|in|pt|px)$"
              },
              "top": {
                "type": "string",
                "pattern": "^\\d{1,4}(\\.\\d{1,3})?(mm|cm|in|pt|px)$"
              },
              "bottom": {
                "type": "string",
                "pattern": "^\\d{1,4}(\\.\\d{1,3})?(mm|cm|in|pt|px)$"
              }
            },
            "additionalProperties": false
          },
          "ranges": {
            "type": "string",
            "maxLength": 100
          },
          "scale": {
            "type": "number",
            "minimum": 0.1,
            "maximum": 2
          },
          "background": {
            "type": "boolean"
          },
          "headerHtml": {
            "type": "string",
            "maxLength": 4000
          },
          "footerHtml": {
            "type": "string",
            "maxLength": 4000
          },
          "startAt": {
            "type": "integer",
            "minimum": 1,
            "maximum": 500
          }
        },
        "additionalProperties": false
      },
      "Processing": {
        "type": "object",
        "properties": {
          "metadata": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "maxLength": 256
              },
              "author": {
                "type": "string",
                "maxLength": 256
              },
              "subject": {
                "type": "string",
                "maxLength": 256
              },
              "creator": {
                "type": "string",
                "maxLength": 256
              }
            },
            "additionalProperties": false
          },
          "trimBlankEnd": {
            "type": "boolean"
          },
          "watermark": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "maxLength": 100
              },
              "image": {
                "type": "string",
                "maxLength": 240000
              },
              "size": {
                "type": "integer",
                "minimum": 4,
                "maximum": 256
              },
              "rotate": {
                "type": "number",
                "minimum": -180,
                "maximum": 180
              },
              "opacity": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "position": {
                "type": "string",
                "enum": [
                  "top-left",
                  "center",
                  "bottom-right"
                ]
              }
            },
            "oneOf": [
              {
                "required": [
                  "text"
                ]
              },
              {
                "required": [
                  "image"
                ]
              }
            ]
          },
          "protection": {
            "type": "object",
            "properties": {
              "userPassword": {
                "type": "string",
                "maxLength": 120,
                "writeOnly": true
              },
              "ownerPassword": {
                "type": "string",
                "maxLength": 100,
                "writeOnly": true
              },
              "print": {
                "type": "boolean"
              },
              "copy": {
                "type": "boolean"
              },
              "modify": {
                "type": "boolean"
              }
            },
            "required": [
              "ownerPassword"
            ]
          }
        }
      },
      "SourceAuth": {
        "type": "object",
        "properties": {
          "basic": {
            "type": "object",
            "properties": {
              "username": {
                "type": "string"
              },
              "password": {
                "type": "string",
                "writeOnly": true
              }
            },
            "required": [
              "username",
              "password"
            ]
          },
          "headers": {
            "type": "object",
            "maxProperties": 12,
            "additionalProperties": {
              "type": "string",
              "maxLength": 1024,
              "writeOnly": true
            }
          },
          "cookies": {
            "type": "object",
            "maxProperties": 12,
            "additionalProperties": {
              "type": "string",
              "maxLength": 1024,
              "writeOnly": true
            }
          }
        },
        "additionalProperties": false
      },
      "EncodedDocument": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "base64": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "filename",
          "contentType",
          "base64"
        ]
      },
      "RequestLog": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "method": {
            "type": "string"
          },
          "route": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "duration": {
            "type": "integer"
          },
          "created": {
            "type": "integer"
          }
        }
      },
      "R2Credentials": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "r2"
            ]
          },
          "accountId": {
            "type": "string",
            "pattern": "^[0-9a-f]{32}$"
          },
          "bucket": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "accessKeyId": {
            "type": "string",
            "writeOnly": true
          },
          "secretAccessKey": {
            "type": "string",
            "writeOnly": true
          }
        },
        "required": [
          "provider",
          "accountId",
          "bucket",
          "accessKeyId",
          "secretAccessKey"
        ]
      },
      "GcsCredentials": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "gcs"
            ]
          },
          "projectId": {
            "type": "string"
          },
          "bucket": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "clientEmail": {
            "type": "string",
            "format": "email",
            "writeOnly": true
          },
          "privateKey": {
            "type": "string",
            "writeOnly": true
          }
        },
        "required": [
          "provider",
          "projectId",
          "bucket",
          "clientEmail",
          "privateKey"
        ]
      }
    }
  }
}
