(webhooks)
Webhooks are a way for Shippo to notify your application when a specific event occurs. For example, when a label is purchased or when a shipment tracking status has changed. You can use webhooks to trigger actions in your application, such as sending an email or updating a database.
The payload is the body of the POST request Shippo sends to the URL specified at the time of webhook registration.
- createWebhook - Create a new webhook
- listWebhooks - List all webhooks
- getWebhook - Retrieve a specific webhook
- updateWebhook - Update an existing webhook
- deleteWebhook - Delete a specific webhook
Creates a new webhook to send notifications to a URL when a specific event occurs.
import { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const result = await shippo.webhooks.createWebhook({
event: "batch_created",
url: "https://example.com/shippo-webhook",
active: true,
isTest: false,
});
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { ShippoCore } from "shippo/core.js";
import { webhooksCreateWebhook } from "shippo/funcs/webhooksCreateWebhook.js";
// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const res = await webhooksCreateWebhook(shippo, {
event: "batch_created",
url: "https://example.com/shippo-webhook",
active: true,
isTest: false,
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
components.WebhookUpdateRequest | ✔️ | 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 Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Returns a list of all webhooks you have created.
import { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const result = await shippo.webhooks.listWebhooks();
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { ShippoCore } from "shippo/core.js";
import { webhooksListWebhooks } from "shippo/funcs/webhooksListWebhooks.js";
// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const res = await webhooksListWebhooks(shippo);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
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.WebhookPaginatedList>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Returns the details of a specific webhook using the webhook object ID.
import { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const result = await shippo.webhooks.getWebhook("<value>");
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { ShippoCore } from "shippo/core.js";
import { webhooksGetWebhook } from "shippo/funcs/webhooksGetWebhook.js";
// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const res = await webhooksGetWebhook(shippo, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
webhookId |
string | ✔️ | Object ID of the webhook to retrieve |
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 Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Updates an existing webhook using the webhook object ID.
import { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const result = await shippo.webhooks.updateWebhook("<value>", {
event: "batch_created",
url: "https://example.com/shippo-webhook",
active: true,
isTest: false,
});
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { ShippoCore } from "shippo/core.js";
import { webhooksUpdateWebhook } from "shippo/funcs/webhooksUpdateWebhook.js";
// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const res = await webhooksUpdateWebhook(shippo, "<value>", {
event: "batch_created",
url: "https://example.com/shippo-webhook",
active: true,
isTest: false,
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
webhookId |
string | ✔️ | Object ID of the webhook to retrieve |
webhookUpdateRequest |
components.WebhookUpdateRequest | ✔️ | N/A |
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 Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Deletes a specific webhook using the webhook object ID.
import { Shippo } from "shippo";
const shippo = new Shippo({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
await shippo.webhooks.deleteWebhook("<value>");
}
run();
The standalone function version of this method:
import { ShippoCore } from "shippo/core.js";
import { webhooksDeleteWebhook } from "shippo/funcs/webhooksDeleteWebhook.js";
// Use `ShippoCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const shippo = new ShippoCore({
apiKeyHeader: "<YOUR_API_KEY_HERE>",
shippoApiVersion: "2018-02-08",
});
async function run() {
const res = await webhooksDeleteWebhook(shippo, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
webhookId |
string | ✔️ | Object ID of the webhook to delete |
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<void>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |