Sending

How to add tags and custom headers to an email

Short answer

Tags are your own labels on an email, such as the flow or the customer id. Send them as a list of name and value pairs in tags on POST /v1/emails; they come back in every webhook for that email and can be used to filter the Emails page. Custom headers go in headers as an object of header names to string values and are added to the message as sent.

Last checked 16 November 2026

Tags help you find and route your own emails. Headers change the message itself.

To add tags

Send tags as a list of name and value pairs:

curl https://api.mailcandor.com/v1/emails \
  -H "Authorization: Bearer $MAILCANDOR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme <hello@acme.com>",
    "to": "sam@example.com",
    "subject": "Your login code",
    "text": "Your code is 481 203",
    "tags": [
      { "name": "flow", "value": "login" },
      { "name": "user_id", "value": "77" }
    ]
  }'

Tags are stored with the email and returned exactly as you sent them in every webhook about it, for example:

{
  "type": "email.delivered",
  "data": {
    "email_id": "3f1c0e2a-...",
    "subject": "Your login code",
    "tags": [ { "name": "flow", "value": "login" }, { "name": "user_id", "value": "77" } ],
    "recipient": "sam@example.com"
  }
}

The API also accepts an object such as {"flow": "login"} and returns it unchanged in webhooks, but the dashboard’s tag filter only matches the list format. Use the list.

To find emails by tag

  1. Open Emails in the dashboard.
  2. Open the filters and fill in Tag name and, optionally, Tag value.

Each email’s page also lists its tags.

Tags Mailcandor sets itself:

  • Broadcast emails carry broadcast_id.
  • SendGrid-compatible sends turn categories into tags named category.
  • Postmark-compatible sends turn Tag into a tag named tag.

To add custom headers

Send headers as an object of header names to string values:

{
  "from": "Acme <hello@acme.com>",
  "to": "sam@example.com",
  "subject": "Order 1042 shipped",
  "html": "<p>On its way.</p>",
  "headers": {
    "X-Entity-Ref-ID": "order-1042-shipped",
    "List-Unsubscribe": "<https://acme.com/unsubscribe?u=77>"
  }
}

Headers are added to the message as given. Use them for things such as:

  • X-Entity-Ref-ID with a unique value, which some mail apps use to stop threading similar emails together.
  • List-Unsubscribe and List-Unsubscribe-Post on marketing-style mail you send through the API. See RFC 8058.
  • Your own X- headers for tracing.

Do not set From, To, Subject or other standard headers here: use the matching fields.

Over SMTP

The relay keeps custom headers whose names start with X- and drops other custom headers. Tags are not available over SMTP.

If it does not work

  • Tag filter finds nothing: the email was sent with tags as an object. Send them as a list of name/value pairs.
  • A header is missing in the received email: over SMTP, only X- headers pass through. Over the API, check the header name is spelled correctly and the value is a string.
  • Tags missing in webhooks: emails sent without tags have no tags field in the webhook.

Full reference: docs.mailcandor.com.

Questions

Do recipients see tags?

No. Tags stay inside Mailcandor: in the log, the dashboard and your webhooks. Headers, on the other hand, are part of the message.

Which tag format should I use?

A list of objects with name and value, like [{"name": "flow", "value": "login"}]. That is the format the dashboard's tag filter searches.

Can I set tags over SMTP?

No. The SMTP relay does not take tags. Use the API if you need them.

Can I add a List-Unsubscribe header to a transactional email?

Yes, through headers. Broadcasts add List-Unsubscribe and List-Unsubscribe-Post for you.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.