{
  "openapi": "3.1.0",
  "info": {
    "title": "Automata Waitlist API",
    "version": "1.0.0",
    "description": "Join the Automata launch waitlist or export it with an operator-provisioned token."
  },
  "servers": [
    {
      "url": "https://automata-ci.com"
    }
  ],
  "paths": {
    "/api/waitlist": {
      "post": {
        "summary": "Join the waitlist",
        "description": "Validates and deduplicates an email address. The response does not disclose whether the address was already registered.",
        "operationId": "joinWaitlist",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WaitlistRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/WaitlistRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/WaitlistRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The address was accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "422": {
            "$ref": "#/components/responses/InvalidEmail"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "get": {
        "summary": "Export the waitlist",
        "description": "Returns registered addresses and campaign attribution. This operator-only operation requires a provisioned bearer token.",
        "operationId": "exportWaitlist",
        "security": [
          {
            "exportToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The current waitlist export.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WaitlistExport"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "exportToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "opaque operator token",
        "description": "Provisioned by an Automata operator; no self-service OAuth flow is available."
      }
    },
    "schemas": {
      "WaitlistRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "utm_campaign": {
            "type": "string",
            "maxLength": 64,
            "description": "Optional lowercase campaign identifier. Unsupported characters are removed."
          }
        }
      },
      "SuccessResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "WaitlistRow": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "email",
          "utm_campaign"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "utm_campaign": {
            "type": "string"
          }
        }
      },
      "WaitlistExport": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "emails",
          "byCampaign",
          "rows"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "byCampaign": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "minimum": 0
            }
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WaitlistRow"
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request body could not be parsed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InvalidEmail": {
        "description": "The email address is invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "RateLimited": {
        "description": "The client exceeded 20 requests per IP address per hour.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "The bearer token is missing or invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    }
  }
}
