Ir al contenido
v2.7

Webhooks

Webhooks del proyecto: avisos HTTP cuando algo pasa.

Webhooks del proyecto: avisos HTTP cuando algo pasa.

Clase Webhooks: 6 métodos (0 en @owbase/web, 6 en @owbase/node). Las descripciones de los métodos están en inglés. Los ejemplos usan la forma de objeto de los parámetros; cambia los valores entre < y > por los tuyos.

Listar webhooks

GET /webhooks · página del método

SDK: solo @owbase/node

Get a list of all webhooks belonging to the project. You can use the query params to filter your results.

Parámetro Tipo Obligatorio Descripción
queries string[] no Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, authUsername, tls, events, enabled, logs, attempts
total boolean no When set to false, the total count returned will be 0 and will not be calculated.

Acceso: clave de API con el alcance webhooks.read.

@owbase/node
import { Client, Webhooks } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const webhooks = new Webhooks(client);
const result = await webhooks.list({
queries: [], // optional
total: false, // optional
});

Crear webhook

POST /webhooks · página del método

SDK: solo @owbase/node

Create a new webhook. Use this endpoint to configure a URL that will receive events from Owbase when specific events occur.

Parámetro Tipo Obligatorio Descripción
webhookId string sí Webhook ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.
url string sí Webhook URL.
name string sí Webhook name. Max length: 128 chars.
events string[] sí Events list. Maximum of 100 events are allowed.
enabled boolean no Enable or disable a webhook.
tls boolean no Certificate verification, false for disabled or true for enabled.
authUsername string no Webhook HTTP user. Max length: 255 chars.
authPassword string no Webhook HTTP password. Max length: 2048 chars.
secret string no Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters.
description string no Optional description for the webhook.
headers object no Custom HTTP headers sent with every delivery, as an object of name and value, for example {“Authorization”:“Bearer token”}. Up to 10 headers. Write-only: the values are never returned, only their names (headerNames). On update, omit to keep the current headers, send an object to replace them or an empty object to remove them; they are removed when the URL changes or TLS verification is disabled.
bodyTemplate string no Optional body template. Empty sends the event JSON. Otherwise the template is sent after each {{variable}} becomes its JSON value. Variables: event, events, projectId, webhookId, deliveryId, timestamp, payload and payload.<path>. Max length: 4096 chars.

Acceso: clave de API con el alcance webhooks.write.

@owbase/node
import { Client, Webhooks } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const webhooks = new Webhooks(client);
const result = await webhooks.create({
webhookId: '<WEBHOOK_ID>',
url: 'https://example.com/webhook',
name: '<NAME>',
events: ['users.*.create'],
enabled: false, // optional
tls: false, // optional
authUsername: '<AUTH_USERNAME>', // optional
authPassword: 'password', // optional
secret: '<SECRET>', // optional
description: '<DESCRIPTION>', // optional
headers: {}, // optional
bodyTemplate: '<BODY_TEMPLATE>', // optional
});

Obtener webhook

GET /webhooks/{webhookId} · página del método

SDK: solo @owbase/node

Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project.

Parámetro Tipo Obligatorio Descripción
webhookId string sí Webhook ID.

Acceso: clave de API con el alcance webhooks.read.

@owbase/node
import { Client, Webhooks } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const webhooks = new Webhooks(client);
const result = await webhooks.get({
webhookId: '<WEBHOOK_ID>',
});

Actualizar webhook

PUT /webhooks/{webhookId} · página del método

SDK: solo @owbase/node

Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook.

Parámetro Tipo Obligatorio Descripción
webhookId string sí Webhook ID.
name string sí Webhook name. Max length: 128 chars.
url string sí Webhook URL.
events string[] sí Events list. Maximum of 100 events are allowed.
enabled boolean no Enable or disable a webhook.
tls boolean no Certificate verification, false for disabled or true for enabled.
authUsername string no Webhook HTTP user. Max length: 255 chars.
authPassword string no Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled.
description string no Optional description for the webhook.
headers object no Custom HTTP headers sent with every delivery, as an object of name and value, for example {“Authorization”:“Bearer token”}. Up to 10 headers. Write-only: the values are never returned, only their names (headerNames). On update, omit to keep the current headers, send an object to replace them or an empty object to remove them; they are removed when the URL changes or TLS verification is disabled.
bodyTemplate string no Optional body template. Omit to keep the current one, send an empty text to go back to the event JSON. Variables: event, events, projectId, webhookId, deliveryId, timestamp, payload and payload.<path>. Max length: 4096 chars.

Acceso: clave de API con el alcance webhooks.write.

@owbase/node
import { Client, Webhooks } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const webhooks = new Webhooks(client);
const result = await webhooks.update({
webhookId: '<WEBHOOK_ID>',
name: '<NAME>',
url: 'https://example.com/webhook',
events: ['users.*.create'],
enabled: false, // optional
tls: false, // optional
authUsername: '<AUTH_USERNAME>', // optional
authPassword: 'password', // optional
description: '<DESCRIPTION>', // optional
headers: {}, // optional
bodyTemplate: '<BODY_TEMPLATE>', // optional
});

Eliminar webhook

DELETE /webhooks/{webhookId} · página del método

SDK: solo @owbase/node

Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events.

Parámetro Tipo Obligatorio Descripción
webhookId string sí Webhook ID.

Acceso: clave de API con el alcance webhooks.write.

@owbase/node
import { Client, Webhooks } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const webhooks = new Webhooks(client);
const result = await webhooks.delete({
webhookId: '<WEBHOOK_ID>',
});

Actualizar clave secreta del webhook

PATCH /webhooks/{webhookId}/secret · página del método

SDK: solo @owbase/node

Update the webhook signing key. This endpoint can be used to regenerate the signing key used to sign and validate payload deliveries for a specific webhook.

Parámetro Tipo Obligatorio Descripción
webhookId string sí Webhook ID.
secret string no Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters.

Acceso: clave de API con el alcance webhooks.write.

@owbase/node
import { Client, Webhooks } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const webhooks = new Webhooks(client);
const result = await webhooks.updateSecret({
webhookId: '<WEBHOOK_ID>',
secret: '<SECRET>', // optional
});

Las descripciones de esta página vienen de la especificación de la API del servidor (licencia BSD-3-Clause), en inglés, y los ejemplos vienen del generador de SDKs (licencia MIT). Los avisos completos están en el archivo NOTICE de los paquetes @owbase/web y @owbase/node.

¿Te ayudó esta página?