Agent Email
API reference for agent email endpoints
Agent Email API
Send and receive email from your agent's dedicated address (agent-{id}@agent.agnic.ai).
Base URL: https://api.agnic.ai
Authentication: All endpoints use authenticateFlexible — pass either Authorization: Bearer <oauth_token> or X-Agnic-Token: <api_token>.
Get Email Alias
Retrieve the agent's email alias information.
Response:
Example:
Create Email Alias
Create or retrieve an email alias for the agent. Idempotent — returns existing alias if one exists.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
displayName | string | No | Display name for outgoing emails |
Example:
Get Inbox
Fetch the agent's email inbox (newest first).
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 20 | Max messages to return (max: 100) |
offset | number | 0 | Pagination offset |
Response:
Example:
Send Email
Send an email from the agent's address.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
to | string or string[] | Yes | Recipient email address(es) |
subject | string | Yes | Email subject line |
body | string | Yes | Email body (plain text) |
Response:
Example:
Reply to Message
Reply to an inbox message. Maintains email threading.
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
messageId | string | Yes | ID of the message to reply to |
body | string | Yes | Reply body (plain text) |
Response:
Example:
Inbound Webhook
Resend sends inbound email events to this endpoint. Not called directly by users.
Headers: Svix signature headers (svix-id, svix-timestamp, svix-signature)
Payload:
The server fetches the full email body via GET /emails/receiving/{email_id} from the Resend API.
Error Responses
| Status | Error | Description |
|---|---|---|
| 400 | "No active agent found" | Complete onboarding first |
| 400 | "Missing required fields" | Check required fields in request body |
| 404 | "No email alias found" | Create alias with POST /api/agent/email |
| 502 | "Failed to send email" | Resend API error |
| 503 | "Email sending not configured" | RESEND_API_KEY not set on server |