{
  "openapi": "3.0.3",
  "info": {
    "title": "Crawlit API",
    "version": "1.0.0",
    "description": "REST API reference for the Crawlit AI Search Visibility Platform. Trigger scans, retrieve pillar scores, and integrate AI visibility data into your workflow."
  },
  "servers": [
    {
      "url": "https://crawlit.eu",
      "description": "Production server"
    }
  ],
  "paths": {
    "/api/v1/scan": {
      "post": {
        "summary": "Trigger a scan",
        "description": "Creates a new website audit scan. Authenticate with an API key from your dashboard.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "The target website URL to scan (e.g., https://example.com)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Scan triggered successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "url": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "example": "pending"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (e.g. invalid URL, missing body)"
          },
          "401": {
            "description": "Unauthorized - Invalid API key"
          },
          "429": {
            "description": "Daily scan limit reached for your plan"
          }
        }
      }
    },
    "/api/v1/scans/{uuid}": {
      "get": {
        "summary": "Retrieve scan results",
        "description": "Get the detailed audit results and scores for a specific scan. Scan results are available once status is 'completed'.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The scan UUID"
          }
        ],
        "responses": {
          "200": {
            "description": "Scan results retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "url": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "example": "completed"
                    },
                    "overall_score": {
                      "type": "integer",
                      "example": 85
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "pillar": {
                            "type": "string",
                            "example": "seo"
                          },
                          "status": {
                            "type": "string",
                            "example": "completed"
                          },
                          "score": {
                            "type": "integer",
                            "example": 90
                          },
                          "findings": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "title": {
                                  "type": "string"
                                },
                                "description": {
                                  "type": "string"
                                },
                                "severity": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid API key"
          },
          "403": {
            "description": "Forbidden - This scan belongs to another user"
          },
          "404": {
            "description": "Scan not found"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Enter your API key with Bearer prefix: Bearer cs_xxxxxxxxx"
      }
    }
  }
}
