{
  "openapi": "3.1.0",
  "info": {
    "title": "Pinin API",
    "version": "2026-11-26",
    "summary": "AI photo restoration for applications.",
    "description": "Queue photo restorations, follow them to completion, and receive the result by webhook or by polling.\n\n**Authentication** — `Authorization: Bearer pnn_live_…`. A key carries scopes; each endpoint lists the scope it needs under `x-pinin-scope`.\n\n**Versioning** — every response carries `X-Pinin-Api-Version`. Pin a version with the `X-Pinin-Api-Version` request header; a version we no longer serve answers `400 unsupported_version` with the list of supported ones.\n\n**Errors** — branch on `error.code`, never on the message text. Every response carries `X-Request-Id`.\n\n**Rate limits** — `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`; a limited request answers `429` with `Retry-After`.\n\n**Retention** — restored files are kept for 30 days after submission. `expires_at` on each job is the exact deletion time; an expired job answers `410 restoration_expired`.",
    "contact": {
      "name": "Pinin support",
      "url": "https://pinin.ai/developers",
      "email": "support@pinin.ai"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://pinin.ai/terms"
    }
  },
  "servers": [
    {
      "url": "https://pinin.ai/api/v1",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Health",
      "description": "Liveness, version and dependency status. No key required."
    },
    {
      "name": "Restorations",
      "description": "Submit photos, follow jobs to completion, download the result."
    },
    {
      "name": "Account",
      "description": "The account behind the key: plan, credits and effective limits."
    },
    {
      "name": "Usage",
      "description": "Requests, errors, restorations and credits, by day and by key."
    },
    {
      "name": "Modes",
      "description": "The restoration modes this plan can request."
    },
    {
      "name": "Keys",
      "description": "Create, rotate, edit and revoke API keys."
    },
    {
      "name": "Webhooks",
      "description": "Endpoints that receive `restoration.completed` and `restoration.failed`."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "health",
        "summary": "Health check",
        "description": "Reports whether the API and its database can serve requests. No key is required, so a load balancer or an uptime monitor can call it.\n\n- `status` is `ok` when every check passed and `degraded` otherwise; a degraded answer is HTTP `503` so a monitor can alert on the status code alone.\n\n- `retention_days` is the same number `expires_at` is computed from, so a client never has to hard-code it.",
        "tags": [
          "Health"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    },
                    "time": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "retention_days": {
                      "type": "integer"
                    },
                    "checks": {
                      "type": "object",
                      "properties": {
                        "database": {
                          "type": "object",
                          "properties": {
                            "ok": {
                              "type": "boolean"
                            },
                            "latency_ms": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "ok",
                            "latency_ms"
                          ]
                        }
                      },
                      "required": [
                        "database"
                      ]
                    }
                  },
                  "required": [
                    "status",
                    "version",
                    "time",
                    "retention_days",
                    "checks"
                  ]
                },
                "example": {
                  "status": "ok",
                  "version": "2026-11-26",
                  "time": "2026-11-26T20:10:16.188Z",
                  "retention_days": 30,
                  "checks": {
                    "database": {
                      "ok": true,
                      "latency_ms": 12
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/restorations": {
      "post": {
        "operationId": "create-restoration",
        "summary": "Create a restoration",
        "description": "Queue one image or a batch for restoration. Every image costs one credit and is charged when the job settles; a failed job is refunded automatically.\n\n- Two doors, both locked: an account needs an active Enterprise plan **and** a positive credit balance. Either one failing answers `403 api_requires_enterprise` or `402 insufficient_credits` before the request is read.\n\n- Multipart uploads are accepted: send the image in a `file` field with `mode` and `metadata` as form fields.\n\n- Reuse the same `Idempotency-Key` header (or `idempotency_key`) to retry a submit without paying twice. The key covers a whole batch, and a duplicate that arrives mid-flight answers `409 idempotency_in_progress`.\n\n- A batch reports every image: `data` holds what was queued, `failures` holds what was refused and why, and `batch` summarises the totals.\n\n- The response carries `Retry-After: 2`, so a poller knows how soon to ask again.",
        "tags": [
          "Restorations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "restorations:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "image_url": {
                    "type": "string",
                    "description": "Public https URL of the image to restore."
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object"
                        }
                      ]
                    },
                    "description": "Up to 100 images per request, as URLs or objects with `image_url`. Your plan's batch cap applies across requests."
                  },
                  "image_base64": {
                    "type": "string",
                    "description": "Inline image as base64 or a data URL (single image)."
                  },
                  "mime_type": {
                    "type": "string",
                    "description": "Content type when you send `image_base64`, for example `image/jpeg`."
                  },
                  "mode": {
                    "type": "string",
                    "description": "One of the five modes. Defaults to `all-in-one`."
                  },
                  "seed": {
                    "type": "integer",
                    "description": "Deterministic output: the same seed and image give the same result."
                  },
                  "idempotency_key": {
                    "type": "string",
                    "description": "Repeat-safe submit for one image or a batch. A repeat returns the jobs the first call created."
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Your own JSON object, up to 2 KB. Returned on the job and echoed in webhook payloads."
                  },
                  "dry_run": {
                    "type": "boolean",
                    "description": "Validate and price the request without spending credits."
                  }
                },
                "required": []
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "image_url": {
                    "type": "string",
                    "description": "Public https URL of the image to restore."
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object"
                        }
                      ]
                    },
                    "description": "Up to 100 images per request, as URLs or objects with `image_url`. Your plan's batch cap applies across requests."
                  },
                  "image_base64": {
                    "type": "string",
                    "description": "Inline image as base64 or a data URL (single image)."
                  },
                  "mime_type": {
                    "type": "string",
                    "description": "Content type when you send `image_base64`, for example `image/jpeg`."
                  },
                  "mode": {
                    "type": "string",
                    "description": "One of the five modes. Defaults to `all-in-one`."
                  },
                  "seed": {
                    "type": "integer",
                    "description": "Deterministic output: the same seed and image give the same result."
                  },
                  "idempotency_key": {
                    "type": "string",
                    "description": "Repeat-safe submit for one image or a batch. A repeat returns the jobs the first call created."
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Your own JSON object, up to 2 KB. Returned on the job and echoed in webhook payloads."
                  },
                  "dry_run": {
                    "type": "boolean",
                    "description": "Validate and price the request without spending credits."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "images": {
                      "type": "object",
                      "properties": {
                        "original": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            },
                            "expires_in": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "url",
                            "expires_in"
                          ]
                        },
                        "restored": {
                          "type": [
                            "object",
                            "array",
                            "string",
                            "number",
                            "boolean",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "original",
                        "restored"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "status",
                    "mode",
                    "credits",
                    "images"
                  ]
                },
                "example": {
                  "object": "restoration",
                  "id": "0b04150b-f216-4284-b77a-be1b1e0c373e",
                  "status": "pending",
                  "mode": "all-in-one",
                  "credits": 0,
                  "images": {
                    "original": {
                      "url": "https://images.pinin.ai/...",
                      "expires_in": 3600
                    },
                    "restored": null
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "images": {
                      "type": "object",
                      "properties": {
                        "original": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            },
                            "expires_in": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "url",
                            "expires_in"
                          ]
                        },
                        "restored": {
                          "type": [
                            "object",
                            "array",
                            "string",
                            "number",
                            "boolean",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "original",
                        "restored"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "status",
                    "mode",
                    "credits",
                    "images"
                  ]
                },
                "example": {
                  "object": "restoration",
                  "id": "0b04150b-f216-4284-b77a-be1b1e0c373e",
                  "status": "pending",
                  "mode": "all-in-one",
                  "credits": 0,
                  "images": {
                    "original": {
                      "url": "https://images.pinin.ai/...",
                      "expires_in": 3600
                    },
                    "restored": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "get": {
        "operationId": "list-restorations",
        "summary": "List restorations",
        "description": "Newest first, cursor paginated. `next_cursor` is the `created_at` value to pass back as `created_before`.",
        "tags": [
          "Restorations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "restorations:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1–100. Default 20.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "`pending`, `processing`, `completed` or `failed`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_before",
            "in": "query",
            "required": false,
            "description": "Cursor from the previous page (`next_cursor`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_before_id",
            "in": "query",
            "required": false,
            "description": "Tiebreaker for the cursor (`next_cursor_id`), so a shared millisecond cannot skip a job.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "description": "Only jobs run in this mode.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "description": "Only jobs touched at or after this instant. This is the sweep a polling client runs to reconcile what it missed.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "object",
                          "id"
                        ]
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "object",
                        "array",
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    },
                    "next_cursor_id": {
                      "type": [
                        "object",
                        "array",
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor",
                    "next_cursor_id"
                  ]
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "restoration",
                      "id": "..."
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null,
                  "next_cursor_id": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/restorations/{id}": {
      "get": {
        "operationId": "get-restoration",
        "summary": "Retrieve a restoration",
        "description": "Read one job. Poll this while `status` is `pending` or `processing`, or listen for the webhook instead of polling.\n\n- Signed image URLs are valid for at least an hour. Re-fetch the job for a fresh link.\n\n- Images are retained for 30 days from submission; `expires_at` says exactly when this job's files are deleted, and an expired job answers `410 restoration_expired`.\n\n- A job that is still `pending` answers in milliseconds. Poll no faster than `Retry-After` suggests.\n\n- The response carries a weak `ETag`. Send it back as `If-None-Match` while polling: an unchanged job answers `304` with no body, so a tight poll loop costs nothing.",
        "tags": [
          "Restorations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "restorations:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "metadata": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "order_id"
                      ]
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "completed_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "images": {
                      "type": "object",
                      "properties": {
                        "original": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            },
                            "expires_in": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "url",
                            "expires_in"
                          ]
                        },
                        "restored": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            },
                            "expires_in": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "url",
                            "expires_in"
                          ]
                        }
                      },
                      "required": [
                        "original",
                        "restored"
                      ]
                    },
                    "share_url": {
                      "type": [
                        "object",
                        "array",
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "status",
                    "mode",
                    "credits",
                    "metadata",
                    "expires_at",
                    "completed_at",
                    "images",
                    "share_url"
                  ]
                },
                "example": {
                  "object": "restoration",
                  "id": "0b04150b-f216-4284-b77a-be1b1e0c373e",
                  "status": "completed",
                  "mode": "all-in-one",
                  "credits": 1,
                  "metadata": {
                    "order_id": "A-10231"
                  },
                  "expires_at": "2027-02-24T20:10:16.188Z",
                  "completed_at": "2026-11-26T20:10:16.188Z",
                  "images": {
                    "original": {
                      "url": "https://images.pinin.ai/...",
                      "expires_in": 3600
                    },
                    "restored": {
                      "url": "https://images.pinin.ai/...",
                      "expires_in": 3600
                    }
                  },
                  "share_url": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/restorations/{id}/download": {
      "get": {
        "operationId": "download",
        "summary": "Download the image",
        "description": "Redirects to a short-lived signed URL. Pass `?image=original` for the source file.",
        "tags": [
          "Restorations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "restorations:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          },
          {
            "name": "image",
            "in": "query",
            "required": false,
            "description": "`restored` (default) or `original`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "HTTP/1.1 302 Found\nLocation: https://images.pinin.ai/<key>?exp=<unix>&sig=<hmac>"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/restorations/{id}/cancel": {
      "post": {
        "operationId": "cancel-restoration",
        "summary": "Cancel a restoration",
        "description": "Cancels a job that has not started. A queued job has not been charged, so cancelling costs nothing; once the pipeline has picked it up the job cannot be stopped.\n\n- Only `pending` jobs can be cancelled. `409 too_late_to_cancel` means a credit is already spent on the work.\n\n- Cancelling emits `restoration.failed` with `error_code: cancelled`, so a webhook receiver learns about it without polling.",
        "tags": [
          "Restorations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "restorations:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "status",
                    "error"
                  ]
                },
                "example": {
                  "object": "restoration",
                  "id": "0b04150b-f216-4284-b77a-be1b1e0c373e",
                  "status": "failed",
                  "error": {
                    "code": "cancelled",
                    "message": "Cancelled by the customer."
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "status",
                    "error"
                  ]
                },
                "example": {
                  "object": "restoration",
                  "id": "0b04150b-f216-4284-b77a-be1b1e0c373e",
                  "status": "failed",
                  "error": {
                    "code": "cancelled",
                    "message": "Cancelled by the customer."
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/account": {
      "get": {
        "operationId": "account",
        "summary": "Account and limits",
        "description": "Plan, credit balance, batch cap, concurrency and the limits of the calling key. Stays readable when the balance is empty, so a blocked account can see why it is blocked.",
        "tags": [
          "Account"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "usage:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "plan": {
                      "type": "object",
                      "properties": {
                        "tier": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "credits": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "tier",
                        "status",
                        "credits"
                      ]
                    },
                    "limits": {
                      "type": "object",
                      "properties": {
                        "batch_cap": {
                          "type": "integer"
                        },
                        "concurrency": {
                          "type": "integer"
                        },
                        "requests_per_minute": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "batch_cap",
                        "concurrency",
                        "requests_per_minute"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "plan",
                    "limits"
                  ]
                },
                "example": {
                  "object": "account",
                  "plan": {
                    "tier": "enterprise",
                    "status": "active",
                    "credits": 998
                  },
                  "limits": {
                    "batch_cap": 500,
                    "concurrency": 24,
                    "requests_per_minute": 120
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "operationId": "usage",
        "summary": "Usage analytics",
        "description": "Requests, errors, restorations and credits per day, plus the current month by key. Pass `?days=` (1–90, default 30) to choose the window.",
        "tags": [
          "Usage"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "usage:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "totals": {
                      "type": "object",
                      "properties": {
                        "requests": {
                          "type": "integer"
                        },
                        "errors": {
                          "type": "integer"
                        },
                        "restorations": {
                          "type": "integer"
                        },
                        "credits": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "requests",
                        "errors",
                        "restorations",
                        "credits"
                      ]
                    },
                    "monthly": {
                      "type": "object",
                      "properties": {
                        "period": {
                          "type": "string"
                        },
                        "credits_used": {
                          "type": "integer"
                        },
                        "restorations": {
                          "type": "integer"
                        },
                        "credits_balance": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "period",
                        "credits_used",
                        "restorations",
                        "credits_balance"
                      ]
                    },
                    "by_key": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "credits_this_month": {
                            "type": "integer"
                          },
                          "restorations_this_month": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "credits_this_month",
                          "restorations_this_month"
                        ]
                      }
                    },
                    "daily": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "day": {
                            "type": "string"
                          },
                          "requests": {
                            "type": "integer"
                          },
                          "restorations": {
                            "type": "integer"
                          },
                          "credits": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "day",
                          "requests",
                          "restorations",
                          "credits"
                        ]
                      }
                    }
                  },
                  "required": [
                    "object",
                    "totals",
                    "monthly",
                    "by_key",
                    "daily"
                  ]
                },
                "example": {
                  "object": "usage",
                  "totals": {
                    "requests": 412,
                    "errors": 3,
                    "restorations": 120,
                    "credits": 120
                  },
                  "monthly": {
                    "period": "2026-11",
                    "credits_used": 120,
                    "restorations": 120,
                    "credits_balance": 880
                  },
                  "by_key": [
                    {
                      "id": "...",
                      "name": "Production",
                      "credits_this_month": 120,
                      "restorations_this_month": 120
                    }
                  ],
                  "daily": [
                    {
                      "day": "2026-11-26",
                      "requests": 12,
                      "restorations": 4,
                      "credits": 4
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/modes": {
      "get": {
        "operationId": "modes",
        "summary": "Available modes",
        "description": "The restoration modes this account can request, with a description of each.",
        "tags": [
          "Modes"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "restorations:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Mode"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "data"
                  ]
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": "colorize",
                      "name": "Colorization",
                      "credits": 1
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/keys": {
      "get": {
        "operationId": "list-keys",
        "summary": "List API keys",
        "description": "Every key on the account with its scopes, limits, last use and this month's spend. Secrets are never included.",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "keys:manage",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "key_prefix": {
                            "type": "string"
                          },
                          "credits_this_month": {
                            "type": "integer"
                          },
                          "restorations_this_month": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "object",
                          "id",
                          "key_prefix",
                          "credits_this_month",
                          "restorations_this_month"
                        ]
                      }
                    }
                  },
                  "required": [
                    "object",
                    "data"
                  ]
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "api_key",
                      "id": "...",
                      "key_prefix": "pnn_live_e5020b1…",
                      "credits_this_month": 120,
                      "restorations_this_month": 120
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "create-key",
        "summary": "Create an API key",
        "description": "Mints a key. The plaintext is returned once and never again — store it immediately.",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "keys:manage",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "A label you will recognise later."
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Scope"
                    },
                    "description": "Defaults to read + write on restorations."
                  },
                  "rate_limit_per_minute": {
                    "type": "integer",
                    "description": "1–300. Default 60. Calls above this are refused, not clamped."
                  },
                  "monthly_credit_cap": {
                    "type": "integer",
                    "description": "Hard ceiling on credits this key may spend per month."
                  },
                  "expires_in_days": {
                    "type": "integer",
                    "description": "Optional expiry, up to 730 days."
                  }
                },
                "required": [
                  "name"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "A label you will recognise later."
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Defaults to read + write on restorations."
                  },
                  "rate_limit_per_minute": {
                    "type": "integer",
                    "description": "1–300. Default 60. Calls above this are refused, not clamped."
                  },
                  "monthly_credit_cap": {
                    "type": "integer",
                    "description": "Hard ceiling on credits this key may spend per month."
                  },
                  "expires_in_days": {
                    "type": "integer",
                    "description": "Optional expiry, up to 730 days."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "key_prefix": {
                      "type": "string"
                    },
                    "api_key": {
                      "type": "string"
                    },
                    "warning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "key_prefix",
                    "api_key",
                    "warning"
                  ]
                },
                "example": {
                  "object": "api_key",
                  "id": "78b960cd-547d-4665-9cc7-8b015d6b1899",
                  "key_prefix": "pnn_live_e5020b1…",
                  "api_key": "pnn_live_...",
                  "warning": "Store this key now. It cannot be shown again."
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "key_prefix": {
                      "type": "string"
                    },
                    "api_key": {
                      "type": "string"
                    },
                    "warning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "key_prefix",
                    "api_key",
                    "warning"
                  ]
                },
                "example": {
                  "object": "api_key",
                  "id": "78b960cd-547d-4665-9cc7-8b015d6b1899",
                  "key_prefix": "pnn_live_e5020b1…",
                  "api_key": "pnn_live_...",
                  "warning": "Store this key now. It cannot be shown again."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/keys/{id}": {
      "get": {
        "operationId": "get-key",
        "summary": "Retrieve an API key",
        "description": "One key, including whether it is revoked and what it has spent this month.",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "keys:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "revoked_at": {
                      "type": [
                        "object",
                        "array",
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "scopes",
                    "revoked_at"
                  ]
                },
                "example": {
                  "object": "api_key",
                  "id": "...",
                  "scopes": [
                    "restorations:read"
                  ],
                  "revoked_at": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "patch": {
        "operationId": "update-key",
        "summary": "Update an API key",
        "description": "Change a key's label, scopes, expiry, per-minute limit or monthly credit cap. Narrowing scopes takes effect on the next request, so this is the way to cut a key's power during an incident without re-issuing its secret.",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "keys:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "New label."
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The scopes the key may use. Must be a non-empty subset of the published list."
                  },
                  "expires_in_days": {
                    "type": "string",
                    "description": "Days from now until the key stops working (max 730), or `null` to remove the expiry."
                  },
                  "rate_limit_per_minute": {
                    "type": "integer",
                    "description": "1–300 requests per minute for this key."
                  },
                  "monthly_credit_cap": {
                    "type": "string",
                    "description": "New ceiling, or `null` to remove it."
                  }
                },
                "required": []
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "New label."
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The scopes the key may use. Must be a non-empty subset of the published list."
                  },
                  "expires_in_days": {
                    "type": "string",
                    "description": "Days from now until the key stops working (max 730), or `null` to remove the expiry."
                  },
                  "rate_limit_per_minute": {
                    "type": "integer",
                    "description": "1–300 requests per minute for this key."
                  },
                  "monthly_credit_cap": {
                    "type": "string",
                    "description": "New ceiling, or `null` to remove it."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "rate_limit_per_minute": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "rate_limit_per_minute"
                  ]
                },
                "example": {
                  "object": "api_key",
                  "id": "...",
                  "rate_limit_per_minute": 240
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "revoke-key",
        "summary": "Revoke an API key",
        "description": "Revokes a key immediately. Requests that use it start failing with `401 revoked_api_key`.",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "keys:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "revoked": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "revoked"
                  ]
                },
                "example": {
                  "object": "api_key",
                  "id": "...",
                  "revoked": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/keys/{id}/rotate": {
      "post": {
        "operationId": "rotate-key",
        "summary": "Rotate an API key",
        "description": "Revokes the key and mints a replacement with the same scopes and limits.",
        "tags": [
          "Keys"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "keys:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "api_key": {
                      "type": "string"
                    },
                    "replaced_key_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "api_key",
                    "replaced_key_id"
                  ]
                },
                "example": {
                  "object": "api_key",
                  "id": "...",
                  "api_key": "pnn_live_...",
                  "replaced_key_id": "..."
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "api_key": {
                      "type": "string"
                    },
                    "replaced_key_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "api_key",
                    "replaced_key_id"
                  ]
                },
                "example": {
                  "object": "api_key",
                  "id": "...",
                  "api_key": "pnn_live_...",
                  "replaced_key_id": "..."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "list-webhooks",
        "summary": "List webhook endpoints",
        "description": "Every endpoint on the account, with its events, active state and recent failure count.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "failure_count": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "object",
                          "id",
                          "url",
                          "active",
                          "failure_count"
                        ]
                      }
                    }
                  },
                  "required": [
                    "object",
                    "data"
                  ]
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "object": "webhook_endpoint",
                      "id": "...",
                      "url": "https://example.com/hook",
                      "active": true,
                      "failure_count": 0
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "webhooks",
        "summary": "Create a webhook endpoint",
        "description": "Registers an https endpoint for `restoration.completed` and `restoration.failed`. Deliveries are signed and retried with exponential backoff for six attempts.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Your https endpoint."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/WebhookEvent"
                    },
                    "description": "Subset of the two event types. Defaults to both."
                  },
                  "description": {
                    "type": "string",
                    "description": "Optional label."
                  }
                },
                "required": [
                  "url"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "Your https endpoint."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Subset of the two event types. Defaults to both."
                  },
                  "description": {
                    "type": "string",
                    "description": "Optional label."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "signing_secret": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "signing_secret",
                    "events"
                  ]
                },
                "example": {
                  "object": "webhook_endpoint",
                  "id": "de9cd18e-e73e-4d14-90c6-0f50a3493259",
                  "signing_secret": "whsec_...",
                  "events": [
                    "restoration.completed",
                    "restoration.failed"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "signing_secret": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "signing_secret",
                    "events"
                  ]
                },
                "example": {
                  "object": "webhook_endpoint",
                  "id": "de9cd18e-e73e-4d14-90c6-0f50a3493259",
                  "signing_secret": "whsec_...",
                  "events": [
                    "restoration.completed",
                    "restoration.failed"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}": {
      "patch": {
        "operationId": "update-webhook",
        "summary": "Update a webhook endpoint",
        "description": "Change the URL, the subscribed events or the description, or pause delivery with `active: false`.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "New https endpoint."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Non-empty subset of the event types."
                  },
                  "active": {
                    "type": "boolean",
                    "description": "`false` pauses delivery without deleting the endpoint."
                  },
                  "description": {
                    "type": "string",
                    "description": "New label."
                  }
                },
                "required": []
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "New https endpoint."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Non-empty subset of the event types."
                  },
                  "active": {
                    "type": "boolean",
                    "description": "`false` pauses delivery without deleting the endpoint."
                  },
                  "description": {
                    "type": "string",
                    "description": "New label."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "active": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "active"
                  ]
                },
                "example": {
                  "object": "webhook_endpoint",
                  "id": "...",
                  "active": false
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "delete-webhook",
        "summary": "Delete a webhook endpoint",
        "description": "Removes the endpoint and stops future deliveries. The delivery log is kept for your records.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "deleted": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "deleted"
                  ]
                },
                "example": {
                  "object": "webhook_endpoint",
                  "id": "...",
                  "deleted": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}/test": {
      "post": {
        "operationId": "test-webhook",
        "summary": "Send a test event",
        "description": "Delivers a signed `webhook.test` event right now and returns your endpoint's response.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "delivered": {
                      "type": "boolean"
                    },
                    "response_status": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "object",
                    "delivered",
                    "response_status"
                  ]
                },
                "example": {
                  "object": "webhook_test",
                  "delivered": true,
                  "response_status": 200
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "delivered": {
                      "type": "boolean"
                    },
                    "response_status": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "object",
                    "delivered",
                    "response_status"
                  ]
                },
                "example": {
                  "object": "webhook_test",
                  "delivered": true,
                  "response_status": 200
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}/rotate-secret": {
      "post": {
        "operationId": "rotate-secret",
        "summary": "Rotate a signing secret",
        "description": "Issues a new `whsec_` secret for the endpoint and retires the old one. Queued deliveries signed with the previous secret are failed rather than sent unverifiable.\n\n- Update your receiver before rotating: the old secret stops verifying immediately.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "signing_secret": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "signing_secret"
                  ]
                },
                "example": {
                  "object": "webhook_endpoint",
                  "id": "...",
                  "signing_secret": "whsec_..."
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "signing_secret": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "signing_secret"
                  ]
                },
                "example": {
                  "object": "webhook_endpoint",
                  "id": "...",
                  "signing_secret": "whsec_..."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}/deliveries": {
      "get": {
        "operationId": "deliveries",
        "summary": "Delivery log",
        "description": "Delivery attempts for an endpoint, newest first, with response codes and errors.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1–100. Default 20.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "Cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "event": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "response_status": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "event",
                          "status",
                          "response_status"
                        ]
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "object",
                        "array",
                        "string",
                        "number",
                        "boolean",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "event": "restoration.completed",
                      "status": "delivered",
                      "response_status": 200
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/webhooks/{id}/deliveries/{delivery_id}/redeliver": {
      "post": {
        "operationId": "redeliver",
        "summary": "Redeliver an event",
        "description": "Sends a stored delivery again, with the same signed payload and event id, and returns the response your endpoint gave this time.\n\n- A redelivery restarts the retry curve, so it can be retried six more times if it fails again.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-pinin-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The resource id."
          },
          {
            "name": "delivery_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The resource id."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "attempts": {
                      "type": "integer"
                    },
                    "response_status": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "status",
                    "attempts",
                    "response_status"
                  ]
                },
                "example": {
                  "object": "webhook_delivery",
                  "id": "...",
                  "status": "delivered",
                  "attempts": 1,
                  "response_status": 200
                }
              }
            }
          },
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "attempts": {
                      "type": "integer"
                    },
                    "response_status": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "status",
                    "attempts",
                    "response_status"
                  ]
                },
                "example": {
                  "object": "webhook_delivery",
                  "id": "...",
                  "status": "delivered",
                  "attempts": 1,
                  "response_status": 200
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key: `Authorization: Bearer pnn_live_…`."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "type",
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "invalid_request_error",
                  "authentication_error",
                  "permission_error",
                  "rate_limit_error",
                  "api_error"
                ]
              },
              "code": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/ErrorCode"
                  }
                ],
                "description": "A stable, documented code. Branch on this, never on the message."
              },
              "message": {
                "type": "string"
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "request_id": {
                "type": "string",
                "description": "Quote this in support requests; it joins the row in our logs."
              },
              "docs_url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "Mode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "all-in-one",
              "dust-scratch",
              "colorize",
              "deblur-upscale",
              "upscale-only"
            ]
          },
          "name": {
            "type": "string"
          },
          "credits": {
            "type": "integer"
          }
        }
      },
      "Scope": {
        "type": "string",
        "enum": [
          "restorations:read",
          "restorations:write",
          "usage:read",
          "webhooks:manage",
          "keys:manage"
        ],
        "description": "What a key is allowed to do."
      },
      "WebhookEvent": {
        "type": "string",
        "enum": [
          "restoration.completed",
          "restoration.failed"
        ]
      },
      "ErrorCode": {
        "type": "string",
        "enum": [
          "empty_file",
          "image_unreachable",
          "invalid_cursor",
          "invalid_expiry",
          "invalid_idempotency_key",
          "invalid_json",
          "invalid_metadata",
          "invalid_mode",
          "invalid_name",
          "invalid_rate_limit",
          "invalid_monthly_cap",
          "account_rate_limit_exceeded",
          "invalid_seed",
          "invalid_status",
          "invalid_url",
          "no_images",
          "nothing_to_update",
          "too_many_images",
          "unknown_event",
          "unknown_scope",
          "expired_api_key",
          "invalid_api_key",
          "missing_api_key",
          "revoked_api_key",
          "insufficient_credits",
          "monthly_key_cap_reached",
          "api_requires_enterprise",
          "insufficient_scope",
          "subscription_inactive",
          "delivery_not_found",
          "image_not_found",
          "key_not_found",
          "restoration_not_found",
          "unknown_route",
          "webhook_not_found",
          "already_completed",
          "already_failed",
          "delivery_in_flight",
          "idempotency_in_progress",
          "key_limit_reached",
          "not_ready",
          "too_late_to_cancel",
          "webhook_limit_reached",
          "restoration_expired",
          "file_too_large",
          "payload_too_large",
          "unsupported_media_type",
          "idempotency_key_reused",
          "batch_limit_reached",
          "rate_limit_exceeded",
          "internal_error",
          "fetch_failed",
          "queue_failed",
          "upload_failed",
          "rate_limiter_unavailable",
          "service_unavailable",
          "image_timeout"
        ],
        "description": "400 empty_file: The uploaded file was empty. | 400 image_unreachable: The URL could not be fetched, or does not point at an image. | 400 invalid_cursor: `created_before` / `before` is not an ISO timestamp. | 400 invalid_expiry: `expires_in_days` is not a positive number. | 400 invalid_idempotency_key: The Idempotency-Key is not 1–128 characters of printable ASCII. | 400 invalid_json: The request body is not valid JSON. | 400 invalid_metadata: `metadata` is not an object, has more than 20 keys, or is larger than 2 KB. | 400 invalid_mode: `mode` is not one of the five modes; `GET /modes` lists them. | 400 invalid_name: A name (key, webhook) is empty or longer than 60 characters. | 400 invalid_rate_limit: `rate_limit_per_minute` is outside 1–300. | 400 invalid_monthly_cap: `monthly_credit_cap` is outside 1–100000, and not null. | 429 account_rate_limit_exceeded: The account is at its 600 requests-per-minute ceiling across every key. | 400 invalid_seed: `seed` is not an integer. | 400 invalid_status: `status` is not pending, processing, completed or failed. | 400 invalid_url: The URL is not https, resolves to a private address, or was refused. | 400 no_images: The request carried no image. | 400 nothing_to_update: A PATCH carried no field it can change. | 400 too_many_images: More than 100 images in one request. | 400 unknown_event: An event name is not `restoration.completed` or `restoration.failed`. | 400 unknown_scope: A scope name is not in the published list. | 401 expired_api_key: The key passed its `expires_at`. | 401 invalid_api_key: The key is unknown, revoked or expired. | 401 missing_api_key: No `Authorization: Bearer` header was sent. | 401 revoked_api_key: The key was revoked. Create a new one. | 402 insufficient_credits: The balance cannot cover this request — or is zero, in which case the whole API is closed except `/account` and `/usage`. Top up to continue. | 402 monthly_key_cap_reached: This key hit its own monthly credit cap. | 403 api_requires_enterprise: The subscription is not an active Enterprise plan. | 403 insufficient_scope: The key does not hold the scope this route needs. | 403 subscription_inactive: The plan is not active, so the API is closed to it. | 404 delivery_not_found: No webhook delivery with that id. | 404 image_not_found: The image is no longer stored for that job. | 404 key_not_found: No API key with that id on this account. | 404 restoration_not_found: No restoration with that id on this account. | 404 unknown_route: No route matches that method and path. Check the version prefix. | 404 webhook_not_found: No webhook endpoint with that id. | 409 already_completed: The job already finished; there is nothing to cancel. | 409 already_failed: The job already failed; there is nothing to cancel. | 409 delivery_in_flight: That webhook delivery is being sent right now. | 409 idempotency_in_progress: A request with this Idempotency-Key is still running. Retry shortly. | 409 key_limit_reached: The account already holds the maximum number of keys. | 409 not_ready: The image is not finished yet; nothing to download. | 409 too_late_to_cancel: The job is already processing, so it cannot be cancelled. | 409 webhook_limit_reached: The account already holds the maximum number of endpoints. | 410 restoration_expired: The retention window passed and the files were deleted. Submit the image again. | 413 file_too_large: An image is larger than 20 MB. | 413 payload_too_large: The request body is larger than 64 MB. Split the batch or send URLs. | 415 unsupported_media_type: The file is not a JPEG, PNG, WebP, GIF, TIFF, BMP, HEIC or AVIF image. | 422 idempotency_key_reused: This Idempotency-Key was already used for a different request. Use a new key. | 429 batch_limit_reached: The plan's per-batch cap was reached. Wait for the queue to drain. | 429 rate_limit_exceeded: This key exceeded its requests-per-minute limit. | 500 internal_error: Our fault. Keep the request_id for support. | 502 fetch_failed: We could not fetch an image from the URL you sent. | 502 queue_failed: The job could not be queued. Safe to retry with the same Idempotency-Key. | 502 upload_failed: Storing your image failed. Safe to retry. | 503 rate_limiter_unavailable: The limiter is briefly unavailable; retry with backoff. | 503 service_unavailable: A dependency is briefly unavailable. Retry with backoff. | 504 image_timeout: Fetching the image took longer than our 20-second budget."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request is malformed or a parameter is invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "invalid_request_error",
                "code": "invalid_mode",
                "message": "Unknown mode \"oil-paint\".",
                "param": "mode",
                "request_id": "req_9f2c1a0b3d4e",
                "docs_url": "https://pinin.ai/developers#errors"
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "The key is missing, malformed, revoked or expired.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "authentication_error",
                "code": "invalid_api_key",
                "message": "That API key is not valid.",
                "param": null,
                "request_id": "req_9f2c1a0b3d4e",
                "docs_url": "https://pinin.ai/developers#errors"
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key lacks the scope this route needs.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "permission_error",
                "code": "insufficient_scope",
                "message": "This key does not hold restorations:write.",
                "param": null,
                "request_id": "req_9f2c1a0b3d4e",
                "docs_url": "https://pinin.ai/developers#errors"
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "No resource with that id belongs to this account.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "invalid_request_error",
                "code": "restoration_not_found",
                "message": "No restoration with that id.",
                "param": "id",
                "request_id": "req_9f2c1a0b3d4e",
                "docs_url": "https://pinin.ai/developers#errors"
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "The request conflicts with the resource's current state.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "invalid_request_error",
                "code": "not_ready",
                "message": "That restoration is processing; there is nothing to download yet.",
                "param": null,
                "request_id": "req_9f2c1a0b3d4e",
                "docs_url": "https://pinin.ai/developers#errors"
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests for this key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "rate_limit_error",
                "code": "rate_limit_exceeded",
                "message": "Rate limit exceeded: 120 requests per minute.",
                "param": null,
                "request_id": "req_9f2c1a0b3d4e",
                "docs_url": "https://pinin.ai/developers#errors"
              }
            }
          }
        },
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds to wait before retrying."
          }
        }
      },
      "ServerError": {
        "description": "Something failed on our side. The request id is the support reference.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "type": "api_error",
                "code": "internal_error",
                "message": "Something went wrong on our side. The request id is your support reference.",
                "param": null,
                "request_id": "req_9f2c1a0b3d4e",
                "docs_url": "https://pinin.ai/developers#errors"
              }
            }
          }
        }
      }
    }
  }
}
