OpenAI 测试Webhook端点

2026-11-12 16:14 更新

测试 Webhook 端点

post /webhook_endpoints/{webhook_endpoint_id}/test

向当前身份验证所对应项目的 Webhook 端点发送示例事件。

路径参数

  • webhook_endpoint_id: string

要测试的 Webhook 端点的 ID。

请求体参数

内容类型:application/json

  • event_type: "batch.completed" or "batch.failed" or "batch.expired" or 24 more

作为示例投递发送的事件类型。

  • "batch.completed"

  • "batch.failed"

  • "batch.expired"

  • "batch.cancelled"

  • "response.completed"

  • "response.failed"

  • "response.cancelled"

  • "response.incomplete"

  • "eval.run.succeeded"

  • "eval.run.failed"

  • "eval.run.canceled"

  • "fine_tuning.job.succeeded"

  • "fine_tuning.job.failed"

  • "fine_tuning.job.cancelled"

  • "realtime.call.incoming"

  • "video.completed"

  • "video.failed"

  • "agent.environment.ready"

  • "agent.environment.failed"

  • "agent.environment.suspended"

  • "agent.environment.expired"

  • "agent.session.created"

  • "agent.session.action_required"

  • "agent.session.in_progress"

  • "agent.session.idle"

  • "agent.session.failed"

  • "safety.alert.created"

返回值

  • WebhookEndpointTestResult object { event_type, object, status_code, 2 more }

  • event_type: string

测试中发送的事件类型。

  • object: "webhook_endpoint.test" (default: "webhook_endpoint.test")

对象类型,始终为 webhook_endpoint.test。

  • "webhook_endpoint.test"

  • status_code: integer

端点返回的 HTTP 状态码。

  • success: true (default: true)

测试请求是否已完成。对于返回的结果,此值始终为 true;应使用 status_code 判断端点的响应情况。

  • true

  • webhook_endpoint_id: string

接收测试的 Webhook 端点的 ID。

示例

## 从环境变量读取 API 密钥;运行前替换 Webhook 端点 ID、URL 和名称占位值。
curl https://api.openai.com/v1/webhook_endpoints/$WEBHOOK_ENDPOINT_ID/test \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
          "event_type": "batch.completed"
        }'

200:示例

{
  "event_type": "event_type",
  "object": "webhook_endpoint.test",
  "status_code": 0,
  "success": true,
  "webhook_endpoint_id": "webhook_endpoint_id"
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号