{
  "openapi": "3.1.0",
  "info": {
    "title": "Throngs Bounties API",
    "version": "1.0.0",
    "description": "Public creator bounty board. Email verification is separate from post verification. Check GET email_enabled and slots_left before claiming. Actions need user authorization; private tokens must not be logged.",
    "contact": {
      "email": "teamcarirl@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://eiislegynfxcfwtlkjcf.supabase.co/functions/v1/bounty-board"
    }
  ],
  "security": [
    {
      "PublicGatewayKey": [],
      "PublicGatewayBearer": []
    }
  ],
  "paths": {
    "/": {
      "get": {
        "operationId": "listBounties",
        "summary": "Read live bounty terms, remaining slots and email readiness",
        "responses": {
          "200": {
            "description": "Live board",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "bounties",
                    "email_enabled"
                  ],
                  "properties": {
                    "email_enabled": {
                      "type": "boolean"
                    },
                    "bounties": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "brand": {
                            "type": "string"
                          },
                          "brief": {
                            "type": "string"
                          },
                          "reward_cents": {
                            "type": "integer",
                            "description": "Maximum reward in USD cents"
                          },
                          "reward_base_cents": {
                            "type": "integer"
                          },
                          "reward_per_1000_cents": {
                            "type": "integer"
                          },
                          "target_views": {
                            "type": "integer"
                          },
                          "slots": {
                            "type": "integer",
                            "description": "Lifetime payout cap per bounty"
                          },
                          "slots_left": {
                            "type": "integer",
                            "description": "Rewards not yet approved or paid. Earlier pending eligible proofs may consume this capacity; no guarantee."
                          },
                          "pending_submissions": {
                            "type": "integer"
                          },
                          "priority": {
                            "type": "string",
                            "const": "eligible_proof_received"
                          },
                          "terms_version": {
                            "type": "string"
                          },
                          "reservation_hours": {
                            "type": "integer",
                            "description": "Submission link lifetime; not an exclusive reward reservation."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "performBountyAction",
        "summary": "Request listing, verify or manage a claim, submit proof",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "terms_accepted",
                      "terms_version",
                      "email",
                      "brand",
                      "title",
                      "website",
                      "brief",
                      "reward",
                      "target_views",
                      "slots"
                    ],
                    "additionalProperties": false,
                    "description": "Submit a private listing request for manual approval. Reward is USD per video. Publication does not happen automatically.",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "request"
                      },
                      "terms_accepted": {
                        "type": "boolean",
                        "const": true,
                        "description": "Only true after the user affirmatively accepts /terms.html."
                      },
                      "terms_version": {
                        "type": "string",
                        "const": "2026-10-10-v1"
                      },
                      "email": {
                        "type": "string",
                        "format": "email",
                        "maxLength": 254
                      },
                      "brand": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "title": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "website": {
                        "type": "string",
                        "format": "uri",
                        "pattern": "^https://",
                        "maxLength": 500
                      },
                      "brief": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 3000
                      },
                      "reward": {
                        "type": "number",
                        "minimum": 1,
                        "maximum": 10000
                      },
                      "target_views": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000000
                      },
                      "slots": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 100
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "terms_accepted",
                      "terms_version",
                      "email",
                      "bounty_id"
                    ],
                    "additionalProperties": false,
                    "description": "Request an email verification link. Only use after the user authorizes the verification email. Fails with 503 when email_enabled is false. Never reserves a payout slot. Requires explicit acceptance of the current bounty terms.",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "claim"
                      },
                      "terms_accepted": {
                        "type": "boolean",
                        "const": true,
                        "description": "Only true after the user affirmatively accepts /terms.html."
                      },
                      "terms_version": {
                        "type": "string",
                        "const": "2026-10-10-v1"
                      },
                      "email": {
                        "type": "string",
                        "format": "email",
                        "maxLength": 254
                      },
                      "bounty_id": {
                        "type": "string",
                        "format": "uuid"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "token"
                    ],
                    "additionalProperties": false,
                    "description": "Consume a verification token received in the user inbox and receive a private proof submission link without reserving a payout. Returns private manage_token.",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "verify"
                      },
                      "token": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "token"
                    ],
                    "additionalProperties": false,
                    "description": "Read a claim using its private management token.",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "get_claim"
                      },
                      "token": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "action",
                      "terms_accepted",
                      "terms_version",
                      "token",
                      "post_url",
                      "reported_views"
                    ],
                    "additionalProperties": false,
                    "description": "Submit a social post and reported views for manual review using its private management token. Never trust reported views as verified views.",
                    "properties": {
                      "action": {
                        "type": "string",
                        "const": "submit"
                      },
                      "terms_accepted": {
                        "type": "boolean",
                        "const": true,
                        "description": "Only true after the user affirmatively accepts /terms.html."
                      },
                      "terms_version": {
                        "type": "string",
                        "const": "2026-10-10-v1"
                      },
                      "token": {
                        "type": "string",
                        "pattern": "^[a-f0-9]{64}$"
                      },
                      "post_url": {
                        "type": "string",
                        "format": "uri",
                        "pattern": "^https://",
                        "maxLength": 500
                      },
                      "reported_views": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000000
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Action succeeded. claim sends an email only; verify returns manage_token. get_claim and submit return claim and bounty."
          },
          "400": {
            "description": "Validation, capacity, expired token or rate limit failure; JSON error field."
          },
          "413": {
            "description": "Body too large; maximum 16,000 characters."
          },
          "503": {
            "description": "Claim email verification is unavailable or delivery failed. Do not report successful reservation."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "PublicGatewayKey": {
        "type": "apiKey",
        "in": "header",
        "name": "apikey",
        "description": "Public anon gateway key documented at /agents.html; not a secret and does not provide direct database access."
      },
      "PublicGatewayBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Use the same public gateway key as bearer token."
      }
    }
  }
}
