{
  "openapi": "3.1.0",
  "info": {
    "title": "PageDrawer publishing API",
    "version": "2.2.0",
    "description": "A verified founder accepts the current agreement and creates a workspace directly. Scoped agent credentials publish and edit through REST or MCP. Free includes one workspace and ten resources. Launch is USD $4.99 yearly for three workspaces and fifty resources total, with a technical limit of twenty resources per workspace. Checkout is disabled for Free launch."
  },
  "servers": [
    {
      "url": "https://pagedrawer.com"
    }
  ],
  "paths": {
    "/api/workspaces": {
      "post": {
        "operationId": "createWorkspace",
        "responses": {
          "201": {
            "description": "Workspace created with the agreement receipt and workspace URL."
          },
          "400": {
            "description": "request_rejected for invalid input, or direct_founder_required if legacy founder nomination fields are supplied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "403": {
            "description": "direct_founder_required if unsigned in direct mode; founder_authentication_required for an invalid assent context; request_rejected for a rejected origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "409": {
            "description": "agreement_version_required when assent is missing or stale, or request_rejected when the brand is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited or budget_exhausted. Respect Retry-After and use bounded backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "402": {
            "description": "workspace_allowance_reached: Account workspace allowance reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "401": {
            "description": "A fresh first-party verification is needed before assent. The code can be request_rejected or founder_authentication_required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "admission_unavailable, budget_unavailable, concurrency_exhausted or restricted. Respect Retry-After when present. Do not retry an ambiguous write blindly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkspace"
              }
            }
          }
        },
        "parameters": [],
        "description": "Create for the signed-in founder, using their verified first-party session and affirmative acceptance of the current agreement. Indirect nominations are disabled.",
        "security": [
          {
            "founderSession": []
          }
        ]
      }
    },
    "/api/workspaces/{brand}/resources": {
      "get": {
        "operationId": "listResources",
        "description": "List text and JSON files in the authorized workspace when workspace hosting is enabled.",
        "security": [
          {
            "workspaceBearer": []
          }
        ],
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid resource"
          },
          "403": {
            "description": "Workspace access denied"
          },
          "404": {
            "description": "Resource or feature unavailable"
          },
          "409": {
            "description": "Founder activation required or publication conflict"
          },
          "402": {
            "description": "Account allowance reached"
          }
        }
      }
    },
    "/api/workspaces/{brand}/resources/{kind}": {
      "get": {
        "operationId": "getResource",
        "description": "Read an authorized file by fixed kind or filename.",
        "security": [
          {
            "workspaceBearer": []
          },
          {
            "founderSession": []
          }
        ],
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "anyOf": [
                {
                  "enum": [
                    "app-ads",
                    "ads",
                    "robots",
                    "llms",
                    "security"
                  ]
                },
                {
                  "pattern": "^(?=.{5,64}$)[a-z0-9]+(?:[._-][a-z0-9]+)*\\.(?:txt|json)$"
                }
              ],
              "description": "Fixed kind or custom single-segment filename. Reserved names are unavailable."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid resource"
          },
          "403": {
            "description": "Workspace access denied"
          },
          "404": {
            "description": "Resource or feature unavailable"
          },
          "409": {
            "description": "Founder activation required or publication conflict"
          },
          "402": {
            "description": "Account allowance reached"
          }
        }
      },
      "put": {
        "operationId": "publishResource",
        "description": "Publish or edit a text file or syntactically valid JSON file. Send the original content as the content string. Custom files use the workspace hostname and a fixed text/plain or application/json response type. Limit: 32,768 UTF-8 bytes per custom file. Each file counts once.",
        "security": [
          {
            "workspaceBearer": []
          },
          {
            "founderSession": []
          }
        ],
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "anyOf": [
                {
                  "enum": [
                    "app-ads",
                    "ads",
                    "robots",
                    "llms",
                    "security"
                  ]
                },
                {
                  "pattern": "^(?=.{5,64}$)[a-z0-9]+(?:[._-][a-z0-9]+)*\\.(?:txt|json)$"
                }
              ],
              "description": "Fixed kind or custom single-segment filename. Reserved names are unavailable."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid resource"
          },
          "403": {
            "description": "request_rejected for missing, expired, revoked or out-of-scope authorization; abuse_suspended when suspended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "404": {
            "description": "Resource or feature unavailable"
          },
          "409": {
            "description": "workspace_quota: the workspace may have reached its independent limit of 20 resources or its storage budget. An authorized edit at the count limit remains allowed if it meets storage and admission controls.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "402": {
            "description": "upgrade_required: Account publication allowance reached. Updates to existing resources remain allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited, workspace_rate or budget_exhausted. Respect Retry-After and use bounded backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "503": {
            "description": "admission_unavailable, budget_unavailable, concurrency_exhausted or restricted. Respect Retry-After when present. Do not retry an ambiguous write blindly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "content": {
                    "type": "string"
                  }
                },
                "required": [
                  "content"
                ]
              }
            }
          }
        }
      }
    },
    "/api/workspaces/{brand}/resource-reservations/{kind}": {
      "put": {
        "operationId": "reserveResource",
        "description": "Legacy pending-workspace reservation endpoint. Unavailable in direct-founder mode.",
        "security": [
          {
            "workspaceBearer": []
          }
        ],
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "anyOf": [
                {
                  "enum": [
                    "app-ads",
                    "ads",
                    "robots",
                    "llms",
                    "security"
                  ]
                },
                {
                  "pattern": "^(?=.{5,64}$)[a-z0-9]+(?:[._-][a-z0-9]+)*\\.(?:txt|json)$"
                }
              ],
              "description": "Fixed kind or custom single-segment filename. Reserved names are unavailable."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "400": {
            "description": "Invalid resource"
          },
          "403": {
            "description": "Workspace access denied"
          },
          "404": {
            "description": "Resource or feature unavailable"
          },
          "409": {
            "description": "Founder activation required or publication conflict"
          },
          "402": {
            "description": "Account allowance reached"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/workspaces/{brand}/reservations/{slug}": {
      "put": {
        "operationId": "reservePage",
        "description": "Legacy pending-workspace reservation endpoint. Unavailable in direct-founder mode.",
        "security": [
          {
            "workspaceBearer": []
          }
        ],
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reserved URL, with activation pending"
          },
          "403": {
            "description": "Workspace access denied"
          },
          "404": {
            "description": "Founder activation not available"
          },
          "409": {
            "description": "A reservation is unavailable"
          }
        }
      }
    },
    "/api/workspaces/{brand}/pages/{slug}": {
      "put": {
        "operationId": "publishPage",
        "description": "Publish or update an active workspace page with a founder-authorized scoped key. Updating the same slug preserves the public URL.",
        "responses": {
          "200": {
            "description": "Success; publishing returns url"
          },
          "400": {
            "description": "Invalid request"
          },
          "403": {
            "description": "request_rejected for missing, expired, revoked or out-of-scope authorization; abuse_suspended when suspended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "409": {
            "description": "workspace_quota: the workspace may have reached its independent limit of 20 resources or its storage budget. An authorized edit at the count limit remains allowed if it meets storage and admission controls.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited, workspace_rate or budget_exhausted. Respect Retry-After and use bounded backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "402": {
            "description": "upgrade_required: Account publication allowance reached. Updates to existing resources remain allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "503": {
            "description": "admission_unavailable, budget_unavailable, concurrency_exhausted or restricted. Respect Retry-After when present. Do not retry an ambiguous write blindly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          }
        },
        "security": [
          {
            "workspaceBearer": []
          },
          {
            "founderSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Page"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/workspaces/{brand}/pages": {
      "get": {
        "operationId": "listPages",
        "responses": {
          "200": {
            "description": "Success; publishing returns url"
          },
          "400": {
            "description": "Invalid request"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Brand already exists"
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "security": [
          {
            "workspaceBearer": []
          }
        ],
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/billing/{brand}/status": {
      "get": {
        "operationId": "billingStatus",
        "description": "Test-only. Owner session or workspace read credential required.",
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Billing status or URL"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Billing operation pending or subscription already exists"
          },
          "503": {
            "description": "Billing not configured or unavailable"
          }
        }
      }
    },
    "/api/billing/{brand}/link": {
      "get": {
        "operationId": "billingLink",
        "description": "Test-only. Owner session or workspace read credential required.",
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Billing status or URL"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Billing operation pending or subscription already exists"
          },
          "503": {
            "description": "Billing not configured or unavailable"
          }
        }
      }
    },
    "/api/billing/{brand}/checkout": {
      "post": {
        "operationId": "billingCheckout",
        "description": "Test-only. Verified-owner session required; agent credentials cannot authorize payments.",
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Billing status or URL"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Billing operation pending or subscription already exists"
          },
          "503": {
            "description": "Billing not configured or unavailable"
          }
        }
      }
    },
    "/api/billing/{brand}/portal": {
      "post": {
        "operationId": "billingPortal",
        "description": "Test-only. Verified-owner session required; agent credentials cannot authorize payments.",
        "parameters": [
          {
            "name": "brand",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Billing status or URL"
          },
          "403": {
            "description": "Not authorized"
          },
          "409": {
            "description": "Billing operation pending or subscription already exists"
          },
          "503": {
            "description": "Billing not configured or unavailable"
          }
        }
      }
    },
    "/api/me": {
      "get": {
        "operationId": "getFounderContext",
        "description": "In direct-founder mode, returns the versioned privacy_notice path. A signed-in founder also receives the current founder_agreement when activation is configured.",
        "responses": {
          "200": {
            "description": "Founder session and public onboarding context"
          }
        }
      }
    },
    "/api/auth/request": {
      "post": {
        "operationId": "requestSignInCode",
        "description": "Show the exact privacy_notice link from GET /api/me before collecting the founder’s own email. In open direct-founder mode submit email and privacy_notice together. Never ask an agent to collect a sign-in code.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "privacy_notice"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "privacy_notice": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Challenge issued"
          },
          "409": {
            "description": "privacy_notice_required: show the current notice before requesting a code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited or budget_exhausted. Respect Retry-After and use bounded backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "503": {
            "description": "admission_unavailable, budget_unavailable, concurrency_exhausted or restricted, or email_delivery_unavailable when the email provider fails. Respect Retry-After when present. Do not retry an ambiguous write blindly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/verify": {
      "post": {
        "operationId": "verifyFounderSignInCode",
        "description": "Founder submits the code directly in the first-party sign-in flow. The successful response sets a secure HttpOnly session cookie. Never give the code or cookie to an agent.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "challenge_id",
                  "code"
                ],
                "properties": {
                  "challenge_id": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified founder session created.",
            "headers": {
              "Set-Cookie": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "email": {
                      "type": "string",
                      "format": "email"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "request_rejected: invalid, expired or consumed code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited or budget_exhausted. Respect Retry-After and use bounded backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "503": {
            "description": "admission_unavailable, concurrency_exhausted or restricted. Follow Retry-After when supplied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait when a retry delay is provided.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          }
        }
      }
    },
    "/api/pricing": {
      "get": {
        "operationId": "getPricing",
        "description": "Read plan allowances and the billing_enabled and workspace_hosts availability flags. A displayed price does not enable payment. workspace_resource_limit gives the separate technical limit (20 resources per claimed workspace).",
        "responses": {
          "200": {
            "description": "Current plans and feature availability.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workspace_resource_limit": {
                      "type": "integer",
                      "const": 20
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateWorkspace": {
        "type": "object",
        "required": [
          "brand",
          "agreement"
        ],
        "properties": {
          "brand": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{0,47}$"
          },
          "agreement": {
            "type": "object",
            "required": [
              "accepted",
              "version",
              "sha256"
            ],
            "properties": {
              "accepted": {
                "type": "boolean",
                "const": true
              },
              "version": {
                "type": "string"
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            }
          }
        }
      },
      "Page": {
        "type": "object",
        "required": [
          "title",
          "content"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 160
          },
          "content": {
            "type": "string",
            "maxLength": 60000
          }
        }
      },
      "OperationError": {
        "type": "object",
        "required": [
          "code",
          "error",
          "retry_after"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "retry_after": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    },
    "securitySchemes": {
      "workspaceBearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "founderSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "__Host-pd_session"
      }
    }
  }
}
