{
  "openapi": "3.1.0",
  "info": {
    "title": "GoClickIT Screenshot API",
    "version": "0.3.0",
    "description": "Paid workspace screenshot API and signed image URLs. API keys require target-domain whitelists. Capture returns HTTP 202 after a bounded render. Signed URLs reuse cached renders. Temporary results expire after one hour. No idempotency-key contract."
  },
  "servers": [
    {
      "url": "https://run.goclick.it"
    }
  ],
  "security": [
    {
      "BearerKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Revocable paid workspace API key; keep server-side."
      },
      "SignedImageURL": {
        "type": "apiKey",
        "in": "query",
        "name": "signature",
        "description": "Generated HMAC signature bound to the URL path and all parameters. Use the app generator or signing endpoint."
      }
    }
  },
  "paths": {
    "/api": {
      "post": {
        "operationId": "createCapture",
        "summary": "Create a capture or generate a signed image URL",
        "parameters": [
          {
            "name": "r",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "api-capture",
                "sign-screenshot-url"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "Public HTTP/HTTPS only. No credentials or private-network hosts; standard ports only."
                  },
                  "width": {
                    "type": "integer",
                    "minimum": 320,
                    "maximum": 2560,
                    "default": 1440
                  },
                  "height": {
                    "type": "integer",
                    "minimum": 200,
                    "maximum": 2000,
                    "default": 900
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "viewport",
                      "full",
                      "selector",
                      "offset",
                      "section"
                    ],
                    "default": "viewport"
                  },
                  "selector": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "Required for selector mode."
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 15000,
                    "default": 0,
                    "description": "Nonzero offset is supported only for section or offset mode."
                  },
                  "device": {
                    "type": "string",
                    "enum": [
                      "desktop",
                      "tablet",
                      "mobile",
                      "custom"
                    ],
                    "description": "Defaults to desktop; omitted with width/height selects custom. Presets determine their own dimensions."
                  },
                  "section_height": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000,
                    "description": "For section mode, height at the vertical offset. Maximum area: 16 megapixels."
                  },
                  "id": {
                    "type": "string",
                    "description": "Required URL profile ID when r=sign-screenshot-url. Create profiles in the owner UI."
                  },
                  "ttl": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 2592000,
                    "default": 86400,
                    "description": "Signed URL lifetime, for signing requests only."
                  },
                  "cache": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 3600,
                    "default": 3600,
                    "description": "Internal render cache lifetime for a signed URL."
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "properties": {
                        "mode": {
                          "const": "selector"
                        }
                      },
                      "required": [
                        "mode"
                      ]
                    },
                    "then": {
                      "required": [
                        "selector"
                      ],
                      "properties": {
                        "selector": {
                          "minLength": 1
                        }
                      }
                    }
                  }
                ]
              },
              "example": {
                "url": "https://example.com",
                "width": 1440,
                "height": 900,
                "mode": "full"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed URL generated; no render yet",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url",
                    "expires_at",
                    "cache_seconds"
                  ],
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "expires_at": {
                      "type": "integer"
                    },
                    "cache_seconds": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Capture completed; read status, then fetch its PNG",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "running",
                        "done",
                        "failed"
                      ]
                    },
                    "status_url": {
                      "type": "string"
                    },
                    "result_url": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "error": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                },
                "example": {
                  "id": "JOB_ID",
                  "status": "done",
                  "status_url": "/api?r=job&id=JOB_ID"
                }
              }
            }
          },
          "400": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "readCapture",
        "summary": "Read a job or download its PNG",
        "parameters": [
          {
            "name": "r",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "job",
                "job-result"
              ]
            }
          },
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "JSON status for r=job; PNG bytes for r=job-result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "running",
                        "done",
                        "failed"
                      ]
                    },
                    "status_url": {
                      "type": "string"
                    },
                    "result_url": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "error": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/shot/{profile}.png": {
      "get": {
        "operationId": "getSignedScreenshot",
        "summary": "Get a signed screenshot PNG, rendering on cache miss",
        "security": [
          {
            "SignedImageURL": []
          }
        ],
        "parameters": [
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{32}$"
            }
          },
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "Public HTTP/HTTPS only. No credentials or private-network hosts; standard ports only."
            }
          },
          {
            "name": "device",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "desktop",
                "tablet",
                "mobile",
                "custom"
              ],
              "description": "Defaults to desktop; omitted with width/height selects custom. Presets determine their own dimensions."
            }
          },
          {
            "name": "width",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 320,
              "maximum": 2560,
              "default": 1440
            }
          },
          {
            "name": "height",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 200,
              "maximum": 2000,
              "default": 900
            }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "viewport",
                "full",
                "selector",
                "offset",
                "section"
              ],
              "default": "viewport"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 15000,
              "default": 0,
              "description": "Nonzero offset is supported only for section or offset mode."
            }
          },
          {
            "name": "section_height",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000,
              "description": "For section mode, height at the vertical offset. Maximum area: 16 megapixels."
            }
          },
          {
            "name": "selector",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 300,
              "description": "Required for selector mode."
            }
          },
          {
            "name": "expires",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cache",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 60,
              "maximum": 3600,
              "default": 3600,
              "description": "Internal render cache lifetime for a signed URL."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "PNG screenshot",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Unavailable or a concurrent render is in progress. Retry-After may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "head": {
        "operationId": "headSignedScreenshot",
        "summary": "Read cached image metadata only; does not render",
        "security": [
          {
            "SignedImageURL": []
          }
        ],
        "parameters": [
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{32}$"
            }
          },
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "Public HTTP/HTTPS only. No credentials or private-network hosts; standard ports only."
            }
          },
          {
            "name": "device",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "desktop",
                "tablet",
                "mobile",
                "custom"
              ],
              "description": "Defaults to desktop; omitted with width/height selects custom. Presets determine their own dimensions."
            }
          },
          {
            "name": "width",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 320,
              "maximum": 2560,
              "default": 1440
            }
          },
          {
            "name": "height",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 200,
              "maximum": 2000,
              "default": 900
            }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "viewport",
                "full",
                "selector",
                "offset",
                "section"
              ],
              "default": "viewport"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 15000,
              "default": 0,
              "description": "Nonzero offset is supported only for section or offset mode."
            }
          },
          {
            "name": "section_height",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000,
              "description": "For section mode, height at the vertical offset. Maximum area: 16 megapixels."
            }
          },
          {
            "name": "selector",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 300,
              "description": "Required for selector mode."
            }
          },
          {
            "name": "expires",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cache",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 60,
              "maximum": 3600,
              "default": 3600,
              "description": "Internal render cache lifetime for a signed URL."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cached image metadata"
          },
          "403": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "No cached image; issue GET first."
          }
        }
      }
    }
  }
}
