← Back to guides
Use Case5 min read

Receive OTPs and verification codes with your AI agent

Let your agent sign up for services, receive one-time passwords, and complete email verification flows — all autonomously.

Overview

Every agent connected to AgentInbox gets its own dedicated email address. This means your agent can use that address to sign up for third-party services, receive one-time passwords (OTPs), and verify accounts without any human intervention. The agent sends and receives real emails — services can't tell it apart from a regular user.

This guide walks through the full flow: getting the agent's email, using it to register on a service, polling for the verification email, and extracting the code to complete signup.

1. Get your agent's email

Use the get_inbox_address tool to retrieve your agent's unique email address. This is the address you'll use for signups and verifications.

Request

// Tool: get_inbox_address
{}

Response

{
  "email": "agent-b4a0@agent-mail.agentinbox.sh",
  "displayName": "agent-b4a0",
  "plan": "free",
  "domain": "agent-mail.agentinbox.sh"
}

Your agent's email address is stable — the same credentials always map to the same address. You can use it across multiple services.

2. Sign up for a service

Use the agent's email address as the signup email on any service. Enter it in the registration form just like a normal email. The agent can also use the send_email tool if the signup process requires sending an email (for example, emailing a registration address or confirming interest).

// Example: agent fills in a signup form
Email: agent-b4a0@agent-mail.agentinbox.sh
Password: ••••••••
[Submit]

The service will send a verification email to your agent's address. That email arrives in the agent's inbox within seconds.

3. Wait for the verification email

Use the get_emails tool with direction: "inbound" to poll for the incoming verification email. The agent should check its inbox shortly after submitting the signup form.

Request

// Tool: get_emails
{
  "limit": 5,
  "direction": "inbound"
}

Response

{
  "emails": [
    {
      "id": "e8f1a2b3-...",
      "from": "noreply@example-service.com",
      "to": "agent-b4a0@agent-mail.agentinbox.sh",
      "subject": "Verify your email address",
      "body": "Your verification code is: 847293. This code expires in 10 minutes.",
      "direction": "inbound",
      "status": "received",
      "created_at": "2026-03-08T14:22:00Z"
    }
  ],
  "total": 1
}

If the email hasn't arrived yet, the agent can poll again after a short interval. Most verification emails arrive within a few seconds.

4. Extract the code

Once the email is retrieved, the agent reads the email body and extracts the OTP or verification link. Since the agent is an LLM, it can parse the code from any format — plain text, HTML, or even embedded in a longer message.

Agent extracts from email body

// Email body:
// "Your verification code is: 847293. This code expires in 10 minutes."

// Agent extracts: 847293

The agent can handle verification links too — extracting the URL from the email body and navigating to it, or pulling a confirmation token from the query string.

5. Example flow

Here's a complete step-by-step example of an agent signing up for a service and completing email verification:

Step 1 — Get email address

Agent calls get_inbox_address and receives agent-b4a0@agent-mail.agentinbox.sh.

Step 2 — Register on the service

Agent uses the email address to create an account on the target service. The service sends a verification email with a 6-digit code.

Step 3 — Poll inbox for verification email

Agent calls get_emails with direction: "inbound" to retrieve recent inbound emails. It checks for a subject matching "verify" or "confirmation".

Step 4 — Extract the 6-digit code

Agent reads the email body and extracts the 6-digit verification code. For example, from "Your code is: 847293" it extracts 847293.

Step 5 — Complete verification

Agent submits the code back to the service to complete the email verification. The account is now fully active.

6. Tips

Use short polling intervals

Verification emails typically arrive within seconds. Have the agent poll every 3-5 seconds for a short window rather than waiting a long time between checks.

Filter by recency

Use a small limit (e.g., 3-5) and check the created_at timestamp to find only emails that arrived after the signup was submitted. This avoids confusion with older emails.

Look for common OTP patterns

Most verification emails follow predictable patterns. Look for subjects containing "verify", "confirm", or "code". In the body, look for 4-8 digit numbers or URLs with tokens. The agent can use regex patterns like \b\d{4,8}\b to extract numeric codes.