openapi: 3.0.3
info:
  title: Rondo Developer API (Public Surface)
  version: v1
  description: |
    Consolidated public/partner-facing API spec for Rondo developer docs.
    Server base is set to dev.
servers:
  - url: https://dev.playrondo.com/api
    description: Rondo Dev API
tags:
  - name: Embed
  - name: Facility Public
  - name: API Keys
  - name: Auth
  - name: Password Reset
  - name: Email Verification
  - name: Public Utility
  - name: Webhooks
security:
  - RondoApiKey: []
  - XApiKey: []
paths:
  /embed/contract/v1:
    get:
      tags: [Embed]
      summary: Get embed v1 contract index
      responses:
        '200':
          description: Contract index
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/contract/v1/openapi:
    get:
      tags: [Embed]
      summary: Get embed v1 OpenAPI document
      responses:
        '200':
          description: OpenAPI JSON
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/sdk/bootstrap:
    get:
      tags: [Embed]
      summary: Get signed embed SDK bootstrap config
      parameters:
        - in: query
          name: view
          schema: { type: string }
        - in: query
          name: theme
          schema: { type: string, enum: [light, dark, auto] }
        - in: query
          name: accent
          schema: { type: string, example: '#16a34a' }
        - in: query
          name: modules
          schema: { type: string, example: 'seasons,schedule,standings,pickups' }
      responses:
        '200':
          description: Signed config payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
        '503':
          $ref: '#/components/responses/FeatureFlagOff'
  /embed/auth/handoff:
    post:
      tags: [Embed]
      summary: Resolve end-user identity for embed context
      security:
        - RondoApiKey: []
          EndUserToken: []
      responses:
        '200':
          description: User handoff context
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/leagues:
    get:
      tags: [Embed]
      summary: List leagues in API key scope
      responses:
        '200':
          description: Leagues list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
  /embed/leagues/{leagueId}/divisions:
    get:
      tags: [Embed]
      summary: List divisions for a league in scope
      parameters:
        - $ref: '#/components/parameters/LeagueId'
      responses:
        '200':
          description: Division list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
  /embed/divisions/{divisionId}/seasons:
    get:
      tags: [Embed]
      summary: List seasons for a division in scope
      parameters:
        - $ref: '#/components/parameters/DivisionId'
      responses:
        '200':
          description: Season list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
  /embed/seasons:
    get:
      tags: [Embed]
      summary: List seasons in API key scope
      responses:
        '200':
          description: Seasons list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
  /embed/seasons/{seasonId}/schedule:
    get:
      tags: [Embed]
      summary: Get season schedule (matches)
      parameters:
        - $ref: '#/components/parameters/SeasonId'
      responses:
        '200':
          description: Season and matches
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/seasons/{seasonId}/standings:
    get:
      tags: [Embed]
      summary: Get season standings
      parameters:
        - $ref: '#/components/parameters/SeasonId'
      responses:
        '200':
          description: Season and standings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/seasons/{seasonId}/teams:
    get:
      tags: [Embed]
      summary: Get season teams and roster data
      parameters:
        - $ref: '#/components/parameters/SeasonId'
      responses:
        '200':
          description: Team entries
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
  /embed/tournaments:
    get:
      tags: [Embed]
      summary: List tournaments in API key scope
      responses:
        '200':
          description: Tournament list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
  /embed/tournaments/{tournamentId}/bracket:
    get:
      tags: [Embed]
      summary: Get tournament bracket rounds
      parameters:
        - $ref: '#/components/parameters/TournamentId'
      responses:
        '200':
          description: Tournament bracket
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/sessions:
    get:
      tags: [Embed]
      summary: List pickup sessions in scope
      responses:
        '200':
          description: Session list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
  /embed/config:
    get:
      tags: [Embed]
      summary: Get embed runtime config
      responses:
        '200':
          description: Config payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/facilities:
    get:
      tags: [Embed]
      summary: List facilities in API key scope
      responses:
        '200':
          description: Facilities payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/facilities/{facilityId}/availability:
    post:
      tags: [Embed]
      summary: Get facility availability for date range
      parameters:
        - $ref: '#/components/parameters/FacilityId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AvailabilityRequest'
      responses:
        '200':
          description: Availability payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/actions/facilities/{facilityId}/book:
    post:
      tags: [Embed]
      summary: Create facility booking request from embed flow
      parameters:
        - $ref: '#/components/parameters/FacilityId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbedFacilityBookRequest'
      responses:
        '200':
          description: Booking action response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/analytics/events:
    post:
      tags: [Embed]
      summary: Ingest embed telemetry event
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbedAnalyticsEventRequest'
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                type: object
                properties:
                  accepted: { type: boolean }
        '503':
          $ref: '#/components/responses/FeatureFlagOff'
  /embed/analytics/summary:
    get:
      tags: [Embed]
      summary: Get telemetry summary for current API key
      responses:
        '200':
          description: Summary payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
        '503':
          $ref: '#/components/responses/FeatureFlagOff'
  /embed/me/registrations:
    get:
      tags: [Embed]
      summary: Get current end-user registrations in embed scope
      security:
        - RondoApiKey: []
          EndUserToken: []
      responses:
        '200':
          description: Registration payload
          content:
            application/json:
              schema:
                type: object
                properties:
                  leagueRegistrations:
                    type: array
                    items: { $ref: '#/components/schemas/GenericObject' }
                  sessionRegistrations:
                    type: array
                    items: { $ref: '#/components/schemas/GenericObject' }
  /embed/me/profile:
    get:
      tags: [Embed]
      summary: Get current end-user profile in embed context
      security:
        - RondoApiKey: []
          EndUserToken: []
      responses:
        '200':
          description: Profile payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/me/payments:
    get:
      tags: [Embed]
      summary: Get current end-user payment history in embed context
      security:
        - RondoApiKey: []
          EndUserToken: []
      responses:
        '200':
          description: Payment payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericObject'
  /embed/actions/sessions/{sessionId}/join:
    post:
      tags: [Embed]
      summary: Join a session
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SessionId'
      requestBody:
        required: false
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/sessions/{sessionId}/pay:
    post:
      tags: [Embed]
      summary: Pay for a session
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SessionId'
      requestBody:
        required: false
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/seasons/{seasonId}/signup-individual:
    post:
      tags: [Embed]
      summary: Sign up end-user as season free agent
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SeasonId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/seasons/{seasonId}/signup-team:
    post:
      tags: [Embed]
      summary: Sign up team to season
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SeasonId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/seasons/{seasonId}/pay-individual:
    post:
      tags: [Embed]
      summary: Pay season individual fee
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SeasonId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/seasons/{seasonId}/pay:
    post:
      tags: [Embed]
      summary: Pay season team/entry fee
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SeasonId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/tournaments/{tournamentId}/signup-team:
    post:
      tags: [Embed]
      summary: Sign up team to tournament
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/TournamentId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/tournaments/{tournamentId}/pay:
    post:
      tags: [Embed]
      summary: Pay tournament fee
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/TournamentId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/organizer/sessions/{sessionId}/waitlist/{userId}/promote:
    post:
      tags: [Embed]
      summary: Promote user from waitlist (organizer)
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SessionId'
        - $ref: '#/components/parameters/UserId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/organizer/sessions/{sessionId}/waitlist/{userId}/reject:
    post:
      tags: [Embed]
      summary: Reject user from waitlist (organizer)
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SessionId'
        - $ref: '#/components/parameters/UserId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/host/sessions:
    post:
      tags: [Embed]
      summary: Create session as API key owner context
      security:
        - RondoApiKey: []
          EndUserToken: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/host/sessions/{sessionId}:
    put:
      tags: [Embed]
      summary: Update session as API key owner context
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SessionId'
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }
  /embed/actions/host/sessions/{sessionId}/cancel:
    post:
      tags: [Embed]
      summary: Cancel session as API key owner context
      security:
        - RondoApiKey: []
          EndUserToken: []
      parameters:
        - $ref: '#/components/parameters/SessionId'
      responses:
        '200': { $ref: '#/components/responses/ActionResponse' }

  /dashboard/runtime-config:
    get:
      tags: [Facility Public]
      summary: Get runtime frontend config
      security: []
      responses:
        '200':
          description: Runtime config
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /dashboard/public/facilities:
    get:
      tags: [Facility Public]
      summary: List approved public facilities
      security: []
      parameters:
        - in: query
          name: city
          schema: { type: string }
        - in: query
          name: state
          schema: { type: string }
        - in: query
          name: search
          schema: { type: string }
      responses:
        '200':
          description: Facilities list
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /dashboard/public/facilities/{facilityId}/availability:
    post:
      tags: [Facility Public]
      summary: Get public facility availability
      security: []
      parameters:
        - $ref: '#/components/parameters/FacilityId'
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/AvailabilityRequest' }
      responses:
        '200':
          description: Availability payload
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /dashboard/public/facilities/{facilityId}/book:
    post:
      tags: [Facility Public]
      summary: Create public booking request (legacy widget endpoint)
      security: []
      parameters:
        - $ref: '#/components/parameters/FacilityId'
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/EmbedFacilityBookRequest' }
      responses:
        '201':
          description: Booking created
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /dashboard/public/facilities/{facilityId}/bookings:
    post:
      tags: [Facility Public]
      summary: Create public inline booking request (API key protected)
      security:
        - XApiKey: []
        - RondoApiKey: []
      parameters:
        - $ref: '#/components/parameters/FacilityId'
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/PublicInlineBookingRequest' }
      responses:
        '201':
          description: Booking request accepted
          content:
            application/json:
              schema: { $ref: '#/components/schemas/PublicInlineBookingResponse' }
        '409':
          description: Slot conflict
          content:
            application/json:
              schema: { $ref: '#/components/schemas/ErrorResponse' }
        '503':
          $ref: '#/components/responses/FeatureFlagOff'
  /dashboard/public/payments/config:
    get:
      tags: [Facility Public]
      summary: Get payment publishable config for public widgets
      security: []
      responses:
        '200':
          description: Payment config
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }

  /api-keys:
    get:
      tags: [API Keys]
      summary: List API keys for authenticated account
      security:
        - BearerAuth: []
      responses:
        '200':
          description: API key list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
    post:
      tags: [API Keys]
      summary: Create API key
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/CreateApiKeyRequest' }
      responses:
        '201':
          description: API key created (full key returned once)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /api-keys/{id}:
    put:
      tags: [API Keys]
      summary: Update API key metadata/scopes/status
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ApiKeyId'
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200':
          description: Updated key
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
    delete:
      tags: [API Keys]
      summary: Delete API key
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ApiKeyId'
      responses:
        '200':
          description: Delete result
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /api-keys/{id}/rotate:
    post:
      tags: [API Keys]
      summary: Rotate API key secret
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/ApiKeyId'
      responses:
        '200':
          description: Rotated key (full key returned once)
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }

  /auth/check-email:
    get:
      tags: [Auth]
      summary: Check email availability
      security: []
      parameters:
        - in: query
          name: email
          required: true
          schema: { type: string, format: email }
      responses:
        '200':
          description: Availability result
          content:
            application/json:
              schema:
                type: object
                properties:
                  available: { type: boolean }
                  msg: { type: string }
  /auth/check-phone:
    get:
      tags: [Auth]
      summary: Check phone availability
      security: []
      parameters:
        - in: query
          name: phone
          required: true
          schema: { type: string }
      responses:
        '200':
          description: Availability result
          content:
            application/json:
              schema:
                type: object
                properties:
                  available: { type: boolean }
                  msg: { type: string }
  /auth/register:
    post:
      tags: [Auth]
      summary: Register account
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/RegisterRequest' }
      responses:
        '200':
          description: Registration result
          content:
            application/json:
              schema: { $ref: '#/components/schemas/AuthResponse' }
  /auth/login:
    post:
      tags: [Auth]
      summary: Login with email and password
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/LoginRequest' }
      responses:
        '200':
          description: Authenticated
          content:
            application/json:
              schema: { $ref: '#/components/schemas/AuthResponse' }
  /auth/firebase-login:
    post:
      tags: [Auth]
      summary: Login/signup via Firebase ID token
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [idToken]
              properties:
                idToken: { type: string }
                latitude: { type: number }
                longitude: { type: number }
      responses:
        '200':
          description: Authenticated
          content:
            application/json:
              schema: { $ref: '#/components/schemas/AuthResponse' }
  /auth/refresh:
    post:
      tags: [Auth]
      summary: Refresh JWT access token
      security:
        - BearerAuth: []
      responses:
        '200':
          description: Refreshed token
          content:
            application/json:
              schema: { $ref: '#/components/schemas/AuthResponse' }
  /auth/test:
    get:
      tags: [Auth]
      summary: Auth route health check
      security: []
      responses:
        '200':
          description: Service health payload
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }

  /password-reset/send-reset-email:
    post:
      tags: [Password Reset]
      summary: Send password reset email
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email]
              properties:
                email: { type: string, format: email }
      responses:
        '200':
          description: Request accepted
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /password-reset/verify-token/{token}:
    get:
      tags: [Password Reset]
      summary: Verify password reset token
      security: []
      parameters:
        - in: path
          name: token
          required: true
          schema: { type: string }
      responses:
        '200':
          description: Token validity payload
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /password-reset/reset-password:
    post:
      tags: [Password Reset]
      summary: Reset password using token
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [token, password]
              properties:
                token: { type: string }
                password: { type: string }
      responses:
        '200':
          description: Password reset success
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }

  /email-verification/send-verification-email:
    post:
      tags: [Email Verification]
      summary: Send email verification message
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email]
              properties:
                email: { type: string, format: email }
      responses:
        '200':
          description: Verification request accepted
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /email-verification/verify-email:
    post:
      tags: [Email Verification]
      summary: Verify email using token/code payload
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200':
          description: Verification result
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /email-verification/check-verification/{email}:
    get:
      tags: [Email Verification]
      summary: Check verification status by email
      security: []
      parameters:
        - in: path
          name: email
          required: true
          schema: { type: string }
      responses:
        '200':
          description: Verification status
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }

  /contact:
    post:
      tags: [Public Utility]
      summary: Submit contact form request
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name, email, type, message]
              properties:
                name: { type: string }
                email: { type: string, format: email }
                type: { type: string }
                message: { type: string }
      responses:
        '200':
          description: Contact request accepted
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /closed-beta/apply:
    post:
      tags: [Public Utility]
      summary: Submit closed beta application
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200':
          description: Application accepted
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /app-config/mobile-update:
    get:
      tags: [Public Utility]
      summary: Get mobile app update policy/config
      security: []
      responses:
        '200':
          description: Mobile update config
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /waivers/file/{filename}:
    get:
      tags: [Public Utility]
      summary: Download waiver file by filename
      security: []
      parameters:
        - in: path
          name: filename
          required: true
          schema: { type: string }
      responses:
        '200':
          description: Waiver file binary
          content:
            application/pdf:
              schema:
                type: string
                format: binary

  /dashboard/facilities/{facilityId}/webhooks:
    get:
      tags: [Webhooks]
      summary: List outbound webhooks for facility
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/FacilityId'
      responses:
        '200':
          description: Webhook list
          content:
            application/json:
              schema:
                type: array
                items: { $ref: '#/components/schemas/GenericObject' }
    post:
      tags: [Webhooks]
      summary: Create outbound webhook for facility
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/FacilityId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [url]
              properties:
                url: { type: string, format: uri }
                events:
                  type: array
                  items: { type: string }
      responses:
        '201':
          description: Webhook created
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /dashboard/facilities/webhooks/{webhookId}:
    put:
      tags: [Webhooks]
      summary: Update outbound webhook
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/WebhookId'
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/GenericObject' }
      responses:
        '200':
          description: Webhook updated
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
    delete:
      tags: [Webhooks]
      summary: Delete outbound webhook
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/WebhookId'
      responses:
        '200':
          description: Webhook deleted
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }
  /dashboard/facilities/webhooks/{webhookId}/test:
    post:
      tags: [Webhooks]
      summary: Send test event to outbound webhook
      security:
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/WebhookId'
      responses:
        '200':
          description: Test delivery result
          content:
            application/json:
              schema: { $ref: '#/components/schemas/GenericObject' }

components:
  parameters:
    ApiKeyId:
      in: path
      name: id
      required: true
      schema: { type: integer, minimum: 1 }
    LeagueId:
      in: path
      name: leagueId
      required: true
      schema: { type: integer, minimum: 1 }
    DivisionId:
      in: path
      name: divisionId
      required: true
      schema: { type: integer, minimum: 1 }
    SeasonId:
      in: path
      name: seasonId
      required: true
      schema: { type: integer, minimum: 1 }
    SessionId:
      in: path
      name: sessionId
      required: true
      schema: { type: integer, minimum: 1 }
    FacilityId:
      in: path
      name: facilityId
      required: true
      schema: { type: integer, minimum: 1 }
    UserId:
      in: path
      name: userId
      required: true
      schema: { type: integer, minimum: 1 }
    TournamentId:
      in: path
      name: tournamentId
      required: true
      schema: { type: integer, minimum: 1 }
    WebhookId:
      in: path
      name: webhookId
      required: true
      schema: { type: integer, minimum: 1 }
  responses:
    ActionResponse:
      description: Action endpoint response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GenericObject'
    FeatureFlagOff:
      description: Feature is disabled
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    RondoApiKey:
      type: apiKey
      in: header
      name: X-Rondo-Api-Key
      description: API key (`rk_...` or `fac_...`)
    XApiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Alternate API key header (`rk_...` or `fac_...`)
    EndUserToken:
      type: apiKey
      in: header
      name: X-Rondo-User-Token
      description: End-user JWT for embed interactive endpoints
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    GenericObject:
      type: object
      additionalProperties: true
    ErrorResponse:
      type: object
      properties:
        error: { type: string }
        code: { type: string }
        details:
          type: array
          items: { $ref: '#/components/schemas/GenericObject' }
    LoginRequest:
      type: object
      required: [email, password]
      properties:
        email: { type: string, format: email }
        password: { type: string }
    RegisterRequest:
      type: object
      required: [name, email, password]
      properties:
        name: { type: string }
        email: { type: string, format: email }
        password: { type: string }
        role: { type: string }
        phoneNumber: { type: string }
        betaCode: { type: string }
    AuthResponse:
      type: object
      properties:
        token: { type: string }
        user: { $ref: '#/components/schemas/GenericObject' }
    CreateApiKeyRequest:
      type: object
      required: [name]
      properties:
        name: { type: string }
        allowedOrigins:
          type: array
          items: { type: string }
        scopes:
          type: object
          properties:
            leagueIds:
              type: array
              items: { type: integer }
            facilityIds:
              type: array
              items: { type: integer }
        expiresAt:
          type: string
          format: date-time
    AvailabilityRequest:
      type: object
      required: [startDate, endDate]
      properties:
        startDate: { type: string, format: date-time }
        endDate: { type: string, format: date-time }
        fieldIds:
          type: array
          items: { type: integer }
        durationMinutes: { type: integer, minimum: 1 }
    EmbedFacilityBookRequest:
      type: object
      required: [fieldId, start, end, email]
      properties:
        fieldId: { type: integer }
        start: { type: string, format: date-time }
        end: { type: string, format: date-time }
        email: { type: string, format: email }
        name: { type: string }
        phone: { type: string }
        notes: { type: string }
    PublicInlineBookingRequest:
      type: object
      required:
        [fieldId, startsAt, endsAt, customerName, customerEmail, customerPhone]
      properties:
        fieldId: { type: integer }
        startsAt: { type: string, format: date-time }
        endsAt: { type: string, format: date-time }
        customerName: { type: string }
        customerEmail: { type: string, format: email }
        customerPhone: { type: string }
        notes: { type: string, nullable: true }
    PublicInlineBookingResponse:
      type: object
      properties:
        bookingId: { type: integer }
        status: { type: string, example: pending }
        startsAt: { type: string, format: date-time }
        endsAt: { type: string, format: date-time }
        fieldId: { type: integer }
    EmbedAnalyticsEventRequest:
      type: object
      required: [eventName]
      properties:
        eventName: { type: string }
        route: { type: string }
        value: { type: number }
        metadata:
          type: object
          additionalProperties: true
        userId: { type: integer }
        occurredAt: { type: string, format: date-time }
