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

Create Webhook Endpoint

client.Webhooks.New(ctx, body) (*WebhookEndpointWithSecret, error)
POST/webhook_endpoints

Creates a webhook endpoint for the authenticated project.

ParametersExpand Collapse
body WebhookNewParams
EventTypes param.Field[[]string]

The event types that trigger deliveries to this endpoint.

Name param.Field[string]

A human-readable name for the webhook endpoint.

minLength1
maxLength256
URL param.Field[string]

The HTTPS URL that receives webhook deliveries.

maxLength2048
ReturnsExpand Collapse
type WebhookEndpointWithSecret struct{…}
ID string

The unique ID of the webhook endpoint.

CreatedAt int64

The Unix timestamp when the endpoint was created.

formatunixtime
EventTypes []string

The event types that trigger deliveries to this endpoint.

Name string

The human-readable name of the endpoint.

Object WebhookEndpoint

The object type, which is always webhook_endpoint.

SigningSecret string

The endpoint’s signing secret. This is returned only when the endpoint is created or the secret is rotated.

SigningSecretHint string

A masked hint for the endpoint’s signing secret.

URL string

The HTTPS URL that receives webhook deliveries.

UpdatedAt int64Optional

The Unix timestamp of the last endpoint configuration or signing-secret change. Initialized at creation; tests and unchanged updates do not advance it.

formatunixtime

Create 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"),
  )
  webhookEndpointWithSecret, err := client.Webhooks.New(context.TODO(), webhooks.WebhookNewParams{
    EventTypes: []string{"batch.completed"},
    Name: "x",
    URL: "https://",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", webhookEndpointWithSecret.ID)
}
{
  "id": "id",
  "created_at": 0,
  "event_types": [
    "string"
  ],
  "name": "name",
  "object": "webhook_endpoint",
  "signing_secret": "signing_secret",
  "signing_secret_hint": "signing_secret_hint",
  "url": "url",
  "updated_at": 0
}
Returns Examples
{
  "id": "id",
  "created_at": 0,
  "event_types": [
    "string"
  ],
  "name": "name",
  "object": "webhook_endpoint",
  "signing_secret": "signing_secret",
  "signing_secret_hint": "signing_secret_hint",
  "url": "url",
  "updated_at": 0
}