Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsMay 11, 2026·4 min de lectura

Resend Audiences — Manage Email Lists from AI Agents

Resend Audiences API lets agents add, remove, segment, unsubscribe email recipients. Tag-based segments. Compliant unsubscribe built in.

Listo para agents

Staging seguro para este activo

Este activo primero queda en staging. El prompt copiado pide inspeccionar los archivos staged antes de activar scripts, config MCP o config global.

Stage only · 29/100Política: staging
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Stage only
Confianza
Confianza: Community
Entrada
Asset
Comando de staging seguro
npx -y tokrepo@latest install d826f667-d0f9-4ded-895e-19ed5d774b47 --target codex

Primero deja archivos en staging; la activación requiere revisar el README y el plan staged.

Introducción

Resend Audiences is the list-management API — your agent adds recipients on signup, removes them on unsubscribe, segments by tag, and ships compliant unsubscribe links automatically. No separate ESP, no list-import CSV nightmare. Best for: AI agents that nurture leads, newsletter signup flows, onboarding sequences with per-stage list membership, anywhere your agent needs to send to a managed group. Works with: Resend Node + Python SDKs, REST. Setup time: 5 minutes.


Create an audience

from resend import Resend
client = Resend(api_key=os.environ["RESEND_API_KEY"])

audience = client.audiences.create({"name": "TokRepo Weekly Digest"})
print(audience["id"])   # save this — used for all member ops

Add a contact

client.contacts.create({
    "audience_id": audience_id,
    "email": "jane@example.com",
    "first_name": "Jane",
    "last_name": "Smith",
    "unsubscribed": False,
})

Bulk import on signup

async def on_user_signup(user):
    client.contacts.create({
        "audience_id": WEEKLY_DIGEST_ID,
        "email": user.email,
        "first_name": user.first_name,
        "unsubscribed": False,
    })
    # If user opted into multiple lists, repeat per audience_id

Send a broadcast to an audience

broadcast = client.broadcasts.create({
    "audience_id": WEEKLY_DIGEST_ID,
    "from": "TokRepo Weekly <weekly@tokrepo.com>",
    "subject": "5 new AI assets shipped this week",
    "html": render_weekly_digest_html(this_week_assets),
    "scheduled_at": "in 1 hour",   # or "2026-05-12 09:00:00 -0700"
})
client.broadcasts.send(broadcast["id"])

Compliance: unsubscribe + RFC 8058

Resend automatically:

  • Adds a one-click unsubscribe link to every broadcast email
  • Includes List-Unsubscribe and List-Unsubscribe-Post headers (Gmail/Yahoo 2024 sender requirements)
  • Records unsubscribes against the contact — future sends skip them
# Manually unsubscribe (e.g., from a user-facing preference center)
client.contacts.update({
    "audience_id": WEEKLY_DIGEST_ID,
    "email": "jane@example.com",
    "unsubscribed": True,
})

List members

contacts = client.contacts.list({"audience_id": WEEKLY_DIGEST_ID})
for c in contacts["data"]:
    print(c["email"], c["unsubscribed"])

FAQ

Q: Can I do tag-based segmentation? A: Yes — contacts support arbitrary tag fields. Filter at send time by tag value to create dynamic segments. Use a separate audience per major list type, then tags for sub-segmentation.

Q: How does Audiences compare to Klaviyo / Mailchimp? A: Audiences is a primitive — list + send + unsubscribe + compliance. Klaviyo/Mailchimp layer on visual campaign builders, automations, predictive segments. For AI-agent-driven lists where the agent IS the segmentation engine, Audiences is the right size.

Q: What about double opt-in? A: Not built in — Resend assumes you've collected consent before adding. Implement double opt-in by sending a confirm-email through emails.send with a token URL, and only call contacts.create after the recipient clicks confirm.


Quick Use

  1. client.audiences.create({name}) to make a list
  2. client.contacts.create({audience_id, email, ...}) per signup
  3. client.broadcasts.create + send to ship a campaign with auto-unsubscribe

Intro

Resend Audiences is the list-management API — your agent adds recipients on signup, removes them on unsubscribe, segments by tag, and ships compliant unsubscribe links automatically. No separate ESP, no list-import CSV nightmare. Best for: AI agents that nurture leads, newsletter signup flows, onboarding sequences with per-stage list membership, anywhere your agent needs to send to a managed group. Works with: Resend Node + Python SDKs, REST. Setup time: 5 minutes.


Create an audience

from resend import Resend
client = Resend(api_key=os.environ["RESEND_API_KEY"])

audience = client.audiences.create({"name": "TokRepo Weekly Digest"})
print(audience["id"])   # save this — used for all member ops

Add a contact

client.contacts.create({
    "audience_id": audience_id,
    "email": "jane@example.com",
    "first_name": "Jane",
    "last_name": "Smith",
    "unsubscribed": False,
})

Bulk import on signup

async def on_user_signup(user):
    client.contacts.create({
        "audience_id": WEEKLY_DIGEST_ID,
        "email": user.email,
        "first_name": user.first_name,
        "unsubscribed": False,
    })
    # If user opted into multiple lists, repeat per audience_id

Send a broadcast to an audience

broadcast = client.broadcasts.create({
    "audience_id": WEEKLY_DIGEST_ID,
    "from": "TokRepo Weekly <weekly@tokrepo.com>",
    "subject": "5 new AI assets shipped this week",
    "html": render_weekly_digest_html(this_week_assets),
    "scheduled_at": "in 1 hour",   # or "2026-05-12 09:00:00 -0700"
})
client.broadcasts.send(broadcast["id"])

Compliance: unsubscribe + RFC 8058

Resend automatically:

  • Adds a one-click unsubscribe link to every broadcast email
  • Includes List-Unsubscribe and List-Unsubscribe-Post headers (Gmail/Yahoo 2024 sender requirements)
  • Records unsubscribes against the contact — future sends skip them
# Manually unsubscribe (e.g., from a user-facing preference center)
client.contacts.update({
    "audience_id": WEEKLY_DIGEST_ID,
    "email": "jane@example.com",
    "unsubscribed": True,
})

List members

contacts = client.contacts.list({"audience_id": WEEKLY_DIGEST_ID})
for c in contacts["data"]:
    print(c["email"], c["unsubscribed"])

FAQ

Q: Can I do tag-based segmentation? A: Yes — contacts support arbitrary tag fields. Filter at send time by tag value to create dynamic segments. Use a separate audience per major list type, then tags for sub-segmentation.

Q: How does Audiences compare to Klaviyo / Mailchimp? A: Audiences is a primitive — list + send + unsubscribe + compliance. Klaviyo/Mailchimp layer on visual campaign builders, automations, predictive segments. For AI-agent-driven lists where the agent IS the segmentation engine, Audiences is the right size.

Q: What about double opt-in? A: Not built in — Resend assumes you've collected consent before adding. Implement double opt-in by sending a confirm-email through emails.send with a token URL, and only call contacts.create after the recipient clicks confirm.


Source & Thanks

Built by Resend. Audiences API docs at resend.com/docs/api-reference/audiences.

resend/resend-node — official SDK

🙏

Fuente y agradecimientos

Built by Resend. Audiences API docs at resend.com/docs/api-reference/audiences.

resend/resend-node — official SDK

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados