Extractions

Automatically extract structured data from emails. AgentInbox provides 8 built-in extraction types, plus LLM-powered fallback for anything else.

Extraction Pipeline

AgentInbox uses a multi-layer extraction pipeline: pattern matching, heuristics, and LLM fallback. The system automatically selects the best method for each type.

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.

bash
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"
}'
POST/api/v1/extractions

Extract structured data from a message

Parameters

NameTypeRequiredDescription
messageIdstringRequiredThe message to extract data from.
typestringRequiredOne of the supported extraction types.

Responses

HTTP 201
{
"id": "ext_abc",
"messageId": "msg_456",
"type": "otp",
"value": "123456",
"confidence": 0.98,
"method": "pattern",
"createdAt": "2024-06-12T10:30:00Z"
}

Confidence Scores

Each extraction returns a confidence score between 0 and 1. Higher values indicate more reliable results.

Confidence Thresholds

For critical operations, consider requiring a confidence score of 0.90 or higher. For non-critical flows, 0.70 may be acceptable.

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.

Enable LLM fallback
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
}'

Next Steps