Skip to content

Latest commit

 

History

History
327 lines (230 loc) · 23.2 KB

README.md

File metadata and controls

327 lines (230 loc) · 23.2 KB

Webhooks

(webhooks)

Overview

Available Operations

createWebhook

Creates a webhook

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.webhooks.createWebhook({
    requestBody: {
      url: "https://woeful-yin.biz",
      events: [
        "deployment-checks-completed",
      ],
    },
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { webhooksCreateWebhook } from "@vercel/sdk/funcs/webhooksCreateWebhook.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await webhooksCreateWebhook(vercel, {
    requestBody: {
      url: "https://woeful-yin.biz",
      events: [
        "test-webhook",
      ],
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request models.CreateWebhookRequest ✔️ 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.

Response

Promise<models.CreateWebhookResponseBody>

Errors

Error Type Status Code Content Type
models.VercelBadRequestError 400 application/json
models.VercelForbiddenError 401 application/json
models.SDKError 4XX, 5XX */*

getWebhooks

Get a list of webhooks

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.webhooks.getWebhooks({});

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { webhooksGetWebhooks } from "@vercel/sdk/funcs/webhooksGetWebhooks.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await webhooksGetWebhooks(vercel, {});

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request models.GetWebhooksRequest ✔️ 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.

Response

Promise<models.GetWebhooksResponseBody>

Errors

Error Type Status Code Content Type
models.VercelBadRequestError 400 application/json
models.VercelForbiddenError 401 application/json
models.SDKError 4XX, 5XX */*

getWebhook

Get a webhook

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.webhooks.getWebhook({
    id: "<id>",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { webhooksGetWebhook } from "@vercel/sdk/funcs/webhooksGetWebhook.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await webhooksGetWebhook(vercel, {
    id: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request models.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.

Response

Promise<models.GetWebhookResponseBody>

Errors

Error Type Status Code Content Type
models.VercelBadRequestError 400 application/json
models.VercelForbiddenError 401 application/json
models.SDKError 4XX, 5XX */*

deleteWebhook

Deletes a webhook

Example Usage

import { Vercel } from "@vercel/sdk";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  await vercel.webhooks.deleteWebhook({
    id: "<id>",
  });


}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { webhooksDeleteWebhook } from "@vercel/sdk/funcs/webhooksDeleteWebhook.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await webhooksDeleteWebhook(vercel, {
    id: "<id>",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  
}

run();

Parameters

Parameter Type Required Description
request models.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.

Response

Promise<void>

Errors

Error Type Status Code Content Type
models.VercelBadRequestError 400 application/json
models.VercelForbiddenError 401 application/json
models.SDKError 4XX, 5XX */*