openapi: "3.1.0"
info:
  title: "Webhooks API"
  version: "1.0.0"
  description: "Webhook registration, listing, and test-event dispatch simulation Exported as an OpenAPI 3.1 document from Fake API for Devs."
servers:
  - url: "https://fakeapifordevs.vercel.app"
        description: "Fake API for Devs production endpoint"
tags:
  - name: "Webhooks"
        description: "Webhook registration, listing, and test-event dispatch simulation"
paths:
  /api/webhooks/register:
    post:
      tags:
        - "Webhooks"
      summary: "POST /api/webhooks/register"
      operationId: "webhooks_post_webhooks_register"
      parameters:
        []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: "object"
            example:
              url: "https://example.com/webhooks/fake-api"
              events:
                - "payment_intent.succeeded"
                - "invoice.payment_failed"
              secret: "whsec_mock_secret"
      responses:
        200:
          description: "Successful response"
          content:
            application/json:
              schema:
                type: "object"
        400:
          description: "Bad request"
        401:
          description: "Unauthorized"
        404:
          description: "Not found"
        429:
          description: "Rate limited"
        500:
          description: "Internal server error"
  /api/webhooks/registrations:
    get:
      tags:
        - "Webhooks"
      summary: "GET /api/webhooks/registrations"
      operationId: "webhooks_get_webhooks_registrations"
      parameters:
        - name: "page"
                    in: "query"
                    schema:
                      type: "integer"
                      minimum: 1
                      default: 1
                    description: "1-indexed page number for collection endpoints."
        - name: "per_page"
                    in: "query"
                    schema:
                      type: "integer"
                      minimum: 1
                      maximum: 50
                      default: 10
                    description: "Page size for collection endpoints."
        - name: "q"
                    in: "query"
                    schema:
                      type: "string"
                    description: "Optional text search filter where supported."
        - name: "delay"
                    in: "query"
                    schema:
                      type: "number"
                      minimum: 0
                      maximum: 10
                    description: "Optional artificial delay in seconds."
        - name: "simulate_error"
                    in: "query"
                    schema:
                      type: "string"
                      enum:
                        - "rate_limit"
                        - "server_error"
                        - "not_found"
                        - "unauthorized"
                        - "forbidden"
                        - "bad_request"
                        - "service_unavailable"
                        - "timeout"
                        - "malformed"
                    description: "Force a mock failure scenario for resilience testing."
      responses:
        200:
          description: "Successful response"
          content:
            application/json:
              schema:
                type: "object"
        400:
          description: "Bad request"
        401:
          description: "Unauthorized"
        404:
          description: "Not found"
        429:
          description: "Rate limited"
        500:
          description: "Internal server error"
  /api/webhooks/test/payment_intent.succeeded:
    post:
      tags:
        - "Webhooks"
      summary: "POST /api/webhooks/test/payment_intent.succeeded"
      operationId: "webhooks_post_webhooks_test_payment_intent_succeeded"
      parameters:
        []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: "object"
            example:
              id: "pi_mock_001"
              amount: 4999
              currency: "usd"
              customer: "cus_123"
              status: "succeeded"
      responses:
        200:
          description: "Successful response"
          content:
            application/json:
              schema:
                type: "object"
        400:
          description: "Bad request"
        401:
          description: "Unauthorized"
        404:
          description: "Not found"
        429:
          description: "Rate limited"
        500:
          description: "Internal server error"