(webhook)
- createWebhook - Create an outbound webhook
- deleteWebhook - Delete an outbound webhook
- getWebhookById - Get a webhook
- getWebhooks - List webhooks
- updateWebhook - Update an outbound webhook
Creates an outbound webhook.
import { Circleci } from "circleci-v2-sdk";
import { Events, TypeT } from "circleci-v2-sdk/dist/sdk/models/operations";
async function run() {
const sdk = new Circleci({
security: {
apiKeyHeader: "<YOUR_API_KEY_HERE>",
},
});
const res = await sdk.webhook.createWebhook({
events: [
Events.JobCompleted,
],
name: "<value>",
scope: {
id: "ef8f63e3-b7d2-4240-88ac-4c59d30daac8",
type: TypeT.Project,
},
signingSecret: "<value>",
url: "http://ragged-suppression.name",
verifyTls: false,
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.CreateWebhookRequestBody | ✔️ | The request object to use for the request. |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Promise<operations.CreateWebhookResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Deletes an outbound webhook
import { Circleci } from "circleci-v2-sdk";
async function run() {
const sdk = new Circleci({
security: {
apiKeyHeader: "<YOUR_API_KEY_HERE>",
},
});
const res = await sdk.webhook.deleteWebhook({
webhookId: "90ed7052-6bb0-4b60-93ab-e4433ee4e2bb",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.DeleteWebhookRequest | ✔️ | The request object to use for the request. |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Promise<operations.DeleteWebhookResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Get an outbound webhook by id.
import { Circleci } from "circleci-v2-sdk";
async function run() {
const sdk = new Circleci({
security: {
apiKeyHeader: "<YOUR_API_KEY_HERE>",
},
});
const res = await sdk.webhook.getWebhookById({
webhookId: "48f47148-587e-42d6-8c80-5b1461e57de9",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetWebhookByIdRequest | ✔️ | The request object to use for the request. |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Promise<operations.GetWebhookByIdResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Get a list of outbound webhooks that match the given scope-type and scope-id
import { Circleci } from "circleci-v2-sdk";
import { ScopeType } from "circleci-v2-sdk/dist/sdk/models/operations";
async function run() {
const sdk = new Circleci({
security: {
apiKeyHeader: "<YOUR_API_KEY_HERE>",
},
});
const res = await sdk.webhook.getWebhooks({
scopeId: "14ccf55a-42ac-416c-bacd-a992e8b59ec0",
scopeType: ScopeType.Project,
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.GetWebhooksRequest | ✔️ | The request object to use for the request. |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Promise<operations.GetWebhooksResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |
Updates an outbound webhook.
import { Circleci } from "circleci-v2-sdk";
import { UpdateWebhookEvents } from "circleci-v2-sdk/dist/sdk/models/operations";
async function run() {
const sdk = new Circleci({
security: {
apiKeyHeader: "<YOUR_API_KEY_HERE>",
},
});
const res = await sdk.webhook.updateWebhook({
requestBody: {
events: [
UpdateWebhookEvents.JobCompleted,
],
},
webhookId: "ac255204-82ad-4436-900a-b198d2970788",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.UpdateWebhookRequest | ✔️ | The request object to use for the request. |
config |
AxiosRequestConfig | ➖ | Available config options for making requests. |
Promise<operations.UpdateWebhookResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |