---
title: creates-a-configurable-log-drain-deprecated
product: vercel
url: /docs/rest-api/logdrains/creates-a-configurable-log-drain-deprecated
canonical_url: "https://vercel.com/docs/rest-api/logdrains/creates-a-configurable-log-drain-deprecated"
last_updated: 2026-09-07
type: reference
prerequisites:
  []
related:
  - /docs/rest-api
summary: Learn about creates-a-configurable-log-drain-deprecated on Vercel.
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

# Creates a Configurable Log Drain (deprecated)

```http
POST /v1/log-drains
```

Creates a configurable log drain. This endpoint must be called with a team AccessToken (integration OAuth2 clients are not allowed)

## Authentication

**bearerToken**: HTTP bearer

## Query parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `teamId` | string | No | The Team identifier to perform the request on behalf of. |
| `slug` | string | No | The Team slug to perform the request on behalf of. |


## Request body

Required: Yes

Content-Type: `application/json`

```json
{
  "type": "object",
  "required": [
    "deliveryFormat",
    "url",
    "sources"
  ],
  "properties": {
    "deliveryFormat": {
      "description": "The delivery log format",
      "enum": [
        "json",
        "ndjson"
      ]
    },
    "url": {
      "type": "string",
      "description": "The log drain url",
      "format": "uri",
      "pattern": "^(http|https)?://"
    },
    "headers": {
      "type": "object",
      "description": "Headers to be sent together with the request",
      "additionalProperties": {
        "type": "string"
      }
    },
    "projectIds": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-zA-z0-9_]+$"
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "static",
          "lambda",
          "build",
          "edge",
          "external",
          "firewall"
        ]
      }
    },
    "environments": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "preview",
          "production"
        ]
      }
    },
    "secret": {
      "type": "string",
      "description": "Custom secret of log drain"
    },
    "samplingRate": {
      "type": "number",
      "description": "The sampling rate for this log drain. It should be a percentage rate between 0 and 100. With max 2 decimal points",
      "minimum": 0.01,
      "maximum": 1
    },
    "name": {
      "type": "string",
      "description": "The custom name of this log drain."
    }
  }
}
```

## Example request

### TypeScript

```typescript
const response = await fetch('https://api.vercel.com/v1/log-drains?teamId=string&slug=string', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "deliveryFormat": "json",
    "url": "https://example.com",
    "headers": "value",
    "projectIds": [],
    "sources": [],
    "environments": [],
    "secret": "string",
    "samplingRate": "123",
    "name": "Example Name"
  }),
});

const data = await response.json();
console.log(data);
```

### Next.js

```typescript
'use server';

export async function callEndpoint() {
  const response = await fetch('https://api.vercel.com/v1/log-drains?teamId=string&slug=string', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.VERCEL_ACCESS_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "deliveryFormat": "json",
      "url": "https://example.com",
      "headers": "value",
      "projectIds": [],
      "sources": [],
      "environments": [],
      "secret": "string",
      "samplingRate": "123",
      "name": "Example Name"
    }),
    next: { revalidate: 3600 }
  });

  if (!response.ok) {
    throw new Error('Request failed');
  }

  return response.json();
}
```

### cURL

```bash
curl -X POST 'https://api.vercel.com/v1/log-drains?teamId=string&slug=string' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d "{
    \"deliveryFormat\": \"json\",
    \"url\": \"https://example.com\",
    \"headers\": \"value\",
    \"projectIds\": [],
    \"sources\": [],
    \"environments\": [],
    \"secret\": \"string\",
    \"samplingRate\": \"123\",
    \"name\": \"Example Name\"
  }"
```

## Example response

```json
"value"
```

## Responses

### 200: No description

Content-Type: `application/json`

```json
{
  "type": "object"
}
```

### 400: One of the provided values in the request body is invalid.

### 401: The request is not authorized.

### 403: You do not have permission to access this resource.

### 410: No description

---

## Related

- [logDrains endpoints](/docs/rest-api#logdrains)

- [REST API overview](/docs/rest-api)

- [OpenAPI spec](https://openapi.vercel.sh/) (machine-readable, all endpoints)

---

[View full sitemap](/docs/sitemap)
