Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Test Webhook Endpoint

client.Webhooks.Test(ctx, webhookEndpointID, body) (*WebhookEndpointTestResult, error)
POST/webhook_endpoints/{webhook_endpoint_id}/test

Sends a sample event to a webhook endpoint for the authenticated project.

ParametersExpand Collapse
webhookEndpointID string
body WebhookTestParams
ReturnsExpand Collapse
type WebhookEndpointTestResult struct{…}
EventType string

The event type sent in the test.

Object WebhookEndpointTest

The object type, which is always webhook_endpoint.test.

StatusCode int64

The HTTP status code returned by the endpoint.

Success bool

Whether the test request completed. Always true for returned results; use status_code to determine the endpoint response.

WebhookEndpointID string

The ID of the webhook endpoint that received the test.

Test Webhook Endpoint

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
  "github.com/openai/openai-go/webhooks"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  webhookEndpointTestResult, err := client.Webhooks.Test(
    context.TODO(),
    "whe_123",
    webhooks.WebhookTestParams{
      EventType: webhooks.WebhookTestParamsEventTypeBatchCompleted,
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", webhookEndpointTestResult.WebhookEndpointID)
}
{
  "event_type": "event_type",
  "object": "webhook_endpoint.test",
  "status_code": 0,
  "success": true,
  "webhook_endpoint_id": "webhook_endpoint_id"
}
Returns Examples
{
  "event_type": "event_type",
  "object": "webhook_endpoint.test",
  "status_code": 0,
  "success": true,
  "webhook_endpoint_id": "webhook_endpoint_id"
}