{
  "openapi": "3.1.0",
  "info": {
    "title": "ContentEffort API",
    "version": "1.0.0",
    "description": "Launch content analyses and read the reports from your own applications. Authentication is a Bearer API key. The monthly allowance is the same as on the website.",
    "contact": {
      "name": "ContentEffort",
      "url": "https://contenteffort.com"
    }
  },
  "servers": [
    {
      "url": "https://contenteffort.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Analyses",
      "description": "Launch an analysis and follow it."
    },
    {
      "name": "Reports",
      "description": "Read, download and share finished reports."
    },
    {
      "name": "Account",
      "description": "Account, subscription and keys. Browser session only."
    },
    {
      "name": "Billing",
      "description": "Checkout and customer portal."
    },
    {
      "name": "System",
      "description": "Service status and plan catalogue."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "sessionAuth": []
    }
  ],
  "paths": {
    "/api/analyses": {
      "post": {
        "tags": [
          "Analyses"
        ],
        "summary": "Create an analysis",
        "description": "Requires an API key (Bearer). The call answers immediately with 202; the work continues in the background. One public URL per request, consuming one unit of the monthly allowance.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048
                  },
                  "language": {
                    "type": "string",
                    "enum": [
                      "en",
                      "es"
                    ],
                    "description": "Report language. Defaults to the account language."
                  }
                }
              },
              "examples": {
                "minimal": {
                  "value": {
                    "url": "https://example.com/article"
                  }
                },
                "english": {
                  "value": {
                    "url": "https://example.com/article",
                    "language": "en"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Analysis accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "running"
                      ]
                    },
                    "quota": {
                      "type": "object",
                      "description": "Quota after this analysis was reserved, already discounted.",
                      "properties": {
                        "period": {
                          "type": "string",
                          "nullable": true
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "consumed": {
                          "type": "integer"
                        }
                      },
                      "nullable": true
                    }
                  }
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                },
                "description": "Where to read the report once it is ready."
              },
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying."
              },
              "RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Window length in seconds."
              }
            }
          },
          "400": {
            "description": "invalid_json, missing_url, destination_not_allowed or invalid_language",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "no_plan, quota_exhausted, no_billing_period or subscription_<status>",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "rate_limited or too_many_running",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying."
              }
            }
          },
          "413": {
            "description": "payload_too_large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/reports": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "List reports",
        "description": "Requires an API key (Bearer). Newest first. Use the cursor to walk older pages. Filter by free text on title or address, and by status.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor of the previous page, returned verbatim. Opaque: do not build it."
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "Text to look for in the title or the address."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "running",
                "completed",
                "failed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of reports",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "reports": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "requested_url",
                          "status",
                          "started_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "examples": [
                              "ana_8f3c1d2e4b5a6978"
                            ]
                          },
                          "requested_url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "final_url": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uri"
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "running",
                              "completed",
                              "failed"
                            ]
                          },
                          "started_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "finished_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "share_token": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "share_expires_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer",
                      "description": "Number of reports that match the same filters, not the size of this page."
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/reports/{id}": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Read a report",
        "description": "Requires an API key (Bearer). Returns 404 while the analysis is running, if it does not exist or if it belongs to another account. Reading with a key creates the private share link if there is none.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "language",
                    "requested_url",
                    "report",
                    "links"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "completed"
                      ]
                    },
                    "language": {
                      "type": "string",
                      "enum": [
                        "en",
                        "es"
                      ]
                    },
                    "requested_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "final_url": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uri"
                    },
                    "canonical": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uri"
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "h1": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sha256": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "SHA-256 of the captured text."
                    },
                    "started_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "finished_at": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "partial_capture": {
                      "type": "boolean"
                    },
                    "missing_interactives": {
                      "type": [
                        "array",
                        "null"
                      ],
                      "items": {
                        "type": "string"
                      }
                    },
                    "score": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Nota del informe sobre 100, calculada por el motor y guardada como dato. Es la misma cifra que muestra la cabecera del informe web y del PDF."
                    },
                    "report": {
                      "type": "object",
                      "properties": {
                        "markdown": {
                          "type": "string",
                          "description": "The full report in Markdown."
                        }
                      }
                    },
                    "links": {
                      "type": "object",
                      "properties": {
                        "web": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uri",
                          "description": "Private share link, created automatically when read with an API key."
                        },
                        "expires_at": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "markdown": {
                          "type": "string",
                          "format": "uri"
                        },
                        "pdf": {
                          "type": "string",
                          "format": "uri"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Reports"
        ],
        "summary": "Delete a report",
        "description": "Requires an API key (Bearer) or a browser session. Removes the report, its files and its share link. A failed analysis can be deleted too. The monthly allowance is not refunded.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "deleted_objects": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "analysis_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/reports/{id}.md": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Download the report as Markdown",
        "description": "Requires an API key (Bearer). Sent as an attachment.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Markdown file",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found"
          }
        }
      }
    },
    "/api/reports/{id}.pdf": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Download the report as PDF",
        "description": "Requires an API key (Bearer). The PDF is generated on first request and cached.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PDF file",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found"
          },
          "502": {
            "description": "pdf_unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/reports/{id}.html": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Private HTML view",
        "description": "Requires an API key (Bearer). Without a session it redirects to the sign-in page. Marked noindex.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "HTML report",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "302": {
            "description": "Redirect to sign-in when there is no session"
          }
        }
      }
    },
    "/api/reports/{id}/share": {
      "post": {
        "tags": [
          "Reports"
        ],
        "summary": "Create or fetch the private share link",
        "description": "Requires a signed-in browser session (cookie), not an API key. Long private link valid for 90 days. Reading a report with an API key already creates it.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Active share link",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "share_token": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "examples": [
                        "/r/AbCdEf..."
                      ]
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Reports"
        ],
        "summary": "Revoke the share link",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Account details",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Account",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string",
                      "format": "email"
                    },
                    "language": {
                      "type": "string",
                      "enum": [
                        "en",
                        "es"
                      ]
                    },
                    "plan": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "enum": [
                        "base",
                        "pro",
                        null
                      ]
                    },
                    "can_generate": {
                      "type": "boolean"
                    },
                    "subscription": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "status": {
                          "type": "string",
                          "description": "Stripe subscription status."
                        },
                        "cancel_at_period_end": {
                          "type": "boolean"
                        },
                        "current_period_start": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "current_period_end": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        }
                      }
                    },
                    "quota": {
                      "type": "object",
                      "properties": {
                        "period": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "limit": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "consumed": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Account"
        ],
        "summary": "Change the report language",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "language"
                ],
                "properties": {
                  "language": {
                    "type": "string",
                    "enum": [
                      "en",
                      "es"
                    ]
                  }
                }
              },
              "example": {
                "language": "en"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "language": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_language",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Delete the account and its data",
        "description": "Cancels the subscription and deletes the account. Refused while an analysis is running.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirm"
                ],
                "properties": {
                  "confirm": {
                    "type": "string",
                    "enum": [
                      "DELETE"
                    ]
                  }
                }
              },
              "example": {
                "confirm": "DELETE"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "deleted_objects": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "confirmation_required or invalid_json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "analysis_in_progress",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/account/export": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Export all account data",
        "description": "JSON download for the right of access. Rows keep the storage field names.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "JSON file",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/keys": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "List API keys",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "prefix": {
                            "type": "string",
                            "examples": [
                              "ce_9f2b7c41"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "active",
                              "revoked"
                            ]
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "revoked_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Create an API key",
        "description": "The full key is returned once and never again.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "New key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "prefix": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/keys/rotate": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Rotate the API key",
        "description": "Revokes every active key and creates a new one.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "New key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "prefix": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/keys/{id}": {
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Revoke one key",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "session_required",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/billing/checkout": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Start a subscription checkout",
        "security": [
          {
            "sessionAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "plan"
                ],
                "properties": {
                  "plan": {
                    "type": "string",
                    "enum": [
                      "base",
                      "pro"
                    ]
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "language": {
                    "type": "string",
                    "enum": [
                      "en",
                      "es"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_plan",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "already_subscribed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "rate_limited",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait before retrying."
              }
            }
          },
          "502": {
            "description": "stripe_error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/billing/portal": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Open the Stripe customer portal",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Portal URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "missing_stripe_customer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "stripe_error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "Stable machine-readable code, snake_case.",
                      "examples": [
                        "not_authenticated"
                      ]
                    },
                    "reason": {
                      "type": "string",
                      "description": "Extra detail for destination_not_allowed.",
                      "enum": [
                        "not_public",
                        "private_range",
                        "numeric_host",
                        "unsupported_scheme",
                        "unsupported_port",
                        "cloud_metadata",
                        "redirect_not_allowed",
                        "unresolvable_host"
                      ]
                    },
                    "suggested_plan": {
                      "type": "string",
                      "examples": [
                        "pro"
                      ]
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Maximum allowed when the limit is the reason."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/plans": {
      "get": {
        "tags": [
          "System"
        ],
        "summary": "Plan catalogue",
        "security": [],
        "responses": {
          "200": {
            "description": "Plans and prices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "plans": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "enum": [
                              "base",
                              "pro"
                            ]
                          },
                          "monthly_price": {
                            "type": "string"
                          },
                          "monthly_quota": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "currency": {
                      "type": "string",
                      "examples": [
                        "USD"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "tags": [
          "System"
        ],
        "summary": "Service status",
        "security": [],
        "responses": {
          "200": {
            "description": "Service up",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "service": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/models": {
      "get": {
        "tags": [
          "System"
        ],
        "summary": "Models the engine can use, with their price",
        "description": "Browser session only. Useful to check provider availability; not needed to create analyses.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogue",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "models": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "pricing": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "models_unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ce_<64 hex>",
        "description": "API key created in Settings → API keys."
      },
      "sessionAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "better-auth.session_token",
        "description": "Browser session. Only for account, key and share routes."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Stable machine-readable code, snake_case.",
            "examples": [
              "not_authenticated"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Extra detail for destination_not_allowed.",
            "enum": [
              "not_public",
              "private_range",
              "numeric_host",
              "unsupported_scheme",
              "unsupported_port",
              "cloud_metadata",
              "redirect_not_allowed",
              "unresolvable_host"
            ]
          },
          "suggested_plan": {
            "type": "string",
            "examples": [
              "pro"
            ]
          },
          "limit": {
            "type": "integer",
            "description": "Maximum allowed when the limit is the reason."
          }
        }
      },
      "ReportSummary": {
        "type": "object",
        "required": [
          "id",
          "requested_url",
          "status",
          "started_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "ana_8f3c1d2e4b5a6978"
            ]
          },
          "requested_url": {
            "type": "string",
            "format": "uri"
          },
          "final_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "completed",
              "failed"
            ]
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "share_token": {
            "type": [
              "string",
              "null"
            ]
          },
          "share_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Report": {
        "type": "object",
        "required": [
          "id",
          "status",
          "language",
          "requested_url",
          "report",
          "links"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed"
            ]
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "es"
            ]
          },
          "requested_url": {
            "type": "string",
            "format": "uri"
          },
          "final_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "canonical": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "h1": {
            "type": [
              "string",
              "null"
            ]
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "description": "SHA-256 of the captured text."
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "partial_capture": {
            "type": "boolean"
          },
          "missing_interactives": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "score": {
            "type": [
              "number",
              "null"
            ],
            "description": "Nota del informe sobre 100, calculada por el motor y guardada como dato. Es la misma cifra que muestra la cabecera del informe web y del PDF."
          },
          "report": {
            "type": "object",
            "properties": {
              "markdown": {
                "type": "string",
                "description": "The full report in Markdown."
              }
            }
          },
          "links": {
            "type": "object",
            "properties": {
              "web": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri",
                "description": "Private share link, created automatically when read with an API key."
              },
              "expires_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "markdown": {
                "type": "string",
                "format": "uri"
              },
              "pdf": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "es"
            ]
          },
          "plan": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "base",
              "pro",
              null
            ]
          },
          "can_generate": {
            "type": "boolean"
          },
          "subscription": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "status": {
                "type": "string",
                "description": "Stripe subscription status."
              },
              "cancel_at_period_end": {
                "type": "boolean"
              },
              "current_period_start": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "current_period_end": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "quota": {
            "type": "object",
            "properties": {
              "period": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "limit": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "consumed": {
                "type": "integer"
              }
            }
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "prefix": {
            "type": "string",
            "examples": [
              "ce_9f2b7c41"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "revoked"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Plans": {
        "type": "object",
        "properties": {
          "plans": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "enum": [
                    "base",
                    "pro"
                  ]
                },
                "monthly_price": {
                  "type": "string"
                },
                "monthly_quota": {
                  "type": "string"
                }
              }
            }
          },
          "currency": {
            "type": "string",
            "examples": [
              "USD"
            ]
          }
        }
      },
      "ShareLink": {
        "type": "object",
        "properties": {
          "share_token": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "examples": [
              "/r/AbCdEf..."
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AnalysisAccepted": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "running"
            ]
          }
        }
      }
    }
  }
}
