# Create webhook

```http
POST /projects/{project_reference}/webhooks
```

Create a webhook when an external service must start an agent, task or workflow run, or when its deliveries must only be stored as webhook events; returns the webhook and its secret, which is shown only once. Requires project.agents.write.

## Parameters

| Name                | In   | Required | Description |
| ------------------- | ---- | -------- | ----------- |
| `project_reference` | path | Yes      |             |

## Request body

| Field             | Type        | Required | Description                                                                                       |
| ----------------- | ----------- | -------- | ------------------------------------------------------------------------------------------------- |
| `name`            | string      | Yes      | Webhook name, 1-120 characters.                                                                   |
| `target`          | object      | Yes      | Target invoked by a webhook definition.                                                           |
| `prompt_template` | string      |          | Prompt template for run targets: required unless target.kind is event, where it is not supported. |
| `event_filter`    | object,null |          | Optional incoming event filter. Missing, null, or empty conditions accept every event.            |

## Responses

| Status | Description                                                                                                |
| ------ | ---------------------------------------------------------------------------------------------------------- |
| 201    | Created webhook                                                                                            |
| 400    | invalid\_input: invalid body or parameters                                                                 |
| 401    | unauthenticated                                                                                            |
| 403    | forbidden: a project member without the required capability                                                |
| 404    | not\_found: project or webhook not found or not visible                                                    |
| 500    | internal                                                                                                   |
| 503    | internal: authentication state is temporarily unavailable and the request was not processed; retry shortly |
