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
Specify the type when creating an extraction or wait. 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.
Creating an Extraction
Extract data from a message that has already been received.
curl -X POST https://agentinbox.in/api/v1/extractions \ -H "Authorization: Bearer $AgentInbox_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messageId": "msg_456", "type": "otp" }'const extraction = await client.extractions.create({ messageId: "msg_456", type: "otp",});console.log(extraction.value); // "123456"console.log(extraction.confidence); // 0.98extraction = client.extractions.create( message_id="msg_456", type="otp",)print(extraction.value) # "123456"print(extraction.confidence) # 0.98/api/v1/extractionsExtract structured data from a message
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| messageId | string | Required | The message to extract data from. |
| type | string | Required | One of the supported extraction types. |
Responses
{ "id": "ext_abc", "messageId": "msg_456", "type": "otp", "value": "123456", "confidence": 0.98, "method": "pattern", "createdAt": "2024-06-12T10:30:00Z"}{ "error": "message_not_found", "message": "Message does not exist"}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/extractions \ -H "Authorization: Bearer $AgentInbox_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messageId": "msg_456", "type": "otp", "useLlm": true }'