> ## Documentation Index
> Fetch the complete documentation index at: https://www.courier.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Amazon SNS for Push

> Send push notifications with Courier and Amazon SNS (AWS SNS), including setup, topic and target ARN profile requirements, and credential overrides.

Amazon Simple Notification Service, also written as Amazon SNS or AWS SNS, delivers push messages to devices subscribed to an SNS topic or target ARN. Courier's provider key for it is `aws-sns`.

<Note>
  Amazon SNS also works as an SMS provider. See [Amazon SNS for SMS](/docs/external-integrations/sms/aws-sns).
</Note>

## Setup

You will need an AWS account with credentials that can publish to SNS. In Courier, navigate to the [Amazon SNS integration](https://app.courier.com/integrations/catalog/aws-sns) page, enter your Access Key ID and Secret Access Key, choose your region, then click "Complete."

You only add the integration once. It is then available as a provider on both the push and SMS channels.

<Warning>
  Leave the Topic ARN field empty if you want to push to individual devices. A Topic ARN saved on the integration takes precedence over the Target ARN in a recipient's profile, so every push goes to that topic and the per-recipient value is ignored. See [Destination precedence](#destination-precedence).
</Warning>

## Profile Requirements

To deliver a message to a mobile device over SNS, Courier needs either the Target ARN that the device is subscribed to or a Topic ARN.

To use a Target ARN, nest it under `aws_sns` in the recipient profile:

```json theme={null}
{
  "message": {
    "to": {
      "aws_sns": {
        "target_arn": "your:target:arn"
      }
    }
  }
}
```

To use a Topic ARN, set it on the integration or pass it as a [`config` override](#overrides). It is not read from the recipient profile.

### Destination precedence

Courier picks exactly one SNS destination per message, in this order:

1. `phone_number` on the profile, which sends an SMS rather than a push
2. Topic ARN, from the integration config or a `config` override
3. `aws_sns.target_arn` on the profile

The first one present wins and the rest are discarded. Nothing is sent if none of the three is set.

## Overrides

The `config` override swaps credentials, region, or the Topic ARN at send time:

| Field             | Effect                                                                    |
| ----------------- | ------------------------------------------------------------------------- |
| `accessKeyId`     | Replaces the saved Access Key ID                                          |
| `secretAccessKey` | Replaces the saved Secret Access Key                                      |
| `region`          | Replaces the saved region. Defaults to `us-east-1` if neither is set      |
| `topicArn`        | Replaces the saved Topic ARN, and still outranks a profile's `target_arn` |

```json theme={null}
{
  "message": {
    "template": "NOTIFICATION_TEMPLATE_ID",
    "to": {
      "aws_sns": {
        "target_arn": "your:target:arn"
      }
    },
    "providers": {
      "aws-sns": {
        "override": {
          "config": {
            "accessKeyId": "RUNTIME_ACCESS_KEY_ID",
            "secretAccessKey": "RUNTIME_SECRET_ACCESS_KEY",
            "region": "eu-west-1"
          }
        }
      }
    }
  }
}
```

The `body` override merges into the SNS `Publish` request itself, so its fields use the AWS parameter names rather than Courier's. See the [SNS publish properties](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#publish-property).

```json theme={null}
{
  "message": {
    "template": "NOTIFICATION_TEMPLATE_ID",
    "to": {
      "aws_sns": {
        "target_arn": "your:target:arn"
      }
    },
    "providers": {
      "aws-sns": {
        "override": {
          "body": {
            "Subject": "Order update",
            "MessageStructure": "json"
          }
        }
      }
    }
  }
}
```
