{
  "openapi": "3.1.0",
  "info": {
    "title": "Enlist API",
    "version": "1",
    "description": "Waitlist management API. Authenticate every request with `Authorization: Bearer <api_key>`."
  },
  "servers": [
    {
      "url": "https://enlist.dev"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from the Enlist dashboard."
      }
    },
    "schemas": {
      "Waitlist": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "550e8400-e29b-41d4-a716-446655440000"
          },
          "name": {
            "type": "string",
            "example": "Beta Access"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "example": "2024-01-15T12:00:00.000Z"
          }
        },
        "required": [
          "id",
          "name",
          "created_at"
        ]
      },
      "WaitlistWithCount": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "550e8400-e29b-41d4-a716-446655440000"
          },
          "name": {
            "type": "string",
            "example": "Beta Access"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "example": "2024-01-15T12:00:00.000Z"
          },
          "signup_count": {
            "type": "integer",
            "minimum": 0,
            "example": 142
          }
        },
        "required": [
          "id",
          "name",
          "created_at",
          "signup_count"
        ]
      },
      "FieldDefinition": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "example": "company"
          },
          "label": {
            "type": "string",
            "example": "Company name"
          },
          "type": {
            "type": "string",
            "enum": [
              "string",
              "number",
              "boolean"
            ],
            "example": "string"
          },
          "required": {
            "type": "boolean",
            "example": false
          },
          "position": {
            "type": "integer",
            "minimum": 0,
            "example": 0
          }
        },
        "required": [
          "key",
          "label",
          "type",
          "required",
          "position"
        ]
      },
      "Signup": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "550e8400-e29b-41d4-a716-446655440001"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "ada@example.com"
          },
          "position": {
            "type": "integer",
            "minimum": 1,
            "example": 47
          },
          "utm_source": {
            "type": [
              "string",
              "null"
            ],
            "example": "twitter"
          },
          "referrer": {
            "type": [
              "string",
              "null"
            ],
            "example": "https://twitter.com"
          },
          "referral_code": {
            "type": "string",
            "example": "k3f9x2mqbr"
          },
          "referral_count": {
            "type": "integer",
            "minimum": 0,
            "example": 3
          },
          "referred_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "example": "550e8400-e29b-41d4-a716-446655440002"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "example": {
              "name": "Ada Lovelace",
              "company": "Acme"
            }
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                },
                {
                  "type": "boolean"
                }
              ]
            },
            "example": {
              "company": "Acme",
              "headcount": 50,
              "is_enterprise": false
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "example": "2024-01-15T12:00:00.000Z"
          },
          "email_status": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "sent",
              "delivered",
              "delivery_delayed",
              "opened",
              "clicked",
              "bounced",
              "complained",
              "failed",
              "suppressed",
              "config_error"
            ],
            "example": "delivered"
          },
          "email_delivered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "example": "2024-01-15T12:00:05.000Z"
          },
          "email_opened_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "email_clicked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "email",
          "position",
          "utm_source",
          "referrer",
          "referral_code",
          "referral_count",
          "referred_by",
          "metadata",
          "fields",
          "created_at",
          "email_status",
          "email_delivered_at",
          "email_opened_at",
          "email_clicked_at"
        ]
      },
      "SignupCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "550e8400-e29b-41d4-a716-446655440001"
          },
          "position": {
            "type": "integer",
            "minimum": 1,
            "example": 47
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "example": 200
          },
          "referral_code": {
            "type": "string",
            "example": "k3f9x2mqbr"
          }
        },
        "required": [
          "id",
          "position",
          "total",
          "referral_code"
        ]
      },
      "WaitlistStats": {
        "type": "object",
        "properties": {
          "waitlist_id": {
            "type": "string",
            "format": "uuid",
            "example": "550e8400-e29b-41d4-a716-446655440000"
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "example": 200
          },
          "range_total": {
            "type": "integer",
            "minimum": 0,
            "example": 48
          },
          "range_from": {
            "type": "string",
            "example": "2024-01-01"
          },
          "range_to": {
            "type": "string",
            "example": "2024-01-30"
          },
          "daily": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "example": "2024-01-15"
                },
                "signups": {
                  "type": "integer",
                  "minimum": 0,
                  "example": 12
                }
              },
              "required": [
                "date",
                "signups"
              ]
            }
          },
          "by_source": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "source": {
                  "type": "string",
                  "example": "twitter"
                },
                "signups": {
                  "type": "integer",
                  "minimum": 0,
                  "example": 87
                }
              },
              "required": [
                "source",
                "signups"
              ]
            }
          },
          "email_engagement": {
            "type": "object",
            "properties": {
              "emails_sent": {
                "type": "integer",
                "minimum": 0,
                "example": 180
              },
              "delivery_rate": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 100,
                "example": 94
              },
              "open_rate": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 100,
                "example": 41
              },
              "click_rate": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 100,
                "example": 12
              }
            },
            "required": [
              "emails_sent",
              "delivery_rate",
              "open_rate",
              "click_rate"
            ]
          },
          "growth": {
            "type": "object",
            "properties": {
              "last_7": {
                "type": "integer",
                "minimum": 0,
                "example": 38
              },
              "prev_7": {
                "type": "integer",
                "minimum": 0,
                "example": 31
              },
              "delta": {
                "type": [
                  "integer",
                  "null"
                ],
                "example": 23
              }
            },
            "required": [
              "last_7",
              "prev_7",
              "delta"
            ]
          },
          "referrer_domains": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "domain": {
                  "type": "string",
                  "example": "news.ycombinator.com"
                },
                "signups": {
                  "type": "integer",
                  "minimum": 0,
                  "example": 64
                }
              },
              "required": [
                "domain",
                "signups"
              ]
            }
          }
        },
        "required": [
          "waitlist_id",
          "total",
          "range_total",
          "range_from",
          "range_to",
          "daily",
          "by_source",
          "email_engagement",
          "growth",
          "referrer_domains"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "invalid_request",
                  "conflict",
                  "rate_limited",
                  "quota_exceeded",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string",
                "example": "Waitlist not found."
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "Account": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string",
            "format": "uuid",
            "example": "550e8400-e29b-41d4-a716-446655440002"
          },
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "launch",
              "scale",
              "enterprise"
            ],
            "example": "free"
          },
          "quota": {
            "type": "object",
            "properties": {
              "tier": {
                "type": "string",
                "example": "free"
              },
              "signups_used": {
                "type": "integer",
                "minimum": 0,
                "example": 450
              },
              "signups_limit": {
                "type": "integer",
                "minimum": 0,
                "example": 500
              },
              "signups_remaining": {
                "type": "integer",
                "minimum": 0,
                "example": 50
              },
              "percent_used": {
                "type": "integer",
                "minimum": 0,
                "example": 23
              },
              "can_add_signup": {
                "type": "boolean",
                "example": true
              }
            },
            "required": [
              "tier",
              "signups_used",
              "signups_limit",
              "signups_remaining",
              "percent_used",
              "can_add_signup"
            ]
          }
        },
        "required": [
          "account_id",
          "plan",
          "quota"
        ]
      }
    },
    "parameters": {}
  },
  "paths": {
    "/v1/account": {
      "get": {
        "operationId": "getAccount",
        "summary": "Get account and quota usage",
        "tags": [
          "Account"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Account details with live quota usage for the current calendar month.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists": {
      "post": {
        "operationId": "createWaitlist",
        "summary": "Create a waitlist",
        "tags": [
          "Waitlists"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Waitlist created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Waitlist"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body or parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A waitlist with that name already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listWaitlists",
        "summary": "List waitlists",
        "tags": [
          "Waitlists"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of waitlists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WaitlistWithCount"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "data",
                    "total",
                    "limit",
                    "offset",
                    "has_more"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists/{id}": {
      "get": {
        "operationId": "getWaitlist",
        "summary": "Get a waitlist",
        "tags": [
          "Waitlists"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The waitlist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Waitlist"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateWaitlist",
        "summary": "Rename a waitlist",
        "tags": [
          "Waitlists"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Waitlist renamed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Waitlist"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body or parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Another waitlist on this account already has that name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteWaitlist",
        "summary": "Delete a waitlist",
        "tags": [
          "Waitlists"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Waitlist deleted, along with every signup on it, its field definitions, and its signup-email copy. Not reversible — export the signups first if you want them."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists/{id}/signups": {
      "post": {
        "operationId": "createSignup",
        "summary": "Add a signup",
        "tags": [
          "Signups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "maxLength": 320,
                    "format": "email"
                  },
                  "utm_source": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200
                  },
                  "referrer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 2000
                  },
                  "referral_code": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64
                  },
                  "metadata": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "fields": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 1000
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Signup created (or returned idempotently for a duplicate email).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignupCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body or parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Stored-signup limit for the account plan has been reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listSignups",
        "summary": "List signups",
        "tags": [
          "Signups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "description": "Max results to return (1–200)."
            },
            "required": false,
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "description": "Number of results to skip."
            },
            "required": false,
            "name": "offset",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "email",
              "description": "Exact-match filter by email address."
            },
            "required": false,
            "name": "email",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of signups.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Signup"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "data",
                    "total",
                    "limit",
                    "offset",
                    "has_more"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists/{id}/signups/export": {
      "get": {
        "operationId": "exportSignups",
        "summary": "Export signups as CSV",
        "tags": [
          "Signups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "All signups as a CSV file. Columns: position, email, created_at, utm_source, referrer, email_status, email_delivered_at, email_opened_at, email_clicked_at, metadata, id.",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists/{id}/signups/{signupId}": {
      "delete": {
        "operationId": "deleteSignup",
        "summary": "Delete a signup",
        "tags": [
          "Signups"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Signup ID."
            },
            "required": true,
            "name": "signupId",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Signup deleted."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists/{id}/stats": {
      "get": {
        "operationId": "getWaitlistStats",
        "summary": "Get waitlist stats",
        "tags": [
          "Stats"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "description": "Start date (YYYY-MM-DD). Defaults to 30 days before `to`."
            },
            "required": false,
            "name": "from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "End date (YYYY-MM-DD). Defaults to today UTC."
            },
            "required": false,
            "name": "to",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Waitlist statistics with daily breakdown and source attribution.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WaitlistStats"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body or parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists/{id}/fields": {
      "get": {
        "operationId": "listWaitlistFields",
        "summary": "List field definitions",
        "tags": [
          "Fields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Field definitions for this waitlist.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FieldDefinition"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "data",
                    "total",
                    "limit",
                    "offset",
                    "has_more"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWaitlistField",
        "summary": "Create a field definition",
        "tags": [
          "Fields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "^[a-z][a-z0-9_]{0,63}$"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "required": {
                    "type": "boolean"
                  },
                  "position": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "key",
                  "label",
                  "type"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Field created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldDefinition"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body or parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A field with that key already exists on this waitlist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/waitlists/{id}/fields/{key}": {
      "patch": {
        "operationId": "updateWaitlistField",
        "summary": "Update a field definition",
        "tags": [
          "Fields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "description": "Field key."
            },
            "required": true,
            "name": "key",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "required": {
                    "type": "boolean"
                  },
                  "position": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Field updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FieldDefinition"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body or parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteWaitlistField",
        "summary": "Delete a field definition",
        "tags": [
          "Fields"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "Waitlist ID."
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "description": "Field key."
            },
            "required": true,
            "name": "key",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "Field deleted. Existing signup values are preserved."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API key lacks the required scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {}
}