---
title: creates-a-new-integration-log-drain-deprecated
product: vercel
url: /docs/rest-api/logdrains/creates-a-new-integration-log-drain-deprecated
type: reference
prerequisites:
  []
related:
  - /docs/rest-api
summary: Learn about creates-a-new-integration-log-drain-deprecated on Vercel.
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---

# Creates a new Integration Log Drain (deprecated)

```http
POST /v2/integrations/log-drains
```

Creates an Integration log drain. This endpoint must be called with an OAuth2 client (integration), since log drains are tied to integrations. If it is called with a different token type it will produce a 400 error.

## 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": [
    "name",
    "url"
  ],
  "properties": {
    "name": {
      "type": "string",
      "description": "The name of the log drain",
      "pattern": "^[A-z0-9_ -]+$",
      "maxLength": 100
    },
    "projectIds": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-zA-z0-9_]+$"
      }
    },
    "secret": {
      "type": "string",
      "description": "A secret to sign log drain notification headers so a consumer can verify their authenticity",
      "pattern": "^[A-z0-9_ -]+$",
      "maxLength": 100
    },
    "deliveryFormat": {
      "description": "The delivery log format",
      "enum": [
        "json",
        "ndjson"
      ]
    },
    "url": {
      "type": "string",
      "description": "The url where you will receive logs. The protocol must be `https://` or `http://` when type is `json` and `ndjson`.",
      "format": "uri",
      "pattern": "^https?://"
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "static",
          "lambda",
          "build",
          "edge",
          "external",
          "firewall"
        ]
      }
    },
    "headers": {
      "type": "object",
      "description": "Headers to be sent together with the request",
      "additionalProperties": {
        "type": "string"
      }
    },
    "environments": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "preview",
          "production"
        ]
      }
    }
  }
}
```

## Responses

### 200: The log drain was successfully created

Content-Type: `application/json`

```json
{
  "type": "object",
  "required": [
    "createdAt",
    "id",
    "name",
    "ownerId",
    "source",
    "url"
  ],
  "properties": {
    "clientId": {
      "type": "string",
      "description": "The oauth2 client application id that created this log drain"
    },
    "configurationId": {
      "type": "string",
      "description": "The client configuration this log drain was created with"
    },
    "createdAt": {
      "type": "number",
      "description": "A timestamp that tells you when the log drain was created"
    },
    "id": {
      "type": "string",
      "description": "The unique identifier of the log drain. Always prefixed with `ld_`"
    },
    "deliveryFormat": {
      "type": "string",
      "description": "The delivery log format",
      "enum": [
        "json",
        "ndjson",
        "protobuf"
      ]
    },
    "name": {
      "type": "string",
      "description": "The name of the log drain"
    },
    "ownerId": {
      "type": "string",
      "description": "The identifier of the team or user whose events will trigger the log drain"
    },
    "projectId": {
      "type": "string",
      "nullable": true
    },
    "projectIds": {
      "type": "array",
      "description": "The identifier of the projects this log drain is associated with",
      "items": {
        "type": "string"
      }
    },
    "url": {
      "type": "string",
      "description": "The URL to call when logs are generated"
    },
    "sources": {
      "type": "array",
      "description": "The sources from which logs are currently being delivered to this log drain.",
      "items": {
        "type": "string",
        "description": "The sources from which logs are currently being delivered to this log drain.",
        "enum": [
          "external",
          "build",
          "edge",
          "lambda",
          "static",
          "firewall",
          "redirect"
        ]
      }
    },
    "createdFrom": {
      "type": "string",
      "description": "Whether the log drain was created by an integration or by a user",
      "enum": [
        "integration",
        "self-served"
      ]
    },
    "headers": {
      "type": "object",
      "description": "The headers to send with the request",
      "additionalProperties": {
        "type": "string"
      }
    },
    "environments": {
      "type": "array",
      "description": "The environment of log drain",
      "items": {
        "type": "string",
        "description": "The environment of log drain",
        "enum": [
          "production",
          "preview"
        ]
      }
    },
    "branch": {
      "type": "string",
      "description": "The branch regexp of log drain"
    },
    "samplingRate": {
      "type": "number",
      "description": "The sampling rate of log drain"
    },
    "source": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "kind"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "self-served"
              ]
            }
          }
        },
        {
          "type": "object",
          "required": [
            "integrationConfigurationId",
            "integrationId",
            "kind"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "integration"
              ]
            },
            "resourceId": {
              "type": "string"
            },
            "externalResourceId": {
              "type": "string"
            },
            "integrationId": {
              "type": "string"
            },
            "integrationConfigurationId": {
              "type": "string"
            }
          }
        }
      ]
    }
  }
}
```

### 400: One of the provided values in the request body is invalid.
The provided token is not from an OAuth2 Client

### 401: The request is not authorized.

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

---

## 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)
