> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/emails/campaigns/log.md).

# Message log

Read the message log of an email campaign — one batch, one message, exactly as it was sent.

**Where:** Email → Campaigns → **View** → a batch → a message · `/projects/<project>/emails/campaigns/<campaignId>/view`

"I never got the email" is the most common question about email. The message log answers it for one message: who sent it, to which address, with which token values, and the rendered email as it went out — or why it failed.

## Before you start

* A campaign that has started sending — see [Campaign details](/codemash/cloud/emails/campaigns/details.md). Permission `email:read`.
* To find the campaign of one person, filter **Email → Campaigns** by **Email Address**, for example `ada.lovelace@example.com`.

## Steps

1. Open the campaign and press the batch (`3 recipient(s)`). The **Batch** page lists one row per message: the recipient, the message id (`ntf_…`), the time and the status. **Back** returns to the campaign.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-0ba65d7779ba1f9be96090558b69d3f5032cc040%2Fcampaigns-log-1.png?alt=media" alt="Batch cmpb_… with status Completed and three messages: ada.lovelace@example.com, alan.turing@example.com, grace.hopper@example.com, each Completed"><figcaption><p>The batch and its three messages.</p></figcaption></figure>
2. Press a message, for example `ada.lovelace@example.com`. **Email Details** opens with a timeline. At the top: **Batch processed** (the batch id) and **Initiator information** — the `@Model.Initiator.User.*` values of the person who sent the campaign.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-b992d84662f4c28b4eb5aa80bdcccdf678a9090b%2Fcampaigns-log-2.png?alt=media" alt="Email Details ntf_…: Batch processed, Initiator information with @Model.Initiator.User.Id, Email, Roles, DisplayName, RoleNames; Delivery Strategy"><figcaption><p>The top of the message log.</p></figcaption></figure>
3. Scroll down through the timeline:

   * **Delivery Strategy** — the recipients rule, the **Template** (link), its **Template Languages** and the **Integration**.
   * **Receiver(s)** — the real **To** (and CC / BCC) and when it was received.
   * **Resolved Tokens** — every token with the value used, shown as `@Model.<key>`.
   * **Email message** — the reference id, the final **Subject**, and the rendered HTML exactly as it was sent.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-72fd4ab7ea522f232221251e638025758117807a%2Fcampaigns-log-3.png?alt=media" alt="Delivery Strategy with Template Welcome email, Template Languages en, de, Integration int_…; Receiver(s) To ada.lovelace@example.com; Resolved Tokens; Email message with Subject Welcome to Acme"><figcaption><p>Receiver, resolved tokens and the start of the sent email.</p></figcaption></figure>

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-72fd4ab7ea522f232221251e638025758117807a%2Fcampaigns-log-3.png?alt=media" alt="The rendered email: Welcome to Acme, Your account is ready, signature Ada Lovelace, Customer support, Acme"><figcaption><p>The email as it was sent, with the signature.</p></figcaption></figure>

## Result

A good message has status **Completed**, the expected address under **Receiver(s)**, and the rendered email with real values. A **Failed** message shows **Campaign Errors** with the time and each error.

Message statuses: **Completed**, **Failed**, **Viewed**, **Clicked**, and three "not sent on purpose" outcomes — the recipient unsubscribed from all marketing (`BlockedByUserPreferenceBlockAll`), turned off one tag (`BlockedByUserPreferenceBlockByTag`), or was blocked by address validation (`BlockedByValidation`, not used yet — see [Validation integrations](/codemash/cloud/emails/integrations/validation.md)). **Viewed** and **Clicked** need a provider that reports opens and clicks back (Mailgun with its [webhook](/codemash/cloud/emails/integrations/providers/mailgun.md)). Every sent email also carries a signed "View in web" link — see [Notification preview link](/codemash/cloud/concepts/message-templates/preview-link.md).

{% hint style="warning" %}
**Known issue:** in the capture above the campaign went to **All users**, and the per-recipient name rendered empty ("Hi,"). See [Create a campaign](/codemash/cloud/emails/campaigns/new.md#result).
{% endhint %}

## Change or remove it later

The log is read-only. It is deleted together with its campaign (**Actions → Delete campaign...** on the [details page](/codemash/cloud/emails/campaigns/details.md)).

## Do it from code

```ts
const id = 'cmp_7mt3e31YJCj3DNk2oDWxNc';
const batches = await norbix.hub.notifications.getEmailCampaignBatches({ id });
const batchId = batches.list.items[0].batchId; // cmpb_…
const { list } = await norbix.hub.notifications.getEmailCampaignBatchNotifications({ id, batchId });
for (const m of list.items) console.log(m.notificationId, m.recipients.to[0].emailAddress, m.statusHistory.at(-1).status);
// ntf_64zYawP2wag7yh1mGb42l2 ada.lovelace@example.com Completed
// ntf_1SfHqeJpVJesOk9AJXp0cJ alan.turing@example.com Completed
// ntf_3q0dGWi4GC7lozrPsBY8jw grace.hopper@example.com Completed
```

```sh
norbix hub notifications email campaign batches get --id cmp_7mt3e31YJCj3DNk2oDWxNc
```

API: [Get Email Campaign Batches](/codemash/api-reference/notifications/email/get-email-campaign-batches.md) · [Get Email Campaign Batch Notifications](/codemash/api-reference/notifications/email/get-email-campaign-batch-notifications.md) · [Get Email Campaign Batch Notification](/codemash/api-reference/notifications/email/get-email-campaign-batch-notification.md)
