# Create a Pub/Sub channel

> **POST** `https://api.us.nylas.com/v3/channels/pubsub`

Source: https://developer.nylas.com/docs/reference/api/pubsub-notifications/create-pubsub-channel/

Create a Pub/Sub channel in the specified application.


**Authentication:** NYLAS_API_KEY

## Request body

Destination definition

Content-Type: application/json

- `description` (string) - A human-readable description of the Pub/Sub channel.
- `trigger_types` (array) **(required)** - The event that triggers the notification. See the
[notification schemas](/docs/reference/notifications/) for details about each trigger
type.

See the [Grants](/docs/reference/api/manage-grants/), [Calendar](/docs/reference/api/calendar/),
[Events](/docs/reference/api/events/), and [Messages](/docs/reference/api/messages/) references
for information on how to trigger each event type.
- `topic` (string) - The Google Pub/Sub topic that Nylas sends notifications to.
- `notification_email_addresses` (array) - The email addresses that Nylas notifies if delivery to the Pub/Sub channel fails.
- `compressed_delivery` (boolean) - If `true`, Nylas compresses notification payloads using gzip before delivering them. Nylas adds a `content_encoding: gzip` message attribute to the Pub/Sub message. Default is `false`.

## Responses

### 200 - Returns the new Destination

- `data` (object)
  - `id` (string) - A unique identifier for the Pub/Sub notification channel.
  - `description` (string) - A human-readable description of the Pub/Sub notification channel.
  - `trigger_types` (array) - The event that triggers the notification. See the
[notification schemas](/docs/reference/notifications/) for details about each trigger
type.

See the [Grants](/docs/reference/api/manage-grants/), [Calendar](/docs/reference/api/calendar/),
[Events](/docs/reference/api/events/), and [Messages](/docs/reference/api/messages/) references
for information on how to trigger each event type.
  - `topic` (string) - The Google Pub/Sub topic that Nylas sends notifications to.
  - `status` (string) - The status of the Pub/Sub channel. When you first create a new channel, Nylas sets it to "active".
  - `notification_email_addresses` (array) - The email addresses that Nylas notifies if delivery to the Pub/Sub channel fails.
  - `compressed_delivery` (boolean) - If `true`, Nylas compresses notification payloads using gzip before delivering them.
- `request_id` (string) - The unique ID of the request that generated this response.

### 400 - Returns the new Destination

- `error` (object)
  - `type` (string) - An alphanumeric code that represents the error type.
  - `message` (string) - A human-readable message with details about the error.
- `request_id` (string) - The unique ID of the request that generated this response.

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.us.nylas.com/v3/channels/pubsub' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --data-raw '{
    "description": "PubSub Test",
    "trigger_types": ["message.send_success"],
    "encryption_key": "",
    "topic": "projects/<YOUR_PROJECT_ID>/topics/<YOUR_TOPIC_ID>",
    "notification_email_addresses": ["leyah@example.com"]
  }'
```
