---
title: vercel drains
description: List, inspect, create, update, pause, resume, and delete Vercel Drains from your terminal.
url: "https://vercel.com/docs/cli/drains"
last_updated: 2018-10-20
related:
  - /docs/drains
  - /docs/cli/login
  - /docs/cli
  - /docs/drains/reference/logs
  - /docs/drains/reference/traces
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
search_kb_with_vercel_cli: npx vercel@latest kb search "<query>"
---

# vercel drains

The `vercel drains` command manages [Drains](/docs/drains) that forward logs, traces, Web Analytics events, Speed Insights metrics, Vercel Connect events, and audit logs to HTTP endpoints or Amazon S3 buckets.

Sign in with [`vercel login`](/docs/cli/login), or [authenticate with a token](/docs/cli#using-in-a-ci/cd-environment). Commands use your current team. Pass the global `--scope` option to select another team. Listing drains doesn't require a linked project; use `--project` to filter the results.

## Usage

Run `vercel drains` without a subcommand to list drains:

```bash filename="terminal"
vercel drains
vercel drains list --scope my-team
```

*List drains for the current team or a specific team.*

| Subcommand | Description |
| --- | --- |
| [`list`](#list) | List drains. Alias: `ls`. |
| [`inspect`](#inspect) | Show a drain's configuration. |
| [`create`](#create) | Create a drain that sends data to an HTTP endpoint or an Amazon S3 bucket. |
| [`update`](#update) | Change a drain's configuration. |
| [`pause`](#pause-and-resume) | Stop sending data without deleting the drain. |
| [`resume`](#pause-and-resume) | Resume a paused drain. |
| [`delete`](#delete) | Permanently delete a drain. Aliases: `rm`, `del`. |

Use a drain ID from `list` wherever a command takes `<drain>`. Every subcommand accepts `--json`.

## List

List drains, optionally filtering by project:

```bash filename="terminal"
vercel drains list
vercel drains list --project my-app --json
```

*List all drains or drains that send data from one project.*

| Option | Description |
| --- | --- |
| `--project`, `-p` | Project name or ID to filter by. Without this option, list drains across the team. |
| `--limit`, `-n` | Integer from 1 to 100 for results per page. Defaults to 20. |
| `--next` | Cursor from the previous page. |
| `--json` | Write a JSON object with `drains` and `pagination` to stdout. |

To continue listing, pass the cursor from `pagination.next` in JSON output or the next-page hint in text output:

```bash filename="terminal"
vercel drains list --limit 10 --json
vercel drains list --limit 10 --next your_next_cursor_here --json
```

*Read successive pages of drains.*

`pagination.next` is `null` when there are no more results.

## Inspect

Inspect a drain's type, destination, projects, and settings:

```bash filename="terminal"
vercel drains inspect drn_example
vercel drains inspect drn_example --json
```

*Inspect a drain using its ID.*

For an HTTP drain, text output shows only the endpoint's host by default. Pass `--show-full-url` to include its path and query string. JSON output includes the full endpoint URL, which can contain credentials. The CLI omits signing secrets and redacts delivery header values in JSON output.

For an S3 drain, text output shows the full `s3://` URL, region, role ARN, external ID, encoding, compression, and encryption. Text output also shows the KMS key ARN and object ACL when the drain has them. Your IAM role's trust policy must require this external ID. See [Send data to Amazon S3](#send-data-to-amazon-s3).

## Create

Provide a name, data type, and destination URL:

```bash filename="terminal"
vercel drains create --name app-logs --type logs --url https://example.com/drain
```

*Create a log drain for all projects on the current team.*

### Data types

A drain of any data type can send data to an HTTP endpoint or an Amazon S3 bucket. Encoding defaults to `json` for every type and destination.

| `--type` | Data | HTTP `--encoding` values | Amazon S3 `--encoding` values |
| --- | --- | --- | --- |
| `logs` | [Logs](/docs/drains/reference/logs) | `json`, `ndjson` | `json`, `ndjson` |
| `traces` | [Distributed traces](/docs/drains/reference/traces) | `json`, `proto` | `json`, `ndjson` |
| `analytics` | [Web Analytics events](/docs/drains/reference/analytics) | `json`, `ndjson` | `json`, `ndjson` |
| `speed-insights` | [Speed Insights metrics](/docs/drains/reference/speed-insights) | `json`, `ndjson` | `json`, `ndjson` |
| `connect` | [Vercel Connect events](/docs/connect/observability#events-reference) | `json`, `ndjson` | `json`, `ndjson` |
| `audit-logs` | [Audit logs](/docs/drains/reference/audit-logs) for the whole team. Requires the Enterprise plan. | `json`, `ndjson` | `json`, `ndjson` |

Scope options limit which data a drain sends. The scope options a drain accepts depend on its data type, and the CLI rejects any other scope option:

| `--type` | `--project` | `--source`, `--environment` | `--sample-rate` |
| --- | --- | --- | --- |
| `logs` | Yes | Yes | Yes |
| `traces`, `analytics`, `speed-insights`, `connect` | Yes | No | Yes |
| `audit-logs` | No | No | No |

Create these drains in the [dashboard](/docs/drains/using-drains#configuring-drains):

- [AI Gateway drains](/docs/ai-gateway/observability-and-spend/trace-drains)
- Audit log drains that send data to Splunk, Datadog, or Panther
- Drains that use native integrations

### Destinations

The scheme of the `--url` value selects the destination:

- An `http` or `https` URL creates an HTTP drain. Trace drains send OpenTelemetry Protocol (OTLP) data over HTTP. Only HTTP drains accept `--header` and `--secret`.
- An `s3://bucket/prefix` URL creates an S3 drain that writes objects to an Amazon S3 bucket. Only S3 drains accept `--region`, `--role-arn`, `--compression`, `--encryption`, `--kms-key-arn`, and `--object-acl`.

The CLI rejects options that don't apply to the destination. For example, `--secret` with an `s3://` URL returns an error.

### Send data to Amazon S3

An S3 drain writes objects to your Amazon S3 bucket as an AWS Identity and Access Management (IAM) role in your AWS account. Pass the `s3://` URL, the bucket's AWS region in `--region`, and the role's Amazon Resource Name (ARN) in `--role-arn`:

```bash filename="terminal"
vercel drains create --name app-logs-archive --type logs --url s3://my-bucket/vercel-logs --region us-east-1 --role-arn arn:aws:iam::123456789012:role/vercel-drains
```

*Archive logs from all projects in an S3 bucket.*

The bucket name uses 3 to 63 lowercase letters, numbers, hyphens, and periods. The prefix after the bucket name is optional. The URL can't include credentials, a port, a query string, or a fragment.

Set up the IAM role before you create the drain:

- **Trust policy**: Allow `arn:aws:iam::977805900156:role/vercel-drains-s3-writer` to assume the role, and require the external ID `vercel-team:<your-team-id>`. Replace `<your-team-id>` with your [Vercel team ID](/docs/accounts#find-your-team-id). `vercel drains inspect` also shows the external ID of an existing S3 drain.
- **Permissions policy**: Allow `s3:PutObject` under the URL's prefix. Also allow `s3:PutObjectAcl` if you pass `--object-acl`, and `kms:GenerateDataKey` on the key if you pass `--kms-key-arn`.
- **KMS key policy**: If you pass `--kms-key-arn`, allow the role in the policy of that AWS Key Management Service (AWS KMS) key.

The IAM setup is the same for every data type. For complete trust and permissions policies, see [Drain Data to Amazon S3](/docs/drains/s3).

`vercel drains create` doesn't send a test delivery, so a wrong trust or permissions policy shows up later as failed deliveries. After you create an S3 drain, run a test delivery from the dashboard. See [Test the drain](/docs/drains/s3#test-the-drain) and [Troubleshooting](/docs/drains/s3#troubleshooting).

S3 drains use these defaults unless you pass the option:

| Setting | Option | Default |
| --- | --- | --- |
| Compression | `--compression` | `gzip`, which adds `.gz` to object keys. Audit log drains default to `none`. |
| Server-side encryption | `--encryption` | `AES256` (server-side encryption with Amazon S3 managed keys, or SSE-S3). |
| KMS key | `--kms-key-arn` | The AWS managed `aws/s3` key, when `--encryption` is `aws:kms` or `aws:kms:dsse`. |
| Object ACL | `--object-acl` | No canned access control list (ACL). Set one only when the bucket requires it. |

To encrypt objects with a customer managed AWS KMS key, pass `--encryption aws:kms` or `--encryption aws:kms:dsse` with the key's full ARN in `--kms-key-arn`. The key must be in the bucket's region and in the role's AWS partition.

### Audit log drains

An audit log drain sends your team's [audit log](/docs/audit-log) events and requires the Enterprise plan. An audit log drain covers the whole team and sends every event, so the CLI rejects `--project`, `--source`, `--environment`, and `--sample-rate` for `--type audit-logs`.

For example, archive audit logs in an S3 bucket encrypted with a customer managed KMS key:

```bash filename="terminal"
vercel drains create --name audit-archive --type audit-logs --url s3://my-audit-bucket/vercel --region us-east-1 --role-arn arn:aws:iam::123456789012:role/vercel-drains --encryption aws:kms --kms-key-arn arn:aws:kms:us-east-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab
```

*Send all audit log events to S3 with AWS KMS encryption.*

### Connect drains

A Connect drain sends [Vercel Connect](/docs/connect) events, such as token requests, authorizations, revocations, and trigger deliveries. Use `--project` to limit the drain to specific projects and `--sample-rate` to send a percentage of events. Connect drains don't accept `--source` or `--environment`.

```bash filename="terminal"
vercel drains create --name connect-events --type connect --url https://example.com/drain --project my-app
```

*Send Vercel Connect events from one project to an HTTP endpoint.*

### Create options

| Option | Required | Description |
| --- | --- | --- |
| `--name` | Yes | Name of the drain. |
| `--type` | Yes | One of the [data types](#data-types) listed above. |
| `--url` | Yes | Full `http` or `https` endpoint URL, or `s3://bucket/prefix` for Amazon S3. |
| `--encoding` | No | Body encoding. Defaults to `json`. See [data types](#data-types) for the values each type accepts. |
| `--header` | No | HTTP drains only. Delivery header in `Name: value` form. Repeat to send multiple headers. |
| `--secret` | No | HTTP drains only. Signing secret for the `x-vercel-signature` header. Use `-` to read the secret from stdin. |
| `--region` | No | AWS region of the bucket, such as `us-east-1`. Required for S3 drains. |
| `--role-arn` | No | ARN of the IAM role that Vercel assumes to write objects. Required for S3 drains. |
| `--compression` | No | S3 drains only. `gzip` or `none`. Defaults to `gzip`, or `none` for audit log drains. `gzip` adds `.gz` to object keys. |
| `--encryption` | No | S3 drains only. Server-side encryption: `AES256`, `aws:kms`, or `aws:kms:dsse`. Defaults to `AES256`. |
| `--kms-key-arn` | No | S3 drains only. Full ARN of the KMS key. Requires `--encryption aws:kms` or `--encryption aws:kms:dsse`. Defaults to the AWS managed `aws/s3` key. |
| `--object-acl` | No | S3 drains only. Canned ACL for objects: `private`, `bucket-owner-read`, or `bucket-owner-full-control`. Defaults to no ACL. |
| `--project`, `-p` | No | Comma-separated project names or IDs. Defaults to all projects on the team. Audit log drains don't accept it. |
| `--environment`, `-e` | No | Logs only. Repeat to select `production` and/or `preview`. Defaults to all environments. |
| `--source` | No | Logs only. Repeat to select `lambda`, `edge`, `static`, `external`, `build`, `firewall`, or `redirect`. Defaults to all sources. |
| `--sample-rate` | No | Percentage greater than 0 and at most 100. Fractional values are supported. Defaults to 100. Audit log drains don't accept it. |
| `--json` | No | Return the created drain and an `outcome` of `created`. |

For example, send production function logs from selected projects:

```bash filename="terminal"
vercel drains create --name production-logs --type logs --url https://example.com/drain --project my-app,my-api --environment production --source lambda
```

*Restrict a log drain by project, environment, and source.*

To send a sample of traces using Protobuf encoding:

```bash filename="terminal"
vercel drains create --name app-traces --type traces --url https://example.com/v1/traces --encoding proto --sample-rate 10
```

*Send 10% of traces to an OTLP HTTP endpoint.*

See [securing drains](/docs/drains/security) for endpoint authentication and request signatures.

## Update

Pass a drain ID and at least one option to change. Omitted settings stay unchanged:

```bash filename="terminal"
vercel drains update drn_example --url https://example.com/new-drain
vercel drains update drn_example --sample-rate 100
```

*Change a drain's endpoint or send all data again.*

`update` accepts the create options except `--type`. Every setting you omit stays unchanged, including the encoding and the S3 compression, encryption, KMS key, and object ACL. When provided, `--header`, `--project`, `--source`, and `--environment` replace their respective lists rather than adding to them.

The scope rules from [data types](#data-types) also apply to `update`. For example, `update` rejects `--project` and `--sample-rate` for an audit log drain.

Use `--all` (or `-a`) to send data from all projects again. You can't combine it with `--project`:

```bash filename="terminal"
vercel drains update drn_example --all
```

*Replace a drain's project selection with all projects on the team.*

### Update a drain's destination

A drain keeps its destination type. Use `--url` to point an HTTP drain at another endpoint, or an S3 drain at another bucket or prefix. `update` never changes an HTTP drain to an S3 drain, or an S3 drain to an HTTP drain. To change the destination type, create a new drain, then delete the old one.

The options you pass must match the drain's destination:

| Destination | Accepted delivery options |
| --- | --- |
| HTTP drain | `--url`, `--encoding`, `--header`, `--secret` |
| S3 drain | `--url`, `--encoding`, `--region`, `--role-arn`, `--compression`, `--encryption`, `--kms-key-arn`, `--no-kms-key`, `--object-acl`, `--no-object-acl` |

Two options remove S3 settings:

| Option | Description |
| --- | --- |
| `--no-kms-key` | Remove the KMS key. S3 then encrypts with the AWS managed `aws/s3` key. You can't combine it with `--kms-key-arn`. |
| `--no-object-acl` | Remove the object ACL. You can't combine it with `--object-acl`. |

`update` keeps a stored KMS key until you pass `--no-kms-key`. To switch an S3 drain with a KMS key back to SSE-S3, pass `--encryption AES256` with `--no-kms-key`:

```bash filename="terminal"
vercel drains update drn_example --encryption AES256 --no-kms-key
```

*Switch an S3 drain from a customer managed KMS key to SSE-S3.*

To write new objects to another prefix with gzip compression:

```bash filename="terminal"
vercel drains update drn_example --url s3://my-bucket/vercel-logs/v2 --compression gzip
```

*Change an S3 drain's prefix and compression.*

A change to `--compression` changes the keys of new objects, because `gzip` adds `.gz`. Update S3 event notifications, lifecycle rules, and other tools that filter on object keys.

For destinations managed by an integration, change delivery settings in that integration. Use the dashboard to change destinations other than HTTP endpoints and Amazon S3, or custom filters that the CLI can't preserve.

## Pause and resume

Pause a drain to stop delivery without deleting its configuration:

```bash filename="terminal"
vercel drains pause drn_example
vercel drains resume drn_example
```

*Pause a drain, then resume delivery.*

Data generated while a drain is paused isn't sent and can't be recovered by resuming the drain. `pause` asks for confirmation. To confirm in a script or with `--json`, pass `--yes` (or `-y`):

```bash filename="terminal"
vercel drains pause drn_example --yes --json
```

*Confirm pausing a drain and return its updated state as JSON.*

`resume` doesn't require confirmation. Pausing an already paused drain or resuming an already running drain makes no change and returns `outcome: "unchanged"` with `--json`.

## Delete

Delete a drain to permanently stop sending data to its destination:

```bash filename="terminal"
vercel drains delete drn_example
```

*Delete a drain after confirming the action.*

Deletion is permanent. Pass `--yes` (or `-y`) to confirm deletion in a script or with JSON output:

```bash filename="terminal"
vercel drains delete drn_example --yes --json
```

*Confirm deleting a drain and return the result as JSON.*

## Output and errors

With `--json`, successful commands write a JSON object to stdout. `inspect` returns a `drain` object. Mutating commands also return an `outcome`, such as `created`, `updated`, `paused`, `resumed`, or `deleted`.

Without `--json`, mutating commands write the drain ID to stdout when piped, so scripts can capture it. Status messages go to stderr.

In JSON or non-interactive mode, drain errors go to stderr as JSON with a `reason` and a nonzero exit code. For example, `pause` or `delete` without `--yes` returns `confirmation_required` when the command can't prompt.

If a create request fails with an unknown outcome, run `vercel drains list` before retrying to check whether the drain already exists.

## Global Options

The following [global options](/docs/cli/global-options) can be passed when using the `vercel drains` command:

- [`--cwd`](/docs/cli/global-options#current-working-directory)
- [`--debug`](/docs/cli/global-options#debug)
- [`--global-config`](/docs/cli/global-options#global-config)
- [`--help`](/docs/cli/global-options#help)
- [`--local-config`](/docs/cli/global-options#local-config)
- [`--no-color`](/docs/cli/global-options#no-color)
- [`--non-interactive`](/docs/cli/global-options#non-interactive)
- [`--scope`](/docs/cli/global-options#scope)
- [`--token`](/docs/cli/global-options#token)
- [`--version`](/docs/cli/global-options#version)

For more information on global options and their usage, refer to the [options section](/docs/cli/global-options).

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
