Agent Identity
← GUIDES · COMPARISONS

Should you build AI agent email and phone on SendGrid and Twilio yourself?

By Naol Ketema, founder · · Markdown

SHORT ANSWER

Build on SendGrid and Twilio yourself if you need full control, already have contracts with them, or need SMS today; both are mature and scale far. If you want each agent to have its own inbox, threaded replies, a phone number and an event it can wait on without writing that layer, a platform like Agent Identity saves the glue code. The raw APIs give you transport; the per-agent identity, threading and event log are yours to build.

What SendGrid and Twilio give you

Twilio SendGrid is an email API for "delivery at scale." Twilio provides phone numbers, voice and SMS. Both are mature, widely used and well documented. They are the transport layer: they move messages and audio.

  • Outbound email through the SendGrid Email API, with dedicated IPs included on Pro and Premier.
  • Inbound email through Inbound Parse: point an MX record at mx.sendgrid.net on a dedicated hostname, and each message is POSTed to your URL as multipart/form-data with headers, text, html, from, to, attachments, and DKIM and SPF results.
  • Phone numbers, inbound and outbound calls, and SMS from Twilio.
  • Media Streams: "capture, transmit, and receive raw audio from live voice calls over WebSockets in near real-time," started bidirectionally with <Connect><Stream>.

What you still have to build

An AI agent needs more than transport. It needs an address that is its own, a memory of the conversation, and a way to wake up when someone answers. With the raw APIs, that layer is yours:

  • Step 1, identity: a table of agents, each with an address on your parse hostname, and routing from the To address to the right agent.
  • Step 2, storage: persist every inbound and outbound message and its attachments.
  • Step 3, threading: set Message-ID on sends, then match replies by In-Reply-To, then References, then subject.
  • Step 4, events: turn webhooks into something an agent can wait on, with a cursor so nothing is missed while it is offline.
  • Step 5, safety: idempotency on sends, allow and block lists checked on send and on ingest, per-agent credentials, a way to stop one agent.
  • Step 6, delivery status: map delivered, bounced and complained callbacks back to the message that caused them.
  • Step 7, voice: a WebSocket server for Media Streams, speech-to-text, text-to-speech and turn-taking, or a voice agent product on top.

None of this is exotic, and a team that owns it gets exactly the behaviour it wants. It is also weeks of work that is not your agent.

Costs on the raw APIs, as of October 2026

  • SendGrid Email API: free trial of 100 emails a day for 60 days, Essentials from $19.95 a month, Pro from $89.95 a month, Premier custom.
  • Twilio US local number: $1.15 a month.
  • Twilio US voice: $0.0085 a minute inbound, $0.0140 a minute outbound on local numbers.
  • Twilio US SMS: $0.0083 per segment in or out, plus carrier fees. US A2P 10DLC senders are subject to registration fees.
  • Add your own costs: speech models for voice, storage, and the engineering time to run it.

What Agent Identity does instead

Agent Identity is that layer as a hosted API. Creating an agent provisions its mailbox in the same call. Inbound mail is threaded by In-Reply-To, then References, then subject, stored, and appended to an event log as mail.received. Delivery statuses arrive as mail.delivered, mail.bounced and mail.complained. Contact rules are enforced on send and on ingest. Each agent can have its own API key, and an org key can suspend it with a recorded reason.

Phone works the same way: one voice number per agent, answered by Aid Voice with no server, or streamed to your agent over a WebSocket as text. Texts are not available yet.

A complete email agent is one loop:

import { AgentClient } from "@agentidentity/sdk";

const client = new AgentClient({
  baseUrl: "https://api.agent-identity.dev",
  apiKey: process.env.AID_KEY!,
});

const identityId = process.env.AID_AGENT!;

for await (const event of client.events.subscribe({ type: "mail.received", identityId })) {
  const thread = await client.mail.getThread(identityId, event.payload.threadId);
  const reply = await compose(thread); // your LLM call

  await client.mail.send({
    identityId,
    to: [event.payload.from!],
    subject: `Re: ${thread.subject ?? ""}`,
    text: reply,
    inReplyToMessageId: event.payload.messageId,
    idempotencyKey: `reply-${event.payload.messageId}`,
  });
}

subscribe advances its cursor from each event's own timestamp, re-polls when the wait window closes and retries with backoff. The idempotency key comes from the inbound message, so a crash and restart never sends the same reply twice.

When to build it yourself

  • You need SMS today. Twilio has it; Agent Identity does not yet.
  • You send at high volume and want to negotiate rates and dedicated IPs directly.
  • You need international numbers or calls outside +1. Agent Identity's hosted calls go to the US and Canada.
  • You have compliance or data-residency rules that require your own infrastructure.
  • Your team already runs SendGrid and Twilio and has the threading and event layer built.

When a platform is the better trade

  • You want each agent to have its own address and key from the first day.
  • Your agent's logic is "send, then wait for the reply," and you do not want to build a durable event log to support it.
  • You want calls answered without running a voice server.
  • You also want agents to trade tasks with other agents over A2A.

We built Agent Identity after writing this glue more than once. Our own sales agent runs on it rather than on raw provider APIs.

FAQ

Can I use SendGrid Inbound Parse to give each agent its own address?

Yes. Point a dedicated hostname's MX at mx.sendgrid.net and route each POST by its to field. You then store, thread and notify the agent yourself.

Is Twilio Media Streams enough to build a voice agent?

It gives you the live audio over a WebSocket, both ways. You still add speech-to-text, a model, text-to-speech and turn-taking on your side.

Does Agent Identity replace Twilio for SMS?

No. Agent Identity phone is calls only for now; texts are not available yet.

Can I keep my own domain on Agent Identity?

Yes. Verify it with a TXT record, publish the SPF, DKIM and DMARC records it lists, and point MX at the provider to receive.

Related guides

Give your agent its own identity in a couple of minutes. Get started free → · Docs · All guides