Skip to content

Create a webhook with POST /webhook, then send it a test event.

Skip the reading — fast path for coding agents
CLI
truto webhooks create --target-url https://example.com/truto-webhook
Skill
View truto skill on GitHub Cursor / Claude Code: /skill truto
curl --location 'https://api.truto.one/webhook' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TRUTO_API_TOKEN" \
--data '{
    "target_url": "https://webhook.site/6a7cc86e-9286-4be8-ba79-bcd8dfdbeee1",
    "is_active": true,
    "event_types": ["integrated_account:created"]
}'
truto webhooks create -b '{
  "target_url": "https://webhook.site/6a7cc86e-9286-4be8-ba79-bcd8dfdbeee1",
  "is_active": true,
  "event_types": ["integrated_account:created"]
}'
from truto_python_sdk import TrutoApi
 
truto_api = TrutoApi(token="<api_token>")
 
webhook = await truto_api.webhooks.create({
    "target_url": "https://webhook.site/6a7cc86e-9286-4be8-ba79-bcd8dfdbeee1",
    "is_active": True,
    "event_types": ["integrated_account:created"],
})

In the example request above,

  • target_url is the webhook endpoint where a POST request with the webhook payload as the request body will be made. It must be a public https:// URL; see Errors.
  • is_active: optional, defaults to true.
  • event_types is an array of webhook event types that the target_url should receive data for. It is optional and if not mentioned in the request, then the target_url will receive data for all webhook event types.

The request returns 201 with the webhook,

{
    "id": "b6d29b9b-3d9d-44fd-aa77-512fd83b28c1",
    "target_url": "https://webhook.site/6a7cc86e-9286-4be8-ba79-bcd8dfdbeee1",
    "secret": "6e17561c-a20c-44ce-b8b5-caff0bf786fe",
    "is_active": true,
    "environment_id": "ac15abdc-b38e-47d0-97a2-69194017c199",
    "event_types": ["integrated_account:created"],
    "created_at": "2023-06-15T14:40:03.000Z",
    "updated_at": "2023-06-15T14:40:03.000Z"
}
  • event_types lists the subscribed event types. It is ["all"] when the request did not specify any.
  • secret is returned only in this response. Fetching or listing webhooks later does not include it, so store it securely now. Use it to verify the X-Truto-Signature header on each event Truto sends. The secret is unique to each webhook that you create, and Truto generates it: a secret sent in the create request is ignored. See verifying webhook events.

Send test event

Send the webhook a test event with POST /webhook/test:

curl --location 'https://api.truto.one/webhook/test' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TRUTO_API_TOKEN" \
--data '{
    "id": "b6d29b9b-3d9d-44fd-aa77-512fd83b28c1",
    "event_type": "integrated_account:created"
}'
truto webhooks test --id b6d29b9b-3d9d-44fd-aa77-512fd83b28c1 --event-type integrated_account:created
result = await truto_api.webhooks.test(
    "b6d29b9b-3d9d-44fd-aa77-512fd83b28c1",
    event_type="integrated_account:created",
)
  • id is the ID of the webhook to send the test event to.
  • event_type is optional and defaults to integrated_account:created. It can be any event type from the list of webhook event types except all.
  • integrated_account_id is optional. When set, the test payload is built from that integrated account, which must belong to the webhook's environment.
  • payload is an optional object deep-merged into the generated test payload.

A test event is sent once, isn't retried and isn't kept in event history. It goes to the webhook even when the webhook is turned off or doesn't subscribe to that event type. Without integrated_account_id, the payload uses placeholder IDs.

A successful test returns the event that was sent (trimmed here),

{
    "success": true,
    "event_type": "integrated_account:created",
    "payload": {
        "id": "00000000-0000-4000-8000-00000000ac01",
        "tenant_id": "truto-test-tenant",
        "environment_id": "ac15abdc-b38e-47d0-97a2-69194017c199",
        "status": "connecting",
        "integration": {
            "id": "00000000-0000-4000-8000-000000000001",
            "name": "hubspot",
            "config": { "label": "HubSpot" }
        },
        "…": "…"
    }
}

If your endpoint responds with a non-2XX status code, the request fails with a 500 error whose message includes the status code and response body your endpoint returned.

Update or delete a webhook

Change a webhook with PATCH /webhook/{id}. It takes target_url, is_active and event_types.

curl --location --request PATCH 'https://api.truto.one/webhook/b6d29b9b-3d9d-44fd-aa77-512fd83b28c1' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TRUTO_API_TOKEN" \
--data '{
    "event_types": ["integrated_account:created", "integrated_account:active"]
}'
truto webhooks update b6d29b9b-3d9d-44fd-aa77-512fd83b28c1 -b '{
  "event_types": ["integrated_account:created", "integrated_account:active"]
}'
import TrutoApi from '@truto/truto-ts-sdk'
 
const trutoApi = new TrutoApi({ token: process.env.TRUTO_API_TOKEN })
 
await trutoApi.webhook.update('b6d29b9b-3d9d-44fd-aa77-512fd83b28c1', {
  event_types: ['integrated_account:created', 'integrated_account:active'],
})
await truto_api.webhooks.update("b6d29b9b-3d9d-44fd-aa77-512fd83b28c1", {
    "event_types": ["integrated_account:created", "integrated_account:active"],
})
  • event_types replaces the list; it doesn't add to it. An empty list leaves the subscriptions as they are.
  • A new target_url must follow the same rules as on create.
  • is_active: false stops deliveries. Turning a webhook off, or deleting it, also deletes its queued retries and its event history, so resend any failed events you need first. Turning it back on doesn't bring them back.

Delete a webhook with DELETE /webhook/{id}, or truto webhooks delete <id> in the CLI.

To change the secret, create a new webhook, move your endpoint to its secret, then delete the old one. While both webhooks point at your endpoint, it gets each event twice, once from each webhook, with a different id.

Errors

Create, and a PATCH that changes target_url, return 400 when the URL isn't a public https:// URL. The message says which rule it broke:

  • target_url must be a valid URL
  • target_url must use https
  • target_url must not embed credentials: the URL has a username or password.
  • target_url must not point to localhost
  • target_url must not point to a private or reserved IP address
  • target_url must be a fully qualified hostname

An event type Truto doesn't know returns 400 with a message such as event_types contains 2 unknown event types: see unknown_event_types. The response's unknown_event_types lists up to 10 of them. Creating a webhook past your environment's limit also returns 400; see Webhooks overview.

Next

See Processing webhook events to verify the events your endpoint receives, and the Webhooks API reference for every endpoint.