(webhooks)
create and configure webhooks for PushPress events
- create - Create a new webhook to subscribe to one or more events
- list - List all registered webhooks
- get - Get details of a specific webhook
- update - Update the URL or events for an existing webhook
- delete - Delete a specific webhook
Create a new webhook to subscribe to one or more events
import { Pushpress } from "pushpress";
const pushpress = new Pushpress({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const result = await pushpress.webhooks.create({
url: "https://your-webhook-url.com",
events: [
"event_1",
"event_2",
],
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PushpressCore } from "pushpress/core.js";
import { webhooksCreate } from "pushpress/funcs/webhooksCreate.js";
// Use `PushpressCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const pushpress = new PushpressCore({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksCreate(pushpress, {
url: "https://your-webhook-url.com",
events: [
"event_1",
"event_2",
],
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CreateWebhookRequestBody | ✔️ | 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<components.Webhook>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400, 413, 414, 415, 422, 431, 510 | application/json |
errors.Unauthorized | 401, 403, 407, 511 | application/json |
errors.NotFound | 404, 501, 505 | application/json |
errors.Timeout | 408, 504 | application/json |
errors.RateLimited | 429 | application/json |
errors.InternalServerError | 500, 502, 503, 506, 507, 508 | application/json |
errors.APIError | 4XX, 5XX | */* |
List all registered webhooks
import { Pushpress } from "pushpress";
const pushpress = new Pushpress({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const result = await pushpress.webhooks.list();
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PushpressCore } from "pushpress/core.js";
import { webhooksList } from "pushpress/funcs/webhooksList.js";
// Use `PushpressCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const pushpress = new PushpressCore({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksList(pushpress);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.ListWebhooksRequest | ✔️ | 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<components.Webhook>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400, 413, 414, 415, 422, 431, 510 | application/json |
errors.Unauthorized | 401, 403, 407, 511 | application/json |
errors.NotFound | 404, 501, 505 | application/json |
errors.Timeout | 408, 504 | application/json |
errors.RateLimited | 429 | application/json |
errors.InternalServerError | 500, 502, 503, 506, 507, 508 | application/json |
errors.APIError | 4XX, 5XX | */* |
Get details of a specific webhook
import { Pushpress } from "pushpress";
const pushpress = new Pushpress({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const result = await pushpress.webhooks.get({
webhookId: "<id>",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PushpressCore } from "pushpress/core.js";
import { webhooksGet } from "pushpress/funcs/webhooksGet.js";
// Use `PushpressCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const pushpress = new PushpressCore({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksGet(pushpress, {
webhookId: "<id>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetWebhookRequest | ✔️ | 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<components.Webhook>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400, 413, 414, 415, 422, 431, 510 | application/json |
errors.Unauthorized | 401, 403, 407, 511 | application/json |
errors.NotFound | 404, 501, 505 | application/json |
errors.Timeout | 408, 504 | application/json |
errors.RateLimited | 429 | application/json |
errors.InternalServerError | 500, 502, 503, 506, 507, 508 | application/json |
errors.APIError | 4XX, 5XX | */* |
Update the URL or events for an existing webhook
import { Pushpress } from "pushpress";
const pushpress = new Pushpress({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const result = await pushpress.webhooks.update({
webhookId: "<id>",
requestBody: "<value>",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PushpressCore } from "pushpress/core.js";
import { webhooksUpdate } from "pushpress/funcs/webhooksUpdate.js";
// Use `PushpressCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const pushpress = new PushpressCore({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksUpdate(pushpress, {
webhookId: "<id>",
requestBody: "<value>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.UpdateWebhookRequest | ✔️ | 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<components.Webhook>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400, 413, 414, 415, 422, 431, 510 | application/json |
errors.Unauthorized | 401, 403, 407, 511 | application/json |
errors.NotFound | 404, 501, 505 | application/json |
errors.Timeout | 408, 504 | application/json |
errors.RateLimited | 429 | application/json |
errors.InternalServerError | 500, 502, 503, 506, 507, 508 | application/json |
errors.APIError | 4XX, 5XX | */* |
Delete a specific webhook
import { Pushpress } from "pushpress";
const pushpress = new Pushpress({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const result = await pushpress.webhooks.delete({
webhookId: "<id>",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { PushpressCore } from "pushpress/core.js";
import { webhooksDelete } from "pushpress/funcs/webhooksDelete.js";
// Use `PushpressCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const pushpress = new PushpressCore({
apiKey: process.env["PUSHPRESS_API_KEY"] ?? "",
});
async function run() {
const res = await webhooksDelete(pushpress, {
webhookId: "<id>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.DeleteWebhookRequest | ✔️ | 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.DeleteWebhookResponseBody>
Error Type | Status Code | Content Type |
---|---|---|
errors.BadRequest | 400, 413, 414, 415, 422, 431, 510 | application/json |
errors.Unauthorized | 401, 403, 407, 511 | application/json |
errors.NotFound | 404, 501, 505 | application/json |
errors.Timeout | 408, 504 | application/json |
errors.RateLimited | 429 | application/json |
errors.InternalServerError | 500, 502, 503, 506, 507, 508 | application/json |
errors.APIError | 4XX, 5XX | */* |