(webhooks)
Webhooks allow you to listen for changes to data in Attio, for example when a record is updated.
- list - List webhooks
- create - Create a webhook
- get - Get a webhook
- partialUpdate - Update a webhook
- delete - Delete a webhook
Get all of the webhooks in your workspace.
Required scopes: webhook:read
.
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.webhooks.list({
limit: 10,
offset: 5,
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { AttioCore } from "attio-js/core.js";
import { webhooksList } from "attio-js/funcs/webhooksList.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksList(attio, {
limit: 10,
offset: 5,
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetV2WebhooksRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetV2WebhooksResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.APIError | 4XX, 5XX | */* |
Create a webhook and associated subscriptions.
Required scopes: webhook:read-write
.
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.webhooks.create({
data: {
targetUrl: "https://example.com/webhook",
subscriptions: [],
},
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { AttioCore } from "attio-js/core.js";
import { webhooksCreate } from "attio-js/funcs/webhooksCreate.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksCreate(attio, {
data: {
targetUrl: "https://example.com/webhook",
subscriptions: [],
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.PostV2WebhooksRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.PostV2WebhooksResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.PostV2WebhooksValidationTypeError | 400 | application/json |
errors.APIError | 4XX, 5XX | */* |
Get a single webhook.
Required scopes: webhook:read
.
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.webhooks.get({
webhookId: "23e42eaf-323a-41da-b5bb-fd67eebda553",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { AttioCore } from "attio-js/core.js";
import { webhooksGet } from "attio-js/funcs/webhooksGet.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksGet(attio, {
webhookId: "23e42eaf-323a-41da-b5bb-fd67eebda553",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetV2WebhooksWebhookIdRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetV2WebhooksWebhookIdResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.GetV2WebhooksWebhookIdNotFoundError | 404 | application/json |
errors.APIError | 4XX, 5XX | */* |
Update a webhook and associated subscriptions.
Required scopes: webhook:read-write
.
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.webhooks.partialUpdate({
webhookId: "23e42eaf-323a-41da-b5bb-fd67eebda553",
requestBody: {
data: {
targetUrl: "https://example.com/webhook",
subscriptions: [
{
eventType: "note.created",
filter: {
dollarAnd: [
{
field: "parent_object_id",
operator: "equals",
value: "97052eb9-e65e-443f-a297-f2d9a4a7f795",
},
],
},
},
{
eventType: "note.created",
filter: {
dollarAnd: [
{
field: "parent_object_id",
operator: "equals",
value: "97052eb9-e65e-443f-a297-f2d9a4a7f795",
},
],
},
},
],
},
},
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { AttioCore } from "attio-js/core.js";
import { webhooksPartialUpdate } from "attio-js/funcs/webhooksPartialUpdate.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksPartialUpdate(attio, {
webhookId: "23e42eaf-323a-41da-b5bb-fd67eebda553",
requestBody: {
data: {
targetUrl: "https://example.com/webhook",
subscriptions: [
{
eventType: "note.created",
filter: {
dollarAnd: [
{
field: "parent_object_id",
operator: "equals",
value: "97052eb9-e65e-443f-a297-f2d9a4a7f795",
},
],
},
},
{
eventType: "note.created",
filter: {
dollarAnd: [
{
field: "parent_object_id",
operator: "equals",
value: "97052eb9-e65e-443f-a297-f2d9a4a7f795",
},
],
},
},
],
},
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.PatchV2WebhooksWebhookIdRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.PatchV2WebhooksWebhookIdResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.GetV2WebhooksWebhookIdNotFoundError | 404 | application/json |
errors.APIError | 4XX, 5XX | */* |
Delete a webhook by ID.
Required scopes: webhook:read-write
.
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.webhooks.delete({
webhookId: "23e42eaf-323a-41da-b5bb-fd67eebda553",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { AttioCore } from "attio-js/core.js";
import { webhooksDelete } from "attio-js/funcs/webhooksDelete.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksDelete(attio, {
webhookId: "23e42eaf-323a-41da-b5bb-fd67eebda553",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.DeleteV2WebhooksWebhookIdRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.DeleteV2WebhooksWebhookIdResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.DeleteV2WebhooksWebhookIdNotFoundError | 404 | application/json |
errors.APIError | 4XX, 5XX | */* |