# Create an Amazon SNS channel

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

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

Create an Amazon SNS notification channel in the specified application.

The `topic` must be a valid Amazon SNS topic ARN (starting with `arn:aws:sns:`).


**Authentication:** NYLAS_API_KEY

## Request body

Amazon SNS channel definition

Content-Type: application/json

- `description` (string) - A human-readable description of the Amazon SNS 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) **(required)** - The Amazon SNS topic ARN that Nylas sends notifications to. Must start with `arn:aws:sns:`.
- `role_arn` (string) **(required)** - The ARN of the IAM role that Nylas assumes to publish messages to the SNS topic. Must match `arn:aws:iam::<account-id>:role/<role-name>`.
- `notification_email_addresses` (array) - The email addresses that Nylas notifies if delivery to the Amazon SNS channel fails.
- `compressed_delivery` (boolean) - If `true`, Nylas gzip-compresses and then base64-encodes notification payloads before delivering them. Nylas adds a `content_encoding: gzip+base64` message attribute to the SNS message. To decode, base64-decode the message body, then gzip-decompress. Default is `false`.

## Responses

### 200 - Returns the new Amazon SNS channel.

- `data` (object)
  - `id` (string) - A unique identifier for the Amazon SNS notification channel.
  - `description` (string) - A human-readable description of the Amazon SNS 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 Amazon SNS topic ARN that Nylas sends notifications to.
  - `role_arn` (string) - The ARN of the IAM role that Nylas assumes to publish messages to the SNS topic.
  - `status` (string) - The status of the Amazon SNS 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 Amazon SNS channel fails.
  - `compressed_delivery` (boolean) - If `true`, Nylas gzip-compresses and then base64-encodes notification payloads before delivering them.
- `request_id` (string) - The unique ID of the request that generated this response.

### 400 - Returns an error.

- `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/sns' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --data-raw '{
    "description": "SNS Test",
    "trigger_types": ["message.send_success"],
    "topic": "arn:aws:sns:us-east-1:123456789012:my-topic",
    "role_arn": "arn:aws:iam::123456789012:role/nylas-sns-role",
    "notification_email_addresses": ["leyah@example.com"]
  }'
```
