openapi: 3.0.3
info:
  title: VoidPaste API
  version: 1.1.0
  description: |
    REST API for VoidPaste — fast, private paste sharing for developers.

    **Production base URL:** `https://voidpaste.com` (same origin for web and API;
    routes under `/api/v1/...`, plus `/raw/{id}` and `/download/{id}` aliases).

    The product is **free**. Anonymous pastes are limited to **1 MB** (1048576 bytes);
    signed-in accounts and API keys allow **5 MB** (5242880 bytes).
    There are no paid tiers. Stripe checkout routes exist only as dormant operator
    hooks and return **501** unless Stripe env is deliberately set.

    **Auth:** session cookie `vp_session` (web) or `Authorization: Bearer vp_live_...`
    (API keys). Password pastes use header `X-Paste-Password` only (not the query string).
    Anonymous creates return a one-time `management_token`; send it only in
    `X-Paste-Management-Token` to delete that paste. It is never part of a URL.

    Transactional mail (verify / password reset) is sent from **hello@voidpaste.com**
    in production (`MAIL_FROM=VoidPaste <hello@voidpaste.com>`).
servers:
  - url: https://voidpaste.com
    description: Production
tags:
  - name: pastes
  - name: auth
  - name: api-keys
  - name: collections
  - name: moderation
  - name: admin
    description: Session-only operator routes. Requires role admin or owner.
  - name: billing
    description: Dormant — not offered in the product UI
