# Create a channel

`POST /v1/projects/{project_id}/channels`

Requires role admin or higher. Counts against the plan limit channels_per_project.

A webhook channel's signing secret is in the response only.

## Authentication

A session token: `Authorization: Bearer <session token>`, or the session cookie in the browser. Requires role `admin` or higher.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `project_id` | path | string | yes |  |

## Request body

`application/json`

```json
{
  "anyOf": [
    {
      "additionalProperties": false,
      "properties": {
        "member_id": {
          "pattern": "^mem_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "name": {
          "maxLength": 100,
          "minLength": 1,
          "pattern": "^(?=[\\s\\S]*\\S)[^\\u0000-\\u001F\\u007F]+$",
          "type": "string"
        },
        "type": {
          "enum": [
            "email"
          ],
          "type": "string"
        }
      },
      "required": [
        "type",
        "name",
        "member_id"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "properties": {
        "name": {
          "maxLength": 100,
          "minLength": 1,
          "pattern": "^(?=[\\s\\S]*\\S)[^\\u0000-\\u001F\\u007F]+$",
          "type": "string"
        },
        "type": {
          "enum": [
            "webhook"
          ],
          "type": "string"
        },
        "url": {
          "maxLength": 2048,
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "type",
        "name",
        "url"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "description": "A Slack incoming webhook URL.",
      "properties": {
        "name": {
          "maxLength": 100,
          "minLength": 1,
          "pattern": "^(?=[\\s\\S]*\\S)[^\\u0000-\\u001F\\u007F]+$",
          "type": "string"
        },
        "type": {
          "enum": [
            "slack"
          ],
          "type": "string"
        },
        "url": {
          "maxLength": 2048,
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "type",
        "name",
        "url"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "description": "A Discord channel webhook URL.",
      "properties": {
        "name": {
          "maxLength": 100,
          "minLength": 1,
          "pattern": "^(?=[\\s\\S]*\\S)[^\\u0000-\\u001F\\u007F]+$",
          "type": "string"
        },
        "type": {
          "enum": [
            "discord"
          ],
          "type": "string"
        },
        "url": {
          "maxLength": 2048,
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "type",
        "name",
        "url"
      ],
      "type": "object"
    }
  ]
}
```

## Responses

### 201

The new channel.

`application/json`

```json
{
  "anyOf": [
    {
      "additionalProperties": false,
      "description": "A channel that emails one member.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "type": "string"
        },
        "email": {
          "description": "The member's current address.",
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "health": {
          "anyOf": [
            {
              "enum": [
                "ok"
              ],
              "type": "string"
            },
            {
              "enum": [
                "failing"
              ],
              "type": "string"
            }
          ],
          "description": "failing after 3 consecutive failed deliveries, until one succeeds."
        },
        "id": {
          "pattern": "^chn_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "member_id": {
          "pattern": "^mem_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "project_id": {
          "pattern": "^prj_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "type": {
          "enum": [
            "email"
          ],
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "type": "string"
        }
      },
      "required": [
        "id",
        "project_id",
        "name",
        "enabled",
        "health",
        "created_at",
        "updated_at",
        "type",
        "member_id",
        "email"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "description": "A new webhook channel, with its signing secret.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "health": {
          "anyOf": [
            {
              "enum": [
                "ok"
              ],
              "type": "string"
            },
            {
              "enum": [
                "failing"
              ],
              "type": "string"
            }
          ],
          "description": "failing after 3 consecutive failed deliveries, until one succeeds."
        },
        "id": {
          "pattern": "^chn_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "project_id": {
          "pattern": "^prj_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "secret": {
          "description": "The signing secret, returned once.",
          "pattern": "^whsec_",
          "type": "string"
        },
        "type": {
          "enum": [
            "webhook"
          ],
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "project_id",
        "name",
        "enabled",
        "health",
        "created_at",
        "updated_at",
        "type",
        "url",
        "secret"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "description": "A channel that posts to a Slack incoming webhook.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "health": {
          "anyOf": [
            {
              "enum": [
                "ok"
              ],
              "type": "string"
            },
            {
              "enum": [
                "failing"
              ],
              "type": "string"
            }
          ],
          "description": "failing after 3 consecutive failed deliveries, until one succeeds."
        },
        "id": {
          "pattern": "^chn_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "project_id": {
          "pattern": "^prj_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "type": {
          "enum": [
            "slack"
          ],
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "type": "string"
        },
        "url_hint": {
          "description": "Identifies the webhook without revealing it; the URL itself is never returned.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "project_id",
        "name",
        "enabled",
        "health",
        "created_at",
        "updated_at",
        "type",
        "url_hint"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "description": "A channel that posts to a Discord channel webhook.",
      "properties": {
        "created_at": {
          "format": "date-time",
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "health": {
          "anyOf": [
            {
              "enum": [
                "ok"
              ],
              "type": "string"
            },
            {
              "enum": [
                "failing"
              ],
              "type": "string"
            }
          ],
          "description": "failing after 3 consecutive failed deliveries, until one succeeds."
        },
        "id": {
          "pattern": "^chn_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "project_id": {
          "pattern": "^prj_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "type": "string"
        },
        "type": {
          "enum": [
            "discord"
          ],
          "type": "string"
        },
        "updated_at": {
          "format": "date-time",
          "type": "string"
        },
        "url_hint": {
          "description": "Identifies the webhook without revealing it; the URL itself is never returned.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "project_id",
        "name",
        "enabled",
        "health",
        "created_at",
        "updated_at",
        "type",
        "url_hint"
      ],
      "type": "object"
    }
  ],
  "description": "The new channel."
}
```

### 401

unauthorized: no valid session, or the email is not verified.

Problem type: [unauthorized](https://docs.dlogify.com/errors/unauthorized.md).

### 403

channel-type-not-allowed: the plan does not include this channel type. csrf-origin-rejected: a cookie-authenticated change from an origin outside the web app. forbidden: the action requires the admin role. plan-limit-reached: the plan's channels_per_project limit is reached.

Problem type: [channel-type-not-allowed](https://docs.dlogify.com/errors/channel-type-not-allowed.md).

### 404

not-found: the resource does not exist, or the caller is not a member of its organization.

Problem type: [not-found](https://docs.dlogify.com/errors/not-found.md).

### 409

conflict: the member already has an email channel in this project.

Problem type: [conflict](https://docs.dlogify.com/errors/conflict.md).

### 422

invalid-webhook-url: the URL is not https, does not resolve only to public addresses, or is not a Slack or Discord webhook URL; also validation-failed. validation-failed: the request does not match the schema.

Problem type: [invalid-webhook-url](https://docs.dlogify.com/errors/invalid-webhook-url.md).

### 429

rate-limited: per-user management request limit.

Problem type: [rate-limited](https://docs.dlogify.com/errors/rate-limited.md).

## Example

```bash
curl -X POST "https://api.dlogify.com/v1/projects/{project_id}/channels" \
  -H "Authorization: Bearer $DLOGIFY_SESSION" \
  -H "Content-Type: application/json" \
  --data-binary @body
```

Source: https://docs.dlogify.com/api/channels/createChannel
