Webhooks
Jump to:
This endpoint is used to obtain an Access Token using the Client Credentials Grant flow. This flow is typically used for machine-to-machine (M2M) communication where a specific user’s consent is not required, and the client application is acting on its own behalf.
Create webhook
This endpoint registers a new webhook subscription for a specific namespace. By creating a webhook, your system can receive real-time HTTP callbacks (POST requests) whenever a specific action (e.g., creation) occurs on a specific resource type (e.g., case) within that namespace.
Request specification
Method: POST (Implied by the presence of a JSON payload)
URL: http://localhost:8080/apis/v1/namespaces/{namespace}/webhook
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
namespace | String | Yes | The unique identifier of the namespace where the webhook will be registered (e.g., 142033). |
Headers
| Header | Value | Required | Description |
|---|---|---|---|
Authorization | Bearer <TOKEN> | Yes | A valid OAuth2 or API Bearer token for authentication. |
Content-Type | application/json | Yes | Indicates that the request body is formatted as JSON. |
Body parameters
The request body defines the configuration of the webhook subscription.
| Field | Type | Required | Description |
|---|---|---|---|
kind | String | Yes | The type of resource being created. Must be set to "webhook". |
version | String | Yes | The API version for the webhook definition (e.g., "v1"). |
namespace | String | Yes | The namespace ID. This usually matches the path parameter. |
name | String | Yes | A unique, user-defined name for this specific webhook configuration (e.g., "case-v1alpha-create"). |
metadata | Object | No | A key-value map for optional custom data or labels. |
spec | Object | Yes | The specification object detailing the trigger conditions and destination. |
url | String | Yes | The destination URL (endpoint) where the event payload will be sent. |
version | String | Yes | The version of the resource you want to monitor (e.g., "v1alpha"). |
kind | String | Yes | The specific resource type to monitor (e.g., "case"). |
action | String | Yes | The specific lifecycle event that triggers the webhook (e.g., "create", "update", "delete"). |
Example usage
Request
curl --location --request POST 'http://localhost:8080/apis/v1/namespaces/142033/webhook' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
--data '{
"kind": "webhook",
"version": "v1",
"namespace": "2135",
"name": "case-v1alpha-create",
"metadata": {},
"spec": {
"url": "https://eojn4d67eio97gx.m.pipedream.net",
"version": "v1alpha",
"kind": "case",
"action": "create"
}
}'
Trigger logic
Based on the example payload provided:
- Trigger: A new
"case"resource (versionv1alpha) is created. - Action: The system sends a POST request containing the event details to
https://eojn4d67eio97gx.m.pipedream.net.