paths:
  /health:
    get:
      summary: Liveness
      responses:
        "200":
          description: '{"status":"ok"}'
  /ready:
    get:
      summary: Readiness (Postgres; Redis when configured)
      responses:
        "200":
          description: Ready
        "503":
          description: Not ready
  /metrics:
    get:
      summary: Simple in-process request counters (JSON)
      description: |
        JSON only. Not Prometheus text exposition and not OpenTelemetry.
        Structured JSON access logs with `request_id` are the primary signal.
      responses:
        "200":
          description: Counters
  /raw/{id}:
    get:
      tags: [pastes]
      summary: Raw paste body (alias)
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PastePassword"
      responses:
        "200":
          description: text/plain; nosniff; CSP sandbox; DENY framing
          content:
            text/plain:
              schema:
                type: string
        "401":
          $ref: "#/components/responses/Error"
        "404":
          $ref: "#/components/responses/Error"
        "410":
          description: Expired or burned
  /download/{id}:
    get:
      tags: [pastes]
      summary: Download paste as attachment (alias)
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PastePassword"
      responses:
        "200":
          description: text/plain attachment
          content:
            text/plain:
              schema:
                type: string
        "401":
          $ref: "#/components/responses/Error"
        "404":
          $ref: "#/components/responses/Error"
  /api/v1/pastes:
    post:
      tags: [pastes]
      summary: Create paste (anonymous allowed)
      description: |
        Default visibility is **unlisted** when omitted.
        `password` is only valid with `visibility=password` (otherwise 400).
        Secret detection may return `warnings` or block with 422.
        Optional `Idempotency-Key` (max 256 chars) stores/replays the JSON
        response for 24h per user (or anon IP). Concurrent duplicate keys
        return 409. Replay sets `Idempotency-Replayed: true`.
        API keys require `pastes:write` (or `*`).
        Anonymous creates also return `management_token` exactly once. Only a
        keyed digest is retained server-side. Idempotency replays omit the token.
        Authenticated callers must have a verified email. An unverified caller
        may set `X-VoidPaste-Anonymous: true` to explicitly use anonymous
        ownership, size, quota, and rate-limit semantics.
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            maxLength: 256
        - name: X-VoidPaste-Anonymous
          in: header
          required: false
          description: Explicitly discard authentication for anonymous paste creation.
          schema:
            type: boolean
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PasteCreate"
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PasteCreateEnvelope"
        "400":
          $ref: "#/components/responses/Error"
        "403":
          description: insufficient_scope or email_verification_required
        "409":
          description: idempotency_conflict
        "413":
          description: Paste size or authenticated account aggregate quota exceeded
        "422":
          description: Secret detection or malware scanner blocked the body (not stored)
        "429":
          $ref: "#/components/responses/Error"
        "503":
          description: idempotency_unavailable
  /api/v1/pastes/{id}:
    get:
      tags: [pastes]
      summary: Get paste metadata + content when authorized
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PastePassword"
      responses:
        "200":
          description: Paste envelope
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PasteGetEnvelope"
        "401":
          description: password_required / bad_password
        "403":
          $ref: "#/components/responses/Error"
        "413":
          description: Retained storage quota exceeded
        "404":
          $ref: "#/components/responses/Error"
        "410":
          description: expired / burned
    patch:
      tags: [pastes]
      summary: Update paste (owner)
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "200":
          description: Updated
        "401":
          $ref: "#/components/responses/Error"
        "403":
          $ref: "#/components/responses/Error"
    delete:
      tags: [pastes]
      summary: Soft-delete paste (account owner or anonymous capability)
      description: |
        Authenticated owners use their session/API key as before. Anonymous
        creators send the one-time token in `X-Paste-Management-Token`.
        Missing/invalid tokens and unknown paste IDs all return the same 404.
      security:
        - session: []
        - apiKey: []
        - managementToken: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PasteManagementToken"
      responses:
        "204":
          description: Deleted
        "404":
          $ref: "#/components/responses/Error"
        "429":
          $ref: "#/components/responses/Error"
  /api/v1/pastes/{id}/claim:
    post:
      tags: [pastes]
      summary: Claim an anonymous paste into the authenticated account
      description: |
        Requires a session or an API key with `pastes:write`, plus the one-time
        anonymous capability in `X-Paste-Management-Token`. Ownership transfer
        and capability invalidation are atomic. Unknown, unavailable, already
        owned, and invalid-token cases share the same 404 response.
      security:
        - session: []
          managementToken: []
        - apiKey: []
          managementToken: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PasteManagementToken"
      responses:
        "200":
          description: Claimed paste envelope
        "401":
          $ref: "#/components/responses/Error"
        "403":
          description: Insufficient API-key scope
        "413":
          description: Active paste count or retained storage quota exceeded
        "404":
          $ref: "#/components/responses/Error"
        "429":
          $ref: "#/components/responses/Error"
  /api/v1/pastes/{id}/meta:
    get:
      tags: [pastes]
      summary: Paste metadata without content, view increment, or burn
      description: |
        For HTML/OG tags. Does not increment view_count, does not burn, and
        omits the body. Opening the paste still uses GET /api/v1/pastes/{id}.
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PastePassword"
      responses:
        "200":
          description: Metadata envelope (no content field)
        "401":
          description: password_required / bad_password
        "403":
          $ref: "#/components/responses/Error"
        "404":
          $ref: "#/components/responses/Error"
        "410":
          description: expired / burned
  /api/v1/pastes/{id}/versions:
    get:
      tags: [pastes]
      summary: List paste versions (owner)
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "200":
          description: Version list with retained count, additional storage, policy, grace protection, and current prune eligibility
        "403":
          description: Unavailable
  /api/v1/pastes/{id}/versions/{version}:
    get:
      tags: [pastes]
      summary: Get a paste version body (owner)
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - name: version
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Version with content
    delete:
      tags: [pastes]
      summary: Permanently delete a selected retained version (owner)
      description: Refuses deletion when the version object is also the current paste object.
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - name: version
          in: path
          required: true
          schema:
            type: integer
      responses:
        "204":
          description: Version deleted and unreferenced object queued for GC
        "400":
          $ref: "#/components/responses/Error"
        "404":
          $ref: "#/components/responses/Error"
  /api/v1/pastes/{id}/versions/{version}/restore:
    post:
      tags: [pastes]
      summary: Restore a historical version (owner)
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - name: version
          in: path
          required: true
          schema:
            type: integer
      responses:
        "200":
          description: Restored paste metadata
  /api/v1/pastes/{id}/diff:
    get:
      tags: [pastes]
      summary: Diff two versions (to=0 means current)
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - name: from
          in: query
          required: true
          schema:
            type: integer
        - name: to
          in: query
          schema:
            type: integer
            default: 0
      responses:
        "200":
          description: '{"diff":"..."}'
  /api/v1/me/pastes:
    get:
      tags: [pastes]
      summary: List my pastes
      security:
        - session: []
        - apiKey: []
      responses:
        "200":
          description: List
  /api/v1/auth/register:
    post:
      tags: [auth]
      summary: Register
      description: |
        Returns the same accepted response for new and existing addresses.
        When eligible, sends a verification email (production From hello@voidpaste.com).
        Link points at the web app `/verify-email?token=...` which POSTs the
        token to this API.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email, password]
              properties:
                email:
                  type: string
                  format: email
                  maxLength: 254
                password:
                  type: string
                  minLength: 8
                  maxLength: 1024
                display_name:
                  type: string
                  maxLength: 100
      responses:
        "202":
          description: Opaque accepted response
  /api/v1/auth/login:
    post:
      tags: [auth]
      summary: Login (sets vp_session cookie)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email, password]
              properties:
                email:
                  type: string
                password:
                  type: string
      responses:
        "200":
          description: Logged in
  /api/v1/auth/logout:
    post:
      tags: [auth]
      summary: Logout current session
      responses:
        "200":
          description: Logged out
  /api/v1/auth/me:
    get:
      tags: [auth]
      summary: Current user
      security:
        - session: []
        - apiKey: []
      responses:
        "200":
          description: User
  /api/v1/auth/csrf:
    get:
      tags: [auth]
      summary: Issue CSRF double-submit token
      description: |
        Sets a readable `vp_csrf` cookie and returns `{csrf_token}`.
        Cookie-authenticated mutating requests must send header `X-CSRF-Token`
        matching the cookie. Bearer API keys skip CSRF.
      responses:
        "200":
          description: CSRF token
  /api/v1/auth/providers:
    get:
      tags: [auth]
      summary: List enabled auth providers (no secrets)
      description: password is always true; github when OAuth env is set; webauthn when configured at boot.
      responses:
        "200":
          description: Providers map (password, github, webauthn booleans)
  /api/v1/auth/oauth/github:
    get:
      tags: [auth]
      summary: Start browser-bound, single-use GitHub OAuth with S256 PKCE (302 when configured)
      responses:
        "302":
          description: Redirect to GitHub
        "404":
          description: OAuth not configured
  /api/v1/auth/oauth/github/callback:
    get:
      tags: [auth]
      summary: GitHub OAuth callback
      responses:
        "302":
          description: Redirect to app dashboard or login error
  /api/v1/auth/webauthn/register/begin:
    post:
      tags: [auth]
      summary: User-verifying resident WebAuthn registration begin
      security:
        - session: []
      responses:
        "200":
          description: Creation options + session id
        "501":
          description: WebAuthn unavailable
  /api/v1/auth/webauthn/register/finish:
    post:
      tags: [auth]
      summary: WebAuthn registration finish
      security:
        - session: []
      responses:
        "200":
          description: Credential stored
        "501":
          description: WebAuthn unavailable
  /api/v1/auth/webauthn/login/begin:
    post:
      tags: [auth]
      summary: WebAuthn login begin
      responses:
        "200":
          description: Assertion options + session id
        "501":
          description: WebAuthn unavailable
  /api/v1/auth/webauthn/login/finish:
    post:
      tags: [auth]
      summary: WebAuthn login finish (sets session cookie)
      responses:
        "200":
          description: Authenticated
        "501":
          description: WebAuthn unavailable
  /api/v1/auth/webauthn/credentials:
    get:
      tags: [auth]
      summary: List registered passkeys
      security:
        - session: []
      responses:
        "200":
          description: Credentials
  /api/v1/auth/webauthn/credentials/{id}:
    delete:
      tags: [auth]
      summary: Remove a passkey (id is base64 credential id)
      security:
        - session: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "204":
          description: Deleted
  /api/v1/billing/status:
    get:
      tags: [billing]
      summary: Billing status (dormant; product is free)
      responses:
        "200":
          description: Includes stripe_checkout boolean. No public prices.
  /api/v1/billing/checkout:
    post:
      tags: [billing]
      summary: Stripe Checkout (dormant; 501 unless operator env is set)
      security:
        - session: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [plan]
              properties:
                plan:
                  type: string
                  enum: [pro, team]
      responses:
        "200":
          description: Checkout URL (only when Stripe configured)
        "501":
          description: Stripe not configured (normal for free product)
  /api/v1/billing/stripe/webhook:
    post:
      tags: [billing]
      summary: Stripe webhook (dormant)
      responses:
        "501":
          description: Billing not configured
        "400":
          description: Invalid signature
        "200":
          description: Event accepted
  /api/v1/mail/resend/webhook:
    post:
      tags: [mail]
      summary: Resend (Svix) delivery webhook
      description: |
        Present only when RESEND_WEBHOOK_SECRET is set. Verifies the raw body
        with Svix's official scheme and five-minute tolerance, then stores only
        keyed message/event digests, template class, coarse state, and timestamps
        for 60 days. Recipient, subject, content, links, headers, provider payload,
        and provider identifiers are never stored. Unknown event types are ignored.
      responses:
        "400":
          description: Invalid signature or payload
        "204":
          description: Event accepted, replayed, out of order, or deliberately ignored
        "413":
          description: Payload exceeds 64 KiB
        "415":
          description: Content-Type is not application/json
  /api/v1/me/usage:
    get:
      tags: [auth]
      summary: Account activity and authoritative quota usage
      description: |
        Returns 30-day activity plus the transactionally maintained active
        paste count and unique retained-object storage usage and limits.
      security:
        - session: []
        - apiKey: []
      responses:
        "200":
          description: Usage
  /api/v1/collections:
    get:
      tags: [collections]
      summary: List my collections
      security:
        - session: []
        - apiKey: []
      responses:
        "200":
          description: Collections
    post:
      tags: [collections]
      summary: Create collection
      security:
        - session: []
        - apiKey: []
      responses:
        "201":
          description: Created
        "403":
          description: Collections unavailable
  /api/v1/api-keys:
    get:
      tags: [api-keys]
      summary: List API keys
      security:
        - session: []
      responses:
        "200":
          description: Keys (secrets never returned)
    post:
      tags: [api-keys]
      summary: Create API key
      description: |
        Secret returned once (`vp_live_...`). Optional `scopes` array
        (defaults `pastes:read`, `pastes:write`) is enforced on API-key
        requests: `pastes:read` for reads, `pastes:write` for creates/updates/
        deletes. `*` grants all. API key management requires a session cookie
        (Bearer API keys are rejected on these routes).
      security:
        - session: []
      responses:
        "201":
          description: Key created (secret shown once)
  /api/v1/me/favorites:
    get:
      tags: [pastes]
      summary: List favorites
      security:
        - session: []
        - apiKey: []
      responses:
        "200":
          description: Favorites
  /api/v1/moderation/reports:
    get:
      tags: [moderation]
      summary: List and filter abuse reports (moderator+)
      security:
        - session: []
      responses:
        "200":
          description: Reports
  /api/v1/moderation/reports/{id}/resolve:
    post:
      tags: [moderation]
      summary: Assign or transition a report with a mandatory reason
      security:
        - session: []
      responses:
        "200":
          description: Updated
  /api/v1/moderation/pastes/{id}/delete:
    post:
      tags: [moderation]
      summary: Soft-delete a paste with a mandatory reason (moderator+)
      security:
        - session: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "200":
          description: Deleted
  /api/v1/pastes/{id}/quarantine:
    post:
      tags: [moderation]
      summary: Quarantine a paste with a mandatory reason (moderator+)
      security:
        - session: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "200":
          description: Quarantined
  /api/v1/pastes/{id}/unquarantine:
    post:
      tags: [moderation]
      summary: Lift quarantine with a mandatory reason (moderator+)
      security:
        - session: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "200":
          description: Restored
  /api/v1/admin/overview:
    get:
      tags: [admin]
      summary: Live counts (users, pastes, open reports, recent signups)
      security:
        - session: []
      responses:
        "200":
          description: Counts from the database
        "403":
          description: Not admin
  /api/v1/admin/users:
    get:
      tags: [admin]
      summary: Search users (no password hashes)
      security:
        - session: []
      responses:
        "200":
          description: User rows
  /api/v1/admin/users/{id}/role:
    post:
      tags: [admin]
      summary: Change a user's role
      description: Cannot change your own role. Only an owner can grant or alter owner. Refuses to remove the last active admin.
      security:
        - session: []
      responses:
        "200":
          description: Updated
        "403":
          description: Forbidden
        "409":
          description: Would remove the last admin
  /api/v1/admin/users/{id}/disable:
    post:
      tags: [admin]
      summary: Disable a user and revoke sessions
      security:
        - session: []
      responses:
        "200":
          description: Disabled
  /api/v1/admin/users/{id}/enable:
    post:
      tags: [admin]
      summary: Re-enable a disabled user
      security:
        - session: []
      responses:
        "200":
          description: Enabled
  /api/v1/admin/pastes:
    get:
      tags: [admin]
      summary: Search paste metadata
      description: Does not return content keys, ciphertext, or password hashes.
      security:
        - session: []
      responses:
        "200":
          description: Paste metadata
  /api/v1/admin/pastes/{id}/delete:
    post:
      tags: [admin]
      summary: Soft-delete a paste
      security:
        - session: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "200":
          description: Deleted
  /api/v1/admin/rate-limits:
    get:
      tags: [admin]
      summary: Rate-limit configuration and live Redis windows
      description: Denied requests are not persisted. Anonymous subjects are hashed.
      security:
        - session: []
      responses:
        "200":
          description: Limits and current windows
  /api/v1/admin/system:
    get:
      tags: [admin]
      summary: Health checks, mailer backend name, worker config
      description: Mailer name only — never the API key. Includes the live worker heartbeat.
      security:
        - session: []
      responses:
        "200":
          description: System snapshot
  /api/v1/admin/alerts:
    get:
      tags: [admin]
      summary: Active and recently resolved operational alerts
      description: Content-free bounded rule state and evaluator heartbeat.
      security:
        - session: []
      responses:
        "200":
          description: Operational alerts
  /api/v1/admin/alerts/{id}/acknowledge:
    post:
      tags: [admin]
      summary: Acknowledge an operational alert
      security:
        - session: []
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string, format: uuid}
      responses:
        "200":
          description: Alert acknowledged
  /api/v1/admin/alerts/{id}/resolve:
    post:
      tags: [admin]
      summary: Resolve an operational alert
      security:
        - session: []
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string, format: uuid}
      responses:
        "200":
          description: Alert resolved
  /api/v1/admin/erasure-jobs/{id}/retry:
    post:
      tags: [admin]
      summary: Audited retry of a terminal failed erasure job
      description: |
        Requeues only a failed job that still has its internal user reference.
        This operation never restores account data. Admin system telemetry
        exposes aggregate erasure counts only.
      security:
        - session: []
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string, format: uuid}
      responses:
        "202":
          description: Requeued
        "409":
          description: Job is not retryable
  /api/v1/admin/audit:
    get:
      tags: [admin]
      summary: Audit log (login, paste, and admin actions)
      security:
        - session: []
      responses:
        "200":
          description: Audit entries
  /api/v1/pastes/{id}/raw:
    get:
      tags: [pastes]
      summary: Raw paste body under the API prefix
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PastePassword"
      responses:
        "200":
          description: text/plain with nosniff, DENY framing, and sandbox CSP
          content:
            text/plain:
              schema:
                type: string
        "400":
          description: Invalid paste id
        "404":
          $ref: "#/components/responses/Error"
  /api/v1/pastes/{id}/download:
    get:
      tags: [pastes]
      summary: Download paste as attachment under the API prefix
      parameters:
        - $ref: "#/components/parameters/PasteID"
        - $ref: "#/components/parameters/PastePassword"
      responses:
        "200":
          description: text/plain attachment
        "400":
          description: Invalid paste id
        "404":
          $ref: "#/components/responses/Error"
  /api/v1/auth/verify-email:
    post:
      tags: [auth]
      summary: Confirm email verification token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [token]
              properties:
                token:
                  type: string
      responses:
        "200":
          description: Verified
  /api/v1/auth/resend-verification:
    post:
      tags: [auth]
      summary: Resend email verification link
      description: |
        Always returns a success-shaped response for unknown or already-verified
        emails (no account enumeration). Unverified accounts get a new token and
        branded email. Cooldown is 60s per email and per IP (429 + Retry-After).
        Anonymous callers send `{ "email": "..." }`. Cookie sessions use the
        signed-in account (CSRF required) and may omit the body.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
      responses:
        "200":
          description: Accepted (opaque success)
        "400":
          description: Email required when not signed in
        "429":
          description: Resend cooldown; Retry-After set
  /api/v1/auth/logout-all:
    post:
      tags: [auth]
      summary: Revoke every session for the current user
      security:
        - session: []
      responses:
        "200":
          description: Logged out
  /api/v1/auth/account-erasure:
    post:
      tags: [auth]
      summary: Revoke credentials and queue deletion of the current account graph
      description: |
        Cookie session only (API keys rejected). Requires normal CSRF protection,
        rate limiting, a session created within the last 15 minutes, and JSON
        confirmation exactly `DELETE MY ACCOUNT`. Sessions, API keys, and email
        tokens are revoked/deleted before the 202 response. Owned public pastes
        and versions are deleted rather than orphaned. The status token is
        returned once and must not be placed in a URL.
      security:
        - session: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [confirmation]
              properties:
                confirmation:
                  type: string
                  enum: [DELETE MY ACCOUNT]
      responses:
        "202":
          description: Credentials revoked and erasure queued
        "400":
          description: Confirmation missing
        "403":
          description: Recent authentication required
        "409":
          description: Erasure already active or privileged-duty transfer required
        "429":
          $ref: "#/components/responses/Error"
  /api/v1/auth/account-erasure/status:
    post:
      tags: [auth]
      summary: Read aggregate erasure progress using an opaque status token
      description: |
        Accepts the token in a JSON body so it does not enter URL/access logs.
        Unknown and malformed tokens return the same 404 response. Status rows
        expire 30 days after completion or terminal failure.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [status_token]
              properties:
                status_token:
                  type: string
                  writeOnly: true
      responses:
        "200":
          description: pending, processing, retry, completed, or failed
        "404":
          $ref: "#/components/responses/Error"
        "429":
          $ref: "#/components/responses/Error"
  /api/v1/auth/password-reset/request:
    post:
      tags: [auth]
      summary: Request a password reset email
      description: Always returns success-shaped response (no account enumeration).
      responses:
        "200":
          description: Accepted
  /api/v1/auth/password-reset/confirm:
    post:
      tags: [auth]
      summary: Set a new password with a reset token
      responses:
        "200":
          description: Password updated
  /api/v1/me/favorites/{id}:
    post:
      tags: [pastes]
      summary: Favorite a paste
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "201":
          description: Favorited
    delete:
      tags: [pastes]
      summary: Remove a favorite
      security:
        - session: []
        - apiKey: []
      parameters:
        - $ref: "#/components/parameters/PasteID"
      responses:
        "204":
          description: Removed
  /api/v1/api-keys/{id}:
    delete:
      tags: [api-keys]
      summary: Revoke an API key
      security:
        - session: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "204":
          description: Revoked
  /api/v1/collections/{id}:
    get:
      tags: [collections]
      summary: Get a collection
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Collection
    patch:
      tags: [collections]
      summary: Update a collection (owner)
      security:
        - session: []
        - apiKey: []
      responses:
        "200":
          description: Updated
    delete:
      tags: [collections]
      summary: Delete a collection (owner)
      security:
        - session: []
        - apiKey: []
      responses:
        "204":
          description: Deleted
  /api/v1/collections/{id}/pastes:
    post:
      tags: [collections]
      summary: Add a paste to a collection
      security:
        - session: []
        - apiKey: []
      responses:
        "201":
          description: Added
  /api/v1/collections/{id}/pastes/{pasteId}:
    delete:
      tags: [collections]
      summary: Remove a paste from a collection
      security:
        - session: []
        - apiKey: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: pasteId
          in: path
          required: true
          description: Public paste id (base62)
          schema:
            type: string
      responses:
        "204":
          description: Removed
        "404":
          description: Collection or paste not in collection
  /api/v1/reports:
    post:
      tags: [moderation]
      summary: Submit a structured paste report (public, rate limited)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [paste_id, category]
              properties:
                paste_id:
                  type: string
                category:
                  type: string
                  enum: [malware_phishing, credentials_secrets, harassment, illegal_content, copyright, spam, other]
                details:
                  type: string
                  maxLength: 500
      responses:
        "201":
          description: Report created
        "429":
          description: Report rate limit exceeded
