---
title: "create log_drain"
method: POST
path: "/accounts/{account_id}/log_drains"
tags: ["LogDrains"]
---

# create log_drain

`POST /accounts/{account_id}/log_drains`

## Request

- Base URL: `https://api.aptible.com`
- URL: `https://api.aptible.com/accounts/{account_id}/log_drains`
- Auth: API key in header `Authorization`

Creates a new log drain for the specified account.

## Path parameters

- `account_id` integer, required

## Query parameters

- `no_embed` boolean

## Headers

- `Prefer` 'no_sensitive_extras=true'

## Request body

- CreateLogDrainRequest
  - `handle` string, required
  - `drain_type` string, required
  - `drain_host` string, uri: For syslog-tls-tcp drains
  - `drain_port` integer: For syslog-tls-tcp drains
  - `drain_username` string: DEPRECATED: For legacy Elasticsearch drains
  - `drain_password` string: For Tail drains
  - `database` string, uri: For Deploy-hosted Elasticsearch drains
  - `database_id` integer: For Deploy-hosted Elasticsearch drains
  - `url` string, uri: For HTTPs Post drains
  - `logging_token` string
  - `drain_apps` boolean
  - `drain_databases` boolean
  - `drain_ephemeral_sessions` boolean
  - `drain_proxies` boolean

## Response `201`

successful

- LogDrain
  - `id` integer, required
  - `_type` string, required
  - `handle` string, required
  - `drain_type` string, required
  - `drain_host` string, required
  - `drain_port` integer, required
  - `created_at` string, dateTime, required
  - `updated_at` string, dateTime, required
  - `status` string, required
  - `drain_username` string
  - `drain_password` string
  - `drain_apps` boolean, required
  - `drain_databases` boolean, required
  - `drain_ephemeral_sessions` boolean, required
  - `drain_proxies` boolean, required
  - `gentlemanjerry_certificate` string, required
  - `gentlemanjerry_docker_name` string, required
  - `gentlemanjerry_instance_id` string, required
  - `gentlemanjerry_host` string, required
  - `gentlemanjerry_port_mapping` array[], required
    - integer[]
  - `gentlemanjerry_allocation` string[], required
  - `url` string
  - `logging_token` string
  - `_links` LogDrainLinks
    - `account` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri
    - `database` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri
    - `operations` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri
    - `containers` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri
    - `ephemeral_containers` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri
    - `self` ListAccountsForStack200ResponseLinksStack
      - `href` string, uri

## Other responses

- `default`: Error response. Often a 4xx or 5xx status code

## Changes

- **2026-07-24** `1dc1e5b8c6eb`: 4 breaking, 2 info
  - the response property `drain_password` became optional for the status `201`
  - the response property `drain_username` became optional for the status `201`
  - the response property `logging_token` became optional for the status `201`
  - the response property `url` became optional for the status `201`
  - …2 more

[Operation history](https://skmtc.dev/aptible/apis/aptible-api-v1/changes/accounts/:account_id/log_drains/post.md)

---

[API](https://skmtc.dev/aptible/apis/aptible-api-v1.md) - [All operations](https://skmtc.dev/aptible/apis/aptible-api-v1/llms.txt) - [OpenAPI document](https://skmtc.dev/aptible/apis/aptible-api-v1/revisions/a21f6b1bc6fe?raw)
