POST
/
v2
/
integrations
/
log-drains
import { Vercel } from "@vercel/sdk";

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

async function run() {
  const result = await vercel.logDrains.createLogDrain({
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      name: "My first log drain",
      secret: "a1Xsfd325fXcs",
      deliveryFormat: "json",
      url: "https://example.com/log-drain",
    },
  });

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

run();
{
  "clientId": "oac_xRhY4LAB7yLhUADD69EvV7ct",
  "configurationId": "icfg_cuwj0AdCdH3BwWT4LPijCC7t",
  "createdAt": 1558531915505,
  "id": "ld_nBuA7zCID8g4QZ8g",
  "deliveryFormat": "json",
  "name": "My first log drain",
  "ownerId": "kr1PsOIzqEL5Xg6M4VZcZosf",
  "projectId": "AbCgVkqoxXeXCDWehVir51LHGrrcWL4mkYm14W6UBPWQeb",
  "projectIds": "AbCgVkqoxXeXCDWehVir51LHGrrcWL4mkYm14W6UBPWQeb",
  "url": "https://example.com/log-drain",
  "sources": [
    "build",
    "edge"
  ],
  "createdFrom": "integration",
  "headers": "{\"Authorization\": \"Bearer 123\"}",
  "environments": [
    "production"
  ],
  "branch": "feature/*",
  "samplingRate": 0.5
}

Authorizations

Authorization
string
header
required

Default authentication mechanism

Query Parameters

teamId
string

The Team identifier to perform the request on behalf of.

Example:

"team_1a2b3c4d5e6f7g8h9i0j1k2l"

slug
string

The Team slug to perform the request on behalf of.

Example:

"my-team-url-slug"

Body

application/json
name
string
required

The name of the log drain

Maximum length: 100
Example:

"My first log drain"

url
string
required

The url where you will receive logs. The protocol must be https:// or http:// when type is json and ndjson, and syslog+tls: or syslog: when the type is syslog.

Example:

"https://example.com/log-drain"

projectIds
string[]
secret
string

A secret to sign log drain notification headers so a consumer can verify their authenticity

Maximum length: 100
Example:

"a1Xsfd325fXcs"

deliveryFormat
enum<string>

The delivery log format

Available options:
json,
ndjson,
syslog
Example:

"json"

sources
enum<string>[]
Available options:
static,
lambda,
build,
edge,
external,
firewall
headers
object

Headers to be sent together with the request

environments
enum<string>[]
Available options:
preview,
production

Response

200
application/json
The log drain was successfully created
createdAt
number
required

A timestamp that tells you when the log drain was created

Example:

1558531915505

id
string
required

The unique identifier of the log drain. Always prefixed with ld_

Example:

"ld_nBuA7zCID8g4QZ8g"

name
string
required

The name of the log drain

Example:

"My first log drain"

ownerId
string
required

The identifier of the team or user whose events will trigger the log drain

Example:

"kr1PsOIzqEL5Xg6M4VZcZosf"

url
string
required

The URL to call when logs are generated

Example:

"https://example.com/log-drain"

environments
enum<string>[]
required

The environment of log drain

The environment of log drain

Available options:
production,
preview
Example:
["production"]
clientId
string

The oauth2 client application id that created this log drain

Example:

"oac_xRhY4LAB7yLhUADD69EvV7ct"

configurationId
string

The client configuration this log drain was created with

Example:

"icfg_cuwj0AdCdH3BwWT4LPijCC7t"

deliveryFormat
enum<string>

The delivery log format

Available options:
json,
ndjson,
syslog,
protobuf
Example:

"json"

projectId
string | null
Example:

"AbCgVkqoxXeXCDWehVir51LHGrrcWL4mkYm14W6UBPWQeb"

projectIds
string[]

The identifier of the projects this log drain is associated with

Example:

"AbCgVkqoxXeXCDWehVir51LHGrrcWL4mkYm14W6UBPWQeb"

sources
enum<string>[]

The sources from which logs are currently being delivered to this log drain.

The sources from which logs are currently being delivered to this log drain.

Available options:
build,
edge,
lambda,
static,
external,
firewall
Example:
["build", "edge"]
createdFrom
enum<string>

Whether the log drain was created by an integration or by a user

Available options:
self-served,
integration
Example:

"integration"

headers
object

The headers to send with the request

Example:

"{\"Authorization\": \"Bearer 123\"}"

branch
string

The branch regexp of log drain

Example:

"feature/*"

samplingRate
number

The sampling rate of log drain

Example:

0.5