Quickstart
Follow this guide to make your first AgentInbox API request and create a new email inbox.
Prerequisites
You need an AgentInbox account. Sign up at agentinbox.in and generate an API key from the dashboard. The API key starts with
at_live_.Step 1: Get Your API Key
Create an account and generate an API key from the dashboard. The API key starts with at_live_.
Environment Variable
export AgentInbox_API_KEY="at_live_..."Step 2: Create an Inbox
Create a new inbox using the API. You can specify a TTL (time-to-live) in seconds.
bash
curl -X POST https://agentinbox.in/api/v1/inboxes \ -H "Authorization: Bearer $AgentInbox_API_KEY" \ -H "Content-Type: application/json" \ -d '{"ttlSeconds": 3600}'typescript
import { AgentInboxClient } from "AgentInbox"; const client = new AgentInboxClient({ apiKey: process.env.AgentInbox_API_KEY! }); const inbox = await client.inboxes.create({ ttlSeconds: 3600 });console.log(inbox.emailAddress); // "k3v9x2m4q7tz@agentinbox.in"python
from AgentInbox import AgentInboxClient client = AgentInboxClient(api_key="at_live_...")inbox = client.inboxes.create(ttl_seconds=3600)print(inbox.email_address) # "k3v9x2m4q7tz@agentinbox.in"Step 3: Use the Email
Use the generated email address in any signup form, password reset, or verification flow.
Example
Sign up for a service using the temporary email address. The verification email will be sent to the inbox.
Step 4: Wait for the Email
Use the wait API to block until the expected email arrives. This is the most common pattern for automation.
typescript
// Wait for OTPconst wait = await client.waits.create({ inboxId: inbox.id, type: "otp", timeoutSeconds: 120,}); console.log(wait.result?.value); // "123456"python
# Wait for OTPwait = client.waits.create( inbox_id=inbox.id, type="otp", timeout_seconds=120,) print(wait.result.value) # "123456"Step 5: Complete Workflow
Use the workflow API for everything in one call. This creates an inbox and waits for the email automatically.
typescript
// Complete workflow in one callconst workflow = await client.workflows.createInboxAndWait({ waitType: "otp", timeoutSeconds: 120,}); console.log(workflow.inbox.emailAddress);console.log(workflow.wait.result?.value);python
# Complete workflow in one callworkflow = client.workflows.create_inbox_and_wait( wait_type="otp", timeout_seconds=120,) print(workflow.inbox.email_address)print(workflow.wait.result.value)