# createWebhook

```graphql
mutation CreateWebhook($input: CreateWebhookInput!) {
  createWebhook(input: $input) {
    webhook {
      id
      projectId
      name
      source
      promptTemplate
      status
      runtimeTargetKind
      runtimeTargetEnvironmentId
      runtimeTargetBranchId
      definitionSource
      sourceTriggerId
      sourcePath
      sourceHash
      ingressId
      webhookUrl
      createdByUserId
      enabledAt
      disabledAt
      disabledReason
      createdAt
      updatedAt
    }
    webhookSecret
  }
}
```

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.

## Arguments

| Name                     | Type                    | Required | Description |
| ------------------------ | ----------------------- | -------- | ----------- |
| `input`                  | CreateWebhookInput!     | Yes      |             |
| `input.projectReference` | String                  |          |             |
| `input.name`             | String!                 | Yes      |             |
| `input.target`           | WebhookTargetInput!     | Yes      |             |
| `input.promptTemplate`   | String                  |          |             |
| `input.eventFilter`      | WebhookEventFilterInput |          |             |

## Variables

```json
{
  "input": {
    "name": "string",
    "target": {
      "kind": "agent",
      "id": "string"
    }
  }
}
```

## Responses

| Status | Description                                      |
| ------ | ------------------------------------------------ |
| 200    | The CreateWebhookPayload! in data.createWebhook. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation CreateWebhook($input: CreateWebhookInput!) {\n  createWebhook(input: $input) {\n    webhook {\n      id\n      projectId\n      name\n      source\n      promptTemplate\n      status\n      runtimeTargetKind\n      runtimeTargetEnvironmentId\n      runtimeTargetBranchId\n      definitionSource\n      sourceTriggerId\n      sourcePath\n      sourceHash\n      ingressId\n      webhookUrl\n      createdByUserId\n      enabledAt\n      disabledAt\n      disabledReason\n      createdAt\n      updatedAt\n    }\n    webhookSecret\n  }\n}",
  "variables": {
    "input": {
      "name": "string",
      "target": {
        "kind": "agent",
        "id": "string"
      }
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createWebhook": {
      "webhook": {
        "id": "string",
        "projectId": "string",
        "name": "string",
        "source": "string",
        "promptTemplate": "string",
        "status": "draft",
        "runtimeTargetKind": "string",
        "runtimeTargetEnvironmentId": "string",
        "runtimeTargetBranchId": "string",
        "definitionSource": "string",
        "sourceTriggerId": "string",
        "sourcePath": "string",
        "sourceHash": "string",
        "ingressId": "string",
        "webhookUrl": "https://example.com",
        "createdByUserId": "string",
        "enabledAt": "string",
        "disabledAt": "string",
        "disabledReason": "string",
        "createdAt": "string",
        "updatedAt": "string"
      },
      "webhookSecret": "string"
    }
  }
}
```
