{
  "openapi": "3.1.0",
  "info": {
    "title": "Earlybirdo Creator Offers API",
    "version": "1.0.0",
    "description": "User-authenticated offer management. Writes use dollars; returned campaign records use cents. No service-role, redemption-key, or MCP credentials."
  },
  "servers": [
    {
      "url": "https://earlybirdo.com/api/v1"
    }
  ],
  "security": [
    {
      "CreatorSession": []
    }
  ],
  "components": {
    "securitySchemes": {
      "CreatorSession": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Supabase user JWT"
      }
    },
    "schemas": {
      "OfferPatch": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 80
          },
          "tagline": {
            "type": "string",
            "maxLength": 140
          },
          "about": {
            "type": "string",
            "maxLength": 5000
          },
          "category": {
            "enum": [
              "apps",
              "food_drink",
              "products",
              "services",
              "events"
            ]
          },
          "images": {
            "type": "array",
            "maxItems": 8,
            "items": {
              "type": "string",
              "maxLength": 512
            }
          },
          "delivery_by": {
            "type": "string",
            "format": "date"
          },
          "duration_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 60
          },
          "refund_policy": {
            "enum": [
              "anytime",
              "window_30",
              "late_only"
            ]
          },
          "charge_timing": {
            "enum": [
              "at_checkout",
              "when_ready"
            ]
          },
          "redeem_until": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "alcohol_licence_confirmed": {
            "type": "boolean"
          },
          "place": {
            "anyOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "lat",
                  "lng",
                  "radius_km"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "lat": {
                    "type": "number",
                    "minimum": -90,
                    "maximum": 90
                  },
                  "lng": {
                    "type": "number",
                    "minimum": -180,
                    "maximum": 180
                  },
                  "radius_km": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 500
                  }
                }
              }
            ]
          },
          "perks": {
            "type": "array",
            "maxItems": 8,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "price",
                "spots"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "maxLength": 80
                },
                "description": {
                  "type": "string",
                  "maxLength": 500
                },
                "price": {
                  "type": "number",
                  "minimum": 1,
                  "maximum": 10000,
                  "multipleOf": 0.01
                },
                "regular_price": {
                  "anyOf": [
                    {
                      "type": "number",
                      "minimum": 1,
                      "maximum": 10000,
                      "multipleOf": 0.01
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "spots": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 1000
                },
                "ships": {
                  "type": "boolean"
                },
                "shipping": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 500,
                  "multipleOf": 0.01
                },
                "shipping_details": {
                  "type": "string",
                  "maxLength": 300
                },
                "food_details": {
                  "type": "string",
                  "maxLength": 500
                }
              }
            }
          },
          "milestones": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title",
                "due_date"
              ],
              "properties": {
                "title": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80
                },
                "due_date": {
                  "type": "string",
                  "format": "date"
                }
              }
            }
          }
        }
      },
      "OfferResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "offer": {
                "type": "object",
                "description": "Owned or accepted shared campaign database record, including perks (prices in cents) and milestones.",
                "additionalProperties": true
              },
              "publish_blockers": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/offers": {
      "get": {
        "operationId": "listOffers",
        "summary": "listOffers",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "offers": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "next_offset": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "401": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "403": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "404": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "409": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "422": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "503": {
            "description": "Request rejected. JSON error has code and an optional message."
          }
        }
      },
      "post": {
        "operationId": "createOffer",
        "summary": "createOffer",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{7,127}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfferResponse"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "401": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "403": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "404": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "409": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "422": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "503": {
            "description": "Request rejected. JSON error has code and an optional message."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfferPatch"
              }
            }
          }
        }
      }
    },
    "/offers/{id}": {
      "get": {
        "operationId": "getOffer",
        "summary": "getOffer",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfferResponse"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "401": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "403": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "404": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "409": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "422": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "503": {
            "description": "Request rejected. JSON error has code and an optional message."
          }
        }
      },
      "patch": {
        "operationId": "updateOffer",
        "summary": "updateOffer",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{7,127}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfferResponse"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "401": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "403": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "404": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "409": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "422": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "503": {
            "description": "Request rejected. JSON error has code and an optional message."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfferPatch"
              }
            }
          }
        }
      }
    },
    "/offers/{id}/publish": {
      "post": {
        "operationId": "publishOffer",
        "summary": "publishOffer",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{7,127}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfferResponse"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "401": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "403": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "404": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "409": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "422": {
            "description": "Request rejected. JSON error has code and an optional message."
          },
          "503": {
            "description": "Request rejected. JSON error has code and an optional message."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "confirm"
                ],
                "additionalProperties": false,
                "properties": {
                  "confirm": {
                    "const": true
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
