{
  "openapi": "3.1.0",
  "info": {
    "title": "xpaling API",
    "version": "1.0.0",
    "description": "Public, dated security records of websites, made in the Netherlands. Submit a URL, poll status, read the report at /host/{host}/rep/{id}.json.",
    "contact": {
      "name": "xpaling",
      "url": "https://xpaling.com"
    },
    "termsOfService": "https://xpaling.com/docs/api#fair-use"
  },
  "servers": [
    {
      "url": "https://xpaling.com/api/v1"
    }
  ],
  "paths": {
    "/scan": {
      "post": {
        "operationId": "submitScan",
        "summary": "Submit a URL for observation",
        "description": "Without a key: 10 public observations a day per IP. Everyone: at most 5 new observations of one registered domain a day (one count shared by all users). With a key: the plan quota.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScanRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "An identical recent public observation exists and is reused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanAccepted"
                }
              }
            }
          },
          "202": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanAccepted"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/cases": {
      "post": {
        "operationId": "createCase",
        "summary": "Put URLs into a box and find the specific links between them",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "urls"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "urls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 1000
                  },
                  "visibility": {
                    "type": "string",
                    "enum": [
                      "private",
                      "public"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Box created; members are observed or reused",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "url": {
                      "type": "string"
                    },
                    "json": {
                      "type": "string"
                    },
                    "added": {
                      "type": "integer"
                    },
                    "reused": {
                      "type": "integer"
                    },
                    "submitted": {
                      "type": "integer"
                    },
                    "skipped": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "get": {
        "operationId": "listCases",
        "summary": "Your boxes",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Boxes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cases": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/cases/{id}": {
      "get": {
        "operationId": "getCase",
        "summary": "Box result: links with evidence, clusters, unlinked hosts",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "name": {
                      "type": "string"
                    },
                    "members": {
                      "type": "integer"
                    },
                    "summary": {
                      "type": "string"
                    },
                    "hosts": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "links": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "sentence": {
                            "type": "string"
                          },
                          "hosts": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "evidence": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "clusters": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "unlinked": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "observing": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "delete": {
        "operationId": "deleteCase",
        "summary": "Delete a box",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/cases/{id}/members": {
      "post": {
        "operationId": "addCaseMembers",
        "summary": "Add URLs to a box",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "urls"
                ],
                "properties": {
                  "urls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Added; the box is re-analyzed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "added": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "reused": {
                      "type": "integer"
                    },
                    "submitted": {
                      "type": "integer"
                    },
                    "skipped": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/scan/{id}": {
      "get": {
        "operationId": "getScanStatus",
        "summary": "Observation status",
        "description": "queued → running → writing → done (or failed). writing: observed, the report is being written into the record and its pages / .json are not readable yet; poll again (Retry-After: 3). The waiting page at the report URL shows the same stage. A re-check that changed nothing answers done with unchanged: true and report_id = the report it confirmed.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-hj-kmnp-tv-z]{10}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status; when done, the full public report object (same shape as the report .json)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScanStatus"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "503": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ScanRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "examples": [
              "https://example.com"
            ]
          },
          "visibility": {
            "type": "string",
            "enum": [
              "public",
              "unlisted",
              "private"
            ],
            "default": "public"
          },
          "region": {
            "type": "string",
            "enum": [
              "eu"
            ],
            "description": "Every observation is from the EU; optional."
          },
          "ua": {
            "type": "string"
          },
          "referer": {
            "type": "string"
          }
        }
      },
      "ScanAccepted": {
        "type": "object",
        "required": [
          "id",
          "existing",
          "url",
          "report",
          "status_url"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "existing": {
            "type": "boolean"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "report": {
            "type": "string",
            "format": "uri",
            "description": "HTML report; append .json or .md for machine formats"
          },
          "status_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "ScanStatus": {
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "writing",
              "done",
              "failed"
            ]
          },
          "stage": {
            "type": "string",
            "enum": [
              "queued",
              "capturing",
              "auditing",
              "publishing"
            ],
            "description": "Before done: the step the waiting page shows (queued · opening the page · reading the host's records · writing the report)"
          },
          "step": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4
          },
          "steps": {
            "type": "integer",
            "const": 4
          },
          "url": {
            "type": "string",
            "description": "Before done: the submitted URL"
          },
          "host": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "dup_of": {
            "type": [
              "string",
              "null"
            ]
          },
          "unchanged": {
            "type": "boolean",
            "description": "done: this re-check found nothing new; report is the one it confirmed (R16)"
          },
          "report_id": {
            "type": "string",
            "description": "with unchanged: the id of the confirmed report"
          },
          "report": {
            "type": "object",
            "additionalProperties": true,
            "description": "Present when status is done: the report as served at <report>.json"
          }
        }
      },
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "/docs/errors#<code>"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "Problem": {
        "description": "RFC 9457 problem details",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from /account (xp_live_...)"
      }
    }
  },
  "externalDocs": {
    "url": "https://xpaling.com/docs/api",
    "description": "Human-readable API docs"
  }
}