Extractions
Automatically extract structured data from emails. AgentInbox provides 8 built-in extraction types, plus LLM-powered fallback for anything else.
Extraction Pipeline
Extraction Types
Extractions are created automatically when messages arrive, waits complete, or you call the message extraction endpoint. The system uses pattern matching and heuristics optimized for each type.
otp
One-time passcodes, typically 4-8 digits. Common in 2FA and verification flows.
magic_link
Account verification and sign-in links. Extracts the primary clickable URL.
verification_code
Alphanumeric verification codes, often longer than simple OTPs.
invoice_number
Invoice identifiers from billing and payment confirmation emails.
tracking_number
Shipping and delivery tracking codes from carriers.
api_token
API keys, access tokens, and bearer tokens from developer emails.
coupon_code
Discount codes and promotional coupons from marketing emails.
password_reset_link
Password reset URLs from account recovery emails.
Extracting a Message
Extract data from a message that has already been received.
curl -X POST https://agentinbox.in/api/v1/messages/00000000-0000-4000-8000-000000000002/extract \ -H "Authorization: Bearer $AGENTINBOX_API_KEY" \ -H "Content-Type: application/json"const extractions = await client.messages.extract("00000000-0000-4000-8000-000000000002");console.log(extractions.data[0]?.value); // "123456"console.log(extractions.data[0]?.confidence); // 0.98extractions = client.messages.extract("00000000-0000-4000-8000-000000000002")first = extractions["data"][0]print(first["value"]) # "123456"print(first["confidence"]) # 0.98/api/v1/messages/{id}/extractExtract structured data from a message
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| useLlm | boolean | Optional | Pass as a query parameter to enable LLM fallback. |
Responses
{ "object": "list", "data": [ { "id": "00000000-0000-4000-8000-000000000005", "messageId": "00000000-0000-4000-8000-000000000002", "type": "otp", "value": "123456", "confidence": 0.98, "createdAt": "2024-06-12T10:30:00Z" } ]}{ "error": { "code": "not_found", "message": "Message not found." }}Confidence Scores
Each extraction returns a confidence score between 0 and 1. Higher values indicate more reliable results.
Confidence Thresholds
0.90 - 1.00
High confidence, result is very likely correct
0.70 - 0.89
Medium confidence, verify if critical
Below 0.70
Low confidence, consider LLM fallback or manual review
LLM Fallback
When pattern matching fails, AgentInbox can use an LLM to extract the value. This is slower but more flexible for unusual formats.
curl -X POST "https://agentinbox.in/api/v1/messages/00000000-0000-4000-8000-000000000002/extract?useLlm=true" \ -H "Authorization: Bearer $AGENTINBOX_API_KEY" \ -H "Content-Type: application/json"