---
title: "Create a webhook"
method: POST
path: "/organizations/{organization}/databases/{database}/webhooks"
tags: ["Webhooks"]
---

# Create a webhook

`POST /organizations/{organization}/databases/{database}/webhooks`

### Authorization
A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:

**Service Token Accesses**
 `write_database`

**OAuth Scopes**

 | Resource | Scopes |
| :------- | :---------- |
| Organization | `write_databases` |
| Database | `write_database` |

## Path parameters

- `organization` string, required
- `database` string, required

## Request body

- object
  - `url` string, required — The URL the webhook will send events to
  - `enabled` boolean — Whether the webhook should be enabled
  - `events` string[] — The events this webhook should subscribe to

## Response `201`

Returns the created webhook

- object
  - `id` string, required — The ID of the webhook
  - `url` string, required — The URL the webhook will send events to
  - `secret` string, required — The secret used to sign the webhook payloads
  - `enabled` boolean, required — Whether the webhook is enabled
  - `last_sent_result` string, required — The last result sent by the webhook
  - `last_sent_success` boolean, required — Whether the last sent was successful
  - `last_sent_at` string, required — When the last event was sent
  - `created_at` string, required — When the webhook was created
  - `updated_at` string, required — When the webhook was updated
  - `events` string[], required — The events this webhook subscribes to

## Other responses

- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `500` — Internal Server Error

---

[API](https://skmtc.dev/planetscale/apis/planetscale-api.md) · [All operations](https://skmtc.dev/planetscale/apis/planetscale-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/planetscale/planetscale-api/revisions/5e881928d77a/schema)
