{
  "openapi": "3.1.0",
  "info": {
    "title": "Allscreenshots API",
    "version": "1.0.0",
    "description": "Capture website screenshots, PDFs, and page outputs without managing browser infrastructure."
  },
  "servers": [
    {
      "url": "https://api.allscreenshots.com"
    }
  ],
  "security": [
    {
      "apiKeyAuth": []
    },
    {
      "bearerAuth": [],
      "apiKeyId": []
    }
  ],
  "paths": {
    "/v1/screenshots": {
      "post": {
        "operationId": "createScreenshot",
        "summary": "Capture a website screenshot",
        "description": "Render a URL and return a screenshot, PDF, or hosted output.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScreenshotRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Screenshot created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreenshotResponse"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "contentEncoding": "binary"
                }
              },
              "image/webp": {
                "schema": {
                  "type": "string",
                  "contentEncoding": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "contentEncoding": "binary"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "contentEncoding": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    },
    "/v1/screenshots/async": {
      "post": {
        "operationId": "createAsyncScreenshot",
        "summary": "Create an asynchronous screenshot job",
        "description": "Submit a screenshot job for asynchronous processing and receive job status or webhook delivery.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/ScreenshotRequest"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "webhookUrl": {
                        "type": "string",
                        "format": "uri"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Screenshot job accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "OAuth or dashboard access token, not a raw API key; pair with X-API-Key-Id."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Pass your raw API key in X-API-Key."
      },
      "apiKeyId": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key-Id",
        "description": "Required alongside an OAuth/dashboard Bearer token; use the organization API key ID."
      }
    },
    "schemas": {
      "ScreenshotRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The URL to capture."
          },
          "fullPage": {
            "type": "boolean",
            "default": true
          },
          "viewport": {
            "type": "object",
            "properties": {
              "width": {
                "type": "integer",
                "default": 1280
              },
              "height": {
                "type": "integer",
                "default": 800
              }
            }
          },
          "format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "webp",
              "pdf"
            ],
            "default": "webp"
          },
          "responseType": {
            "type": "string",
            "enum": [
              "binary",
              "base64",
              "url"
            ],
            "default": "binary"
          },
          "blockAds": {
            "type": "boolean"
          },
          "blockCookieBanners": {
            "type": "boolean"
          },
          "darkMode": {
            "type": "boolean"
          },
          "stealth": {
            "type": "boolean"
          },
          "delay": {
            "type": "integer",
            "description": "Additional wait time before capture in milliseconds."
          },
          "waitForSelector": {
            "type": "string",
            "description": "CSS selector to wait for before capture."
          }
        }
      },
      "ScreenshotResponse": {
        "type": "object",
        "properties": {
          "storageUrl": {
            "type": "string",
            "format": "uri",
            "description": "Hosted capture URL when responseType is url; temporary storage, see expiresAt."
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "data": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "Expiry timestamp for hosted output."
          }
        }
      }
    }
  }
}
