JavaScript
import Cerca from '@cerca-dev/sdk';
const client = new Cerca({
apiKey: process.env['CERCA_API_KEY'], // This is the default and can be omitted
});
const webhookSubscriptionCreated = await client.webhooks.create('fleet_abc123', {
url: 'https://example.com/webhook',
});
console.log(webhookSubscriptionCreated.id);import os
from cerca import Cerca
client = Cerca(
api_key=os.environ.get("CERCA_API_KEY"), # This is the default and can be omitted
)
webhook_subscription_created = client.webhooks.create(
fleet_id="fleet_abc123",
url="https://example.com/webhook",
)
print(webhook_subscription_created.id)package main
import (
"context"
"fmt"
"github.com/matrices/cerca-go"
"github.com/matrices/cerca-go/option"
)
func main() {
client := cercago.NewClient(
option.WithAPIKey("My API Key"),
)
webhookSubscriptionCreated, err := client.Webhooks.New(
context.TODO(),
"fleet_abc123",
cercago.WebhookNewParams{
URL: cercago.F("https://example.com/webhook"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", webhookSubscriptionCreated.ID)
}
require "cerca"
cerca = Cerca::Client.new(api_key: "My API Key")
webhook_subscription_created = cerca.webhooks.create("fleet_abc123", url: "https://example.com/webhook")
puts(webhook_subscription_created)cerca webhooks create \
--api-key 'My API Key' \
--fleet-id fleet_abc123 \
--url https://example.com/webhookcurl --request POST \
--url https://api.cerca.dev/fleets/{fleetId}/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/webhook",
"events": []
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cerca.dev/fleets/{fleetId}/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://example.com/webhook',
'events' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.cerca.dev/fleets/{fleetId}/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/webhook\",\n \"events\": []\n}")
.asString();{
"createdAt": "<string>",
"enabled": true,
"fleetId": "<string>",
"events": [
"agent.created"
],
"id": "<string>",
"updatedAt": "<string>",
"url": "<string>",
"secret": "whsec_abc123"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}Webhooks
Create webhook
POST
/
fleets
/
{fleetId}
/
webhooks
JavaScript
import Cerca from '@cerca-dev/sdk';
const client = new Cerca({
apiKey: process.env['CERCA_API_KEY'], // This is the default and can be omitted
});
const webhookSubscriptionCreated = await client.webhooks.create('fleet_abc123', {
url: 'https://example.com/webhook',
});
console.log(webhookSubscriptionCreated.id);import os
from cerca import Cerca
client = Cerca(
api_key=os.environ.get("CERCA_API_KEY"), # This is the default and can be omitted
)
webhook_subscription_created = client.webhooks.create(
fleet_id="fleet_abc123",
url="https://example.com/webhook",
)
print(webhook_subscription_created.id)package main
import (
"context"
"fmt"
"github.com/matrices/cerca-go"
"github.com/matrices/cerca-go/option"
)
func main() {
client := cercago.NewClient(
option.WithAPIKey("My API Key"),
)
webhookSubscriptionCreated, err := client.Webhooks.New(
context.TODO(),
"fleet_abc123",
cercago.WebhookNewParams{
URL: cercago.F("https://example.com/webhook"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", webhookSubscriptionCreated.ID)
}
require "cerca"
cerca = Cerca::Client.new(api_key: "My API Key")
webhook_subscription_created = cerca.webhooks.create("fleet_abc123", url: "https://example.com/webhook")
puts(webhook_subscription_created)cerca webhooks create \
--api-key 'My API Key' \
--fleet-id fleet_abc123 \
--url https://example.com/webhookcurl --request POST \
--url https://api.cerca.dev/fleets/{fleetId}/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/webhook",
"events": []
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cerca.dev/fleets/{fleetId}/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://example.com/webhook',
'events' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.cerca.dev/fleets/{fleetId}/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/webhook\",\n \"events\": []\n}")
.asString();{
"createdAt": "<string>",
"enabled": true,
"fleetId": "<string>",
"events": [
"agent.created"
],
"id": "<string>",
"updatedAt": "<string>",
"url": "<string>",
"secret": "whsec_abc123"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}{
"error": "<string>",
"code": "MONTHLY_TOKEN_BUDGET_EXCEEDED"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Minimum string length:
1Example:
"fleet_abc123"
Body
application/json
HTTPS endpoint that will receive webhook deliveries.
Example:
"https://example.com/webhook"
Event names to deliver. Omit to subscribe to all non-test events.
webhook.test is reserved for the test endpoint and cannot be subscribed to.
Available options:
agent.created, agent.updated, agent.deleted, thread.created, thread.status.changed, thread.completed, thread.failed, turn.created, turn.completed, turn.failed, message.created, approval.requested, approval.resolved, approval.granted, schedule.created, schedule.deleted, schedule.triggered, connection.attached, connection.detached Response
Webhook subscription created. The one-time signing secret is returned as secret.
Webhook subscription response for create and rotate. Includes the one-time secret field.
Available options:
agent.created, agent.updated, agent.deleted, thread.created, thread.status.changed, thread.completed, thread.failed, turn.created, turn.completed, turn.failed, message.created, approval.requested, approval.resolved, approval.granted, schedule.created, schedule.deleted, schedule.triggered, connection.attached, connection.detached, webhook.test One-time webhook signing secret returned only by create and rotate responses. The field name is secret.
Example:
"whsec_abc123"