{
  "openapi": "3.1.0",
  "info": {
    "title": "Blaaiz Platform API - Replay Webhook",
    "version": "1.0.0",
    "description": "Trigger (on demand) a webhook for any successful transaction (payout or collection)."
  },
  "tags": [
    {
      "name": "Webhook"
    }
  ],
  "servers": [
    {
      "url": "https://api-prod.blaaiz.com"
    },
    {
      "url": "https://api-dev.blaaiz.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "oauth2ClientCredentials": {
        "type": "oauth2",
        "description": "Use your OAuth client credentials to obtain a short-lived Bearer token from POST /oauth/token.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "/oauth/token",
            "scopes": {
              "webhook:replay": "Replay webhook deliveries."
            }
          }
        }
      }
    },
    "schemas": {
      "WebhookReplayRequest": {
        "type": "object",
        "properties": {
          "transaction_id": {
            "type": "string",
            "description": "Transaction ID to replay"
          }
        },
        "required": [
          "transaction_id"
        ]
      },
      "WebhookReplayResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ]
      }
    }
  },
  "paths": {
    "/api/external/webhook-replay": {
      "post": {
        "summary": "Replay webhook",
        "description": "Trigger a webhook on demand for a successful transaction. Required scope: `webhook:replay`.",
        "tags": [
          "Webhook"
        ],
        "security": [
          {
            "oauth2ClientCredentials": [
              "webhook:replay"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookReplayRequest"
              },
              "example": {
                "transaction_id": "fb87c0f8-31e3-46f3-b0d3-1ff2618565bc"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook replayed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookReplayResponse"
                },
                "example": {
                  "message": "Webhook replayed successfully"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Invalid or missing access token"
                }
              }
            }
          }
        }
      }
    }
  }
}