# Prepare webhook

Prepare a webhook subscription for an administrator to review. Returns its configuration and approval URL. No subscription is activated until a person approves it.

POST https://api.brigg.app/v1/operations/webhooks.PrepareWebhook

## Access & visibility

Allow `webhooks.PrepareWebhook` on your API key.

**Workspace access by default.** Private member data requires [approved member delegation](https://developer.brigg.app/authentication#member-delegation) through `Brigg-Act-As`; the key supplies permissions while private ownership and project boundaries remain enforced.

[Set up authentication](https://developer.brigg.app/authentication) · [Choose permissions](https://developer.brigg.app/permissions)

## Request fields

Send a JSON object with the following fields. Required fields must be included; omit optional fields you do not need.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | Yes | An HTTPS endpoint on a public host. At least 1 character. At most 2048 characters. |
| `event` | string | Yes | Event name. Supported values: `meeting.completed`, `resource.created`, `resource.updated`, `resource.deleted`. See the [event reference](https://developer.brigg.app/events) for payloads and delivery contracts. At least 1 character. At most 64 characters. |
| `resource_types` | array of string | No | Explicit resource type identifiers, such as `core:Company` or a workspace app's qualified type. Discover the exact values from `resource` on the record operations returned by `GET /v1/operations` using a key with access to those records. These are resource types, not app names or operation namespaces. Required and non-empty for `resource.created`, `resource.updated` and `resource.deleted`; omit for legacy `meeting.completed`. Only selected, published shared types are included; new types are never added automatically. See [webhook resource selection](https://developer.brigg.app/webhooks#choose-resource-types). |

## Response

Returns **200 OK** with a JSON body.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `configuration` | [object](#response-configuration) | Yes | Proposed webhook settings for a person to approve in Brigg; this is not an active subscription. |
| `approval_url` | string | Yes | Path in the Brigg application where an administrator reviews this exact proposal. Open it on your Brigg application origin. Preparing a proposal does not create a subscription. |
| `message` | string | Yes | Instructions or outcome for the webhook action. |

### response.configuration

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | Yes | Absolute URL, including its scheme. |
| `event` | string | Yes | Event name. Supported values: `meeting.completed`, `resource.created`, `resource.updated`, `resource.deleted`. See the [event reference](https://developer.brigg.app/events) for payloads and delivery contracts. |
| `resource_types` | array of string | Yes | Explicit resource type identifiers, such as `core:Company` or a workspace app's qualified type. Discover the exact values from `resource` on the record operations returned by `GET /v1/operations` using a key with access to those records. These are resource types, not app names or operation namespaces. Required and non-empty for `resource.created`, `resource.updated` and `resource.deleted`; omit for legacy `meeting.completed`. Only selected, published shared types are included; new types are never added automatically. See [webhook resource selection](https://developer.brigg.app/webhooks#choose-resource-types). |

## Errors & retries

This operation reads data. It needs no idempotency key and can be retried after a transient failure.

For rate limits, follow the server’s retry guidance and back off. See [HTTP errors](https://developer.brigg.app/http#errors) and [safe retries and limits](https://developer.brigg.app/reliability).

| HTTP status | Code | What to do |
| --- | --- | --- |
| 400 | `invalid_json` | Send a JSON object with Content-Type: application/json. |
| 400 | `invalid_input` | Check the request fields and types. |
| 401 | `invalid_key` | The workspace API key is missing, invalid or revoked. |
| 403 | `forbidden` | Check the key’s operation and resource grants. If Brigg-Act-As is supplied, the key must be authorized to delegate to that member. |
| 404 | `not_found` | The requested operation or resource is not available to this credential. |
| 429 | `rate_limited` | Wait for Retry-After before retrying. |

## Next steps

- [Receive and verify webhooks](https://developer.brigg.app/webhooks)

[Download OpenAPI](https://developer.brigg.app/openapi.json) · [Versioning & retirement](https://developer.brigg.app/versioning)

## Examples

### Example request

Fictional values. Replace IDs and business details with values from your workspace.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/webhooks.PrepareWebhook' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "url": "https://example.com/webhooks/brigg",
  "event": "resource.updated",
  "resource_types": [
    "core:Company"
  ]
}'
```

#### TypeScript


```typescript
const response = await fetch("https://api.brigg.app/v1/operations/webhooks.PrepareWebhook", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "url": "https://example.com/webhooks/brigg",
    "event": "resource.updated",
    "resource_types": [
      "core:Company"
    ]
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

payload = {
  "url": "https://example.com/webhooks/brigg",
  "event": "resource.updated",
  "resource_types": [
    "core:Company"
  ]
}
request = Request(
    "https://api.brigg.app/v1/operations/webhooks.PrepareWebhook",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "configuration": {
    "url": "https://example.com/webhooks/brigg",
    "event": "resource.updated",
    "resource_types": [
      "core:Company"
    ]
  },
  "approval_url": "/settings/webhooks?webhook_proposal=%7B%22url%22%3A%22https%3A%2F%2Fexample.com%2Fwebhooks%2Fbrigg%22%2C%22event%22%3A%22resource.updated%22%2C%22resource_types%22%3A%5B%22core%3ACompany%22%5D%7D",
  "message": "Review the endpoint and resource access in Brigg Settings."
}
```

## JSON schemas


```json-schema-request
{
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048,
      "description": "An HTTPS endpoint on a public host."
    },
    "event": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Event name. Supported values: `meeting.completed`, `resource.created`, `resource.updated`, `resource.deleted`. See the [event reference](https://developer.brigg.app/events) for payloads and delivery contracts."
    },
    "resource_types": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "description": "Explicit resource type identifiers, such as `core:Company` or a workspace app's qualified type. Discover the exact values from `resource` on the record operations returned by `GET /v1/operations` using a key with access to those records. These are resource types, not app names or operation namespaces. Required and non-empty for `resource.created`, `resource.updated` and `resource.deleted`; omit for legacy `meeting.completed`. Only selected, published shared types are included; new types are never added automatically. See [webhook resource selection](https://developer.brigg.app/webhooks#choose-resource-types)."
    }
  },
  "required": [
    "url",
    "event"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "url": "https://example.com/webhooks/brigg",
      "event": "resource.updated",
      "resource_types": [
        "core:Company"
      ]
    }
  ]
}
```


```json-schema-response
{
  "type": "object",
  "properties": {
    "configuration": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "description": "Absolute URL, including its scheme."
        },
        "event": {
          "type": "string",
          "description": "Event name. Supported values: `meeting.completed`, `resource.created`, `resource.updated`, `resource.deleted`. See the [event reference](https://developer.brigg.app/events) for payloads and delivery contracts."
        },
        "resource_types": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Explicit resource type identifiers, such as `core:Company` or a workspace app's qualified type. Discover the exact values from `resource` on the record operations returned by `GET /v1/operations` using a key with access to those records. These are resource types, not app names or operation namespaces. Required and non-empty for `resource.created`, `resource.updated` and `resource.deleted`; omit for legacy `meeting.completed`. Only selected, published shared types are included; new types are never added automatically. See [webhook resource selection](https://developer.brigg.app/webhooks#choose-resource-types)."
        }
      },
      "required": [
        "url",
        "event",
        "resource_types"
      ],
      "additionalProperties": false,
      "description": "Proposed webhook settings for a person to approve in Brigg; this is not an active subscription."
    },
    "approval_url": {
      "type": "string",
      "description": "Path in the Brigg application where an administrator reviews this exact proposal. Open it on your Brigg application origin. Preparing a proposal does not create a subscription."
    },
    "message": {
      "type": "string",
      "description": "Instructions or outcome for the webhook action."
    }
  },
  "required": [
    "configuration",
    "approval_url",
    "message"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "configuration": {
        "url": "https://example.com/webhooks/brigg",
        "event": "resource.updated",
        "resource_types": [
          "core:Company"
        ]
      },
      "approval_url": "/settings/webhooks?webhook_proposal=%7B%22url%22%3A%22https%3A%2F%2Fexample.com%2Fwebhooks%2Fbrigg%22%2C%22event%22%3A%22resource.updated%22%2C%22resource_types%22%3A%5B%22core%3ACompany%22%5D%7D",
      "message": "Review the endpoint and resource access in Brigg Settings."
    }
  ]
}
```

