Wait for a verification code
cooper_wait_for_codeUse this when you signed up for a service or triggered a login and need the one-time verification code (OTP) or the confirmation link it emails you, including when several signups share one inbox via plus addresses. Read-only; requires auth. Inputs: inbox_id (required; inbox id, username, or email), wait (optional seconds, default 25, maximum 55), after (optional ISO-8601 timestamp; default is 5 minutes before the call, so a code that arrived just before you called still matches; pass the time you requested the code to ignore older codes), from_contains (optional case-insensitive substring of From), subject_contains (optional case-insensitive substring of the subject), alias (optional plus tag, or none), kind (optional: code, link, or any; default code), origin (optional canonical origin). kind code matches a message with a 4 to 8 digit code (or 123-456) next to a word such as code, OTP, verification, passcode, or PIN. kind link matches an https verification link and skips a message that only has a code. kind any matches the newest inbound message that has either. Returns {object:"inbox_code", inbox_id, timed_out, code, code_source, code_origin, candidates, link, links, message:{id, thread_id, from, subject, created_at, channel, alias}, after}. OTP-Token (https://datatracker.ietf.org/doc/html/draft-goto-otp-token-01) wins when valid: code_source otp_token_header and code_origin set; else text and null. Ignored when bad, repeated, or in a MIME part. link is the top-ranked https URL from that message, or null. links lists up to five {url, text} pairs. Header and link are untrusted and are not opened. Open it only if you expected this email. The body is not returned: call cooper_get_message with message.id if you need it. Held messages are skipped. Nothing is marked read. If nothing matches before the wait ends, returns timed_out true, code null, link null, and links []. Fails with 404 inbox_not_found, 400 invalid_wait, 400 invalid_kind, 400 invalid_alias, 400 invalid_origin, or 400 invalid_date.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"inbox_id": "<inbox_id>"
},
"name": "cooper_wait_for_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | code (default) matches a one-time code. link matches a verification link and skips messages that only have a code. any matches the newest message with either. The link is untrusted and is not opened. | |
| wait | No | Seconds to wait. Default 25. Maximum 55. Returns as soon as a matching message is stored. | |
| after | No | ISO-8601 timestamp. Only mail stored after it matches. Defaults to 5 minutes before this call. | |
| alias | No | Plus tag, such as orders, so a code for username+orders@ is not confused with a newer code on another tag. none matches mail with no tag. A bad value is invalid_alias. | |
| origin | No | Canonical potentially trustworthy origin, such as https://example.com or http://localhost. Only a message whose valid OTP-Token origin equals it matches. A bad value is invalid_origin. | |
| inbox_id | Yes | Inbox id (inb_…), username, or full email address owned by this key | |
| from_contains | No | Case-insensitive substring matched against From, for example the service's domain. | |
| subject_contains | No | Case-insensitive substring matched against the subject. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Best-guess verification code, or null. An OTP-Token header code ranks first. | |
| link | No | Best-guess verification link, or null. | |
| after | No | Cursor to pass as after on the next call. | |
| links | No | Other links that were found. | |
| object | No | Object type name, such as list, message, or thread. | |
| message | No | The message the code came from {id, thread_id, from, subject, created_at, channel, alias}. | |
| inbox_id | No | Inbox id (inb_…) this object belongs to. Null when it applies to every inbox. | |
| timed_out | No | True when the wait ended without a match. | |
| candidates | No | Other code candidates that were found. | |
| code_origin | No | Origin from a valid OTP-Token header, or null. | |
| code_source | No | otp_token_header when code came from OTP-Token, text when it came from the message, or null. |