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.in"; 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"] if wait.result else None) # "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.waits.createInboxAndWait({ waitType: "otp", timeoutSeconds: 120,}); console.log(workflow.inbox.emailAddress);console.log(workflow.wait.result?.value);python
# Complete workflow with the REST APIimport osimport requests resp = requests.post( "https://agentinbox.in/api/v1/workflow/create-inbox-and-wait", headers={"Authorization": f"Bearer {os.environ['AGENTINBOX_API_KEY']}"}, json={"waitType": "otp", "timeoutSeconds": 120},)resp.raise_for_status()workflow = resp.json() print(workflow["inbox"]["emailAddress"])print(workflow["wait"]["result"]["value"])