# Set up the email API

**Summary:** Create an M2M token with Communication permissions, then use it to get the sender list, the published lists and the personalized tokens that the email endpoints use.

- Space: [Developers](https://www.subrite.no/developers)
- Source: https://www.subrite.no/developers/email-setup
- Updated: 2026-09-23
- Markdown index: https://www.subrite.no/developers/llms.txt

<a id="step-1-create-an-m2m-token"></a>
## Step 1: Create an M2M token

Create an M2M token granting Communication permissions. You will receive the token once you click save.

![Creating an M2M token with Communication permissions in Subrite](https://cdn.sanity.io/images/1x2xswq6/production/a2b4969ad7e7a047faa8398676c322a744cfecf1-753x746.png?w=1600&fit=max&auto=format)

<a id="step-2-get-the-sender-list"></a>
## Step 2: Get the sender list

Use the `get senders` API call to get the sender list.

- **Method:** `GET`
- **Route:** `{baseUrl}/api/v1/communications/email/senders`
- **CommunicationChannel:** `email`
- **Authorization:** Bearer token (use the M2M token from step 1)

In the response you will find the sender list:

```javascript
[
  {
    ...
    "senderName": "Subrite",
    "id": 1,
  },
  {
    ...
    "senderName": "Subrite two",
    "id": 2,
  }
]
```

<a id="step-3-get-the-published-lists"></a>
## Step 3: Get the published lists

Use the `segments/published` API call to get the lists.

- **Method:** `GET`
- **Route:** `{baseUrl}/api/v1/segments/published`
- **Authorization:** Bearer token (use the M2M token from step 1)

In the response you will find the lists:

```javascript
[
  {
    "id": 1,
    "name": "List 1",
    ...
  },
  {
    "id": 2,
    "name": "List 2",
    ...
  }
]
```

<a id="step-4-get-personalized-tokens"></a>
## Step 4: Get personalized tokens

Use the `api/v1/communications/email/tokens` API call to get personalized tokens.

- **Method:** `GET`
- **Route:** `{baseUrl}/api/v1/communications/email/tokens`
- **Authorization:** Bearer token (use the M2M token from step 1)

In the response you will find the tokens:

```json
{
  "memberInfo": [
    "fullName",
    "nickName",
    "email",
    "dateOfBirth",
    "phoneNumber",
    "address",
    "zipCode",
    "city",
    "country",
    "unsubscribeUrl",
    "mufcNumber",
    "muscNumber"
  ],
  "myPageLink": [
    "consentLink",
    "invoiceLink",
    "subscriptionLink",
    "podcastLink"
  ]
}
```

> [!NOTE]
> The email endpoints refer back to these steps: use a sender `id` from step 2 as `senderId` and a list `id` from step 3 as `segmentId`.