components:
  securitySchemes:
    session:
      type: apiKey
      in: cookie
      name: vp_session
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: vp_live_
    managementToken:
      type: apiKey
      in: header
      name: X-Paste-Management-Token
  parameters:
    PasteID:
      name: id
      in: path
      required: true
      description: Public paste id (base62), not a database UUID
      schema:
        type: string
    PastePassword:
      name: X-Paste-Password
      in: header
      required: false
      schema:
        type: string
    PasteManagementToken:
      name: X-Paste-Management-Token
      in: header
      required: false
      description: One-time anonymous capability returned only by create; never put it in a URL.
      schema:
        type: string
  schemas:
    PasteCreate:
      type: object
      required: [content]
      properties:
        title:
          type: string
        content:
          type: string
          description: |
            UTF-8 body. When client_encrypted=true this must be canonical
            unpadded base64url AES-256-GCM output including the authentication tag.
        language:
          type: string
        visibility:
          type: string
          enum: [public, unlisted, private, password]
          default: unlisted
          description: |
            private requires auth. password requires a non-empty password field.
            Sending password with any other visibility returns 400.
        password:
          type: string
          description: Required when visibility=password
        expiration:
          type: string
          description: |
            Presets: never, 10m, 1h, 1d, 1w, 1M (~30 days, capital M).
            Also accepts relative durations (e.g. 2d, 90m) and RFC3339 timestamps.
            Lowercase 1m is one minute; do not confuse with 1M.
        burn_after_reading:
          type: boolean
        max_views:
          type: integer
          nullable: true
        no_index:
          type: boolean
        client_encrypted:
          type: boolean
          description: |
            Requests setting this flag must use the versioned official envelope
            described by encryption_meta. The server validates the envelope shape
            but cannot prove the semantic plaintext or custody of the key.
        encryption_meta:
          type: object
          additionalProperties: false
          required: [v, alg, iv]
          properties:
            v:
              type: integer
              enum: [1]
            alg:
              type: string
              enum: [AES-256-GCM]
            iv:
              type: string
              description: Canonical unpadded base64url encoding of exactly 12 bytes.
            kdf:
              type: string
              enum: [PBKDF2-SHA256]
            iter:
              type: integer
              enum: [310000]
            salt:
              type: string
              description: Required with kdf; canonical unpadded base64url encoding of exactly 16 bytes.
    Paste:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
          nullable: true
        language:
          type: string
        visibility:
          type: string
        content:
          type: string
          description: Present when the caller is authorized to read the body
        size_bytes:
          type: integer
        burn_after_reading:
          type: boolean
        max_views:
          type: integer
          nullable: true
        view_count:
          type: integer
        no_index:
          type: boolean
        client_encrypted:
          type: boolean
        encryption_meta:
          type: object
          additionalProperties: true
        content_sha256:
          type: string
        expires_at:
          type: string
          format: date-time
          nullable: true
        burned_at:
          type: string
          format: date-time
          nullable: true
        quarantined_at:
          type: string
          format: date-time
          nullable: true
        owner_id:
          type: string
          format: uuid
        raw_url:
          type: string
          example: /raw/{id}
        download_url:
          type: string
          example: /download/{id}
        api_url:
          type: string
          example: /api/v1/pastes/{id}
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    PasteCreateEnvelope:
      type: object
      properties:
        paste:
          $ref: "#/components/schemas/Paste"
        warnings:
          type: array
          items:
            type: object
            properties:
              severity:
                type: string
              kind:
                type: string
              message:
                type: string
        management_token:
          type: string
          writeOnly: true
          description: |
            Returned exactly once for anonymous creates. Store privately and
            send only in X-Paste-Management-Token. Omitted for authenticated creates
            and idempotency replays.
    PasteGetEnvelope:
      type: object
      properties:
        paste:
          $ref: "#/components/schemas/Paste"
        burned:
          type: boolean
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: |
                Examples: unauthorized, forbidden, not_found, validation_error,
                rate_limited, expired, burned, password_required, bad_password,
                secret_blocked, malware_blocked, too_large, limit_exceeded,
                quota_exceeded
            message:
              type: string
            request_id:
              type: string
  responses:
    Error:
      description: Error envelope
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
