---
title: "Discussion on \"How an AI agent waits for a verification code on Cooper Email\" | Hashnode"
description: "Discussion on \"How an AI agent waits for a verification code on Cooper Email\". GET /api/v1/inboxes/:id/wait-for-code holds up to 55 seconds and returns the code plus message id (timed_out when none arrives). GET /api/v1/events?wa"
url: "https://hashnode.com/posts/agent-email-wait-for-code/6ad0d34ecc051465278efd16"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How an AI agent waits for a verification code on Cooper Email](https://cooperemail.hashnode.dev/agent-email-wait-for-code?utm_source=hashnode&utm_medium=feed)

GET /api/v1/inboxes/:id/wait-for-code holds up to 55 seconds and returns the code plus message id (timed\_out when none arrives). GET /api/v1/events?wa

Oct 15 · 8 min read · cooperemail.hashnode.dev  
Read the article

-   [#email](https://hashnode.com/tag/email)
-   [#ai-agents](https://hashnode.com/tag/ai-agents)
-   [#mcp](https://hashnode.com/tag/mcp)
-   [#api](https://hashnode.com/tag/api)

## Written by

[Cooper Email](https://hashnode.com/@cooperemail)

@cooperemail

  
[View profile](https://hashnode.com/@cooperemail)

Real email inboxes for AI agents, via API and MCP. By Avatar 8 LLC.

Real email inboxes for AI agents, via API and MCP. By Avatar 8 LLC.

## Responses 3

Markdown supported · ⌘↵ to post

[StackShortlist](https://hashnode.com/@veristria)

[Oct 17](https://hashnode.com/posts/agent-email-wait-for-code/6ad0d34ecc051465278efd16/comment/6ad2f07a13f22ae0d1413723)

Treating timed\_out as a normal response, with a 55 second cap, fits scripts and CI jobs that can't receive a webhook. Returning the message id next to the code is handy too, since the caller can open the full message if the parsed code looks wrong. Is the after timestamp the intended way to make sure an older code already sitting in the inbox isn't returned?

[Cooper Email](https://hashnode.com/@cooperemail)

[Oct 21](https://hashnode.com/posts/agent-email-wait-for-code/6ad0d34ecc051465278efd16/comment/6ad2f07a13f22ae0d1413723#reply-6ad8385959e12396314dd953)

Yes. after defaults to five minutes before the call, so a code that landed just before you asked still counts. Pass the time you requested the code as after and anything older is ignored. On timed\_out, call again with the same after.

[StackShortlist](https://hashnode.com/@veristria)

[Oct 21](https://hashnode.com/posts/agent-email-wait-for-code/6ad0d34ecc051465278efd16/comment/6ad2f07a13f22ae0d1413723#reply-6ad93d54f387e8efde5270fd)

Good, that default makes sense. Passing the request time as after and retrying with the same value is the part I'd put in a code comment, because it's easy to bump it on each retry and lose the message.
