Create a webhook subscription
Create a webhook
POSThttps://api.cuemby.io/functions/v1/webhooks
Create a webhook subscription
- This endpoint is used to create a webhook subscription for specific events in your organization or projects.
- Webhooks are scoped to a level (
organization
,project
, orenvironment
) and require areferenceId
that must exist in the corresponding scope. - You can also define entity-specific filters using
entityFilters
, allowing you to limit events to specific resource names, types, or categories.
Scopes
organization
: Applies to all projects/environments under the organization.project
: Targets events within a specific project (e.g. environments, runtimes).environment
: Focused on events within one environment (e.g. runtimes).
Entity Filters
- These allow you to filter only the events that match a particular pattern. For example:
- Filter only runtimes that start with
api-
:\{ "entity": "runtime", "name": "api-%" \}
- Only include clusters from a environment:
\{ "entity": "environment", "name": "dev" \}
- Filter only runtimes that start with
- The combination of
scope
,referenceId
,url
, andentityFilters
must be unique within an organization.
Body
- The
body
property is an optional string that uses the 'mustache' template syntax. If provided, it will be used to format the webhook payload according to the specified template. For example, when integrating with Microsoft Teams, thebody
must follow the structure required by Teams' webhook format. If thebody
property is not provided, the webhook will send the full event data as a JSON object.
Headers
Authorization
: Optional. If provided, it will be included in the webhook request headersX-Custom-Header
: Optional. If provided, it will be included in the webhook request headers
Request
Header Parameters
X-Organization-Id stringrequired
The ID of the organization (this parameter is not required when using API key authorization)
- application/json
Bodyrequired
namestringrequired
Example:
Notify Runtime Deployments
urlurirequired
Example:
https://hooks.example.com/webhook
scopestringrequired
Possible values: [project
, environment
]
Example:
project
referenceIdstringrequired
Example:
proj_abc123
eventsstring[]required
entityFilters object[]required
secretstring
If provided, events will be signed using HMAC SHA-256
Example:
whsec_abc123
bodystring
The body
property is an optional string that uses the 'mustache' template syntax. If provided, it will be used to format the webhook payload according to the specified template. For example, when integrating with Microsoft Teams, the body
must follow the structure required by Teams' webhook format. If the body
property is not provided, the webhook will send the full event data as a JSON object.
Example:
{ 'type': 'message', 'attachments': [ { 'contentType': 'application/vnd.microsoft.card.adaptive', 'content': { '$schema': 'http://adaptivecards.io/schemas/adaptive-card.json', 'type': 'AdaptiveCard', 'version': '1.2', 'body': [ { 'type': 'TextBlock', 'text': 'CuembyPlatform runtimeId: {{ Id }}, runtimeName: {{ name }}', 'weight': 'Bolder', 'size': 'Medium' }, { 'type': 'TextBlock', 'text': 'Please, to continue, review the following item with', 'wrap': true } ] } } ] }
headers object
Responses
- 200
- 400
- 404
Webhook created successfully
- application/json
- Schema
- Example (auto)
Schema
successboolean
Default value:
true
timestampstring
Default value:
2024-01-01T00:00:00.000Z
statusCodenumber
Default value:
200
statusTextstring
Default value:
Success
messagestring
Default value:
Message successfully
Example:
Webhook created successfully
localizationstring
Default value:
someone-method:success
data object
{
"success": true,
"timestamp": "2024-01-01T00:00:00.000Z",
"statusCode": 200,
"statusText": "Success",
"message": "Webhook created successfully",
"localization": "someone-method:success",
"data": {
"id": "string",
"name": "string",
"url": "string",
"scope": "string",
"referenceId": "string",
"events": [
"string"
],
"entityFilters": [
{
"entity": "runtime",
"name": "api-%",
"type": "container"
}
],
"body": "string",
"headers": {},
"active": true
}
}
Bad Request
- application/json
- Schema
- Example (auto)
Schema
successboolean
Default value:
false
dataobject
Default value:
null
timestampstring
Default value:
2024-01-01T00:00:00.000Z
statusCodenumber
Default value:
400
statusTextstring
Default value:
Bad Request
messagestring
Default value:
Message Error
localizationstring
Default value:
someone-method:error
{
"success": false,
"data": {},
"timestamp": "2024-01-01T00:00:00.000Z",
"statusCode": 400,
"statusText": "Bad Request",
"message": "Message Error",
"localization": "someone-method:error"
}
Not Found
- application/json
- Schema
- Example (auto)
Schema
successboolean
Default value:
false
dataobject
Default value:
null
timestampstring
Default value:
2024-01-01T00:00:00.000Z
statusCodenumber
Default value:
404
statusTextstring
Default value:
Not Found
messagestring
Default value:
Message Not Found
localizationstring
Default value:
someone-method:error
{
"success": false,
"data": {},
"timestamp": "2024-01-01T00:00:00.000Z",
"statusCode": 404,
"statusText": "Not Found",
"message": "Message Not Found",
"localization": "someone-method:error"
}
Authorization: x-api-key
name: x-api-keytype: apiKeyin: header
- csharp
- curl
- dart
- go
- http
- java
- javascript
- kotlin
- c
- nodejs
- objective-c
- ocaml
- php
- powershell
- python
- r
- ruby
- rust
- shell
- swift
- HTTPCLIENT
- RESTSHARP
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.cuemby.io/functions/v1/webhooks");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("x-api-key", "<x-api-key>");
var content = new StringContent("{\n \"name\": \"Notify Runtime Deployments\",\n \"url\": \"https://hooks.example.com/webhook\",\n \"scope\": \"project\",\n \"referenceId\": \"proj_abc123\",\n \"events\": [\n \"runtime.created\"\n ],\n \"entityFilters\": [\n {\n \"entity\": \"runtime\",\n \"name\": \"api-%\",\n \"type\": \"container\"\n }\n ],\n \"secret\": \"whsec_abc123\",\n \"body\": \"{ 'type': 'message', 'attachments': [ { 'contentType': 'application/vnd.microsoft.card.adaptive', 'content': { '$schema': 'http://adaptivecards.io/schemas/adaptive-card.json', 'type': 'AdaptiveCard', 'version': '1.2', 'body': [ { 'type': 'TextBlock', 'text': 'CuembyPlatform runtimeId: {{ Id }}, runtimeName: {{ name }}', 'weight': 'Bolder', 'size': 'Medium' }, { 'type': 'TextBlock', 'text': 'Please, to continue, review the following item with', 'wrap': true } ] } } ] }\",\n \"headers\": {\n \"Authorization\": \"Bearer xxxx\",\n \"X-Custom-Header\": \"value\"\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
ResponseClear