Skip to content
Email parsing

email.parse

Parse an RFC 5322 email into headers, addresses, MIME bodies, attachments, and thread IDs.

POSThttps://api.kanagu.dev/v1/email/parse
Price
$0.03 per successful call
Without a key
10 free calls per IP per UTC day, shared by REST and MCP.
MCP tool
email.parse at https://api.kanagu.dev/mcp
curl https://api.kanagu.dev/v1/email/parse \
  -H "Content-Type: application/json" \
  -d '{"text":"From: Maya Chen <maya@example.com>\r\nTo: Dev Team <dev@example.net>\r\nSubject: Re: Import window for December\r\nDate: Mon, 23 Nov 2026 09:30:00 -0500\r\nMessage-ID: <import-window-2@example.com>\r\nIn-Reply-To: <import-window-1@example.net>\r\nReferences: <import-window-1@example.net>\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThe next import will start at 10:00 a.m. Eastern on December 1."}'
curl https://api.kanagu.dev/v1/email/parse \
  -H "Authorization: Bearer $KANAGU_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"From: Maya Chen <maya@example.com>\r\nTo: Dev Team <dev@example.net>\r\nSubject: Re: Import window for December\r\nDate: Mon, 23 Nov 2026 09:30:00 -0500\r\nMessage-ID: <import-window-2@example.com>\r\nIn-Reply-To: <import-window-1@example.net>\r\nReferences: <import-window-1@example.net>\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThe next import will start at 10:00 a.m. Eastern on December 1."}'
const res = await fetch("https://api.kanagu.dev/v1/email/parse", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KANAGU_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "text": "From: Maya Chen <maya@example.com>\r\nTo: Dev Team <dev@example.net>\r\nSubject: Re: Import window for December\r\nDate: Mon, 23 Nov 2026 09:30:00 -0500\r\nMessage-ID: <import-window-2@example.com>\r\nIn-Reply-To: <import-window-1@example.net>\r\nReferences: <import-window-1@example.net>\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThe next import will start at 10:00 a.m. Eastern on December 1."
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const result = await res.json();
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "email.parse",
    "arguments": {
      "text": "From: Maya Chen <maya@example.com>\r\nTo: Dev Team <dev@example.net>\r\nSubject: Re: Import window for December\r\nDate: Mon, 23 Nov 2026 09:30:00 -0500\r\nMessage-ID: <import-window-2@example.com>\r\nIn-Reply-To: <import-window-1@example.net>\r\nReferences: <import-window-1@example.net>\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThe next import will start at 10:00 a.m. Eastern on December 1."
    }
  }
}
Request body
{
  "text": "From: Maya Chen <maya@example.com>\r\nTo: Dev Team <dev@example.net>\r\nSubject: Re: Import window for December\r\nDate: Mon, 23 Nov 2026 09:30:00 -0500\r\nMessage-ID: <import-window-2@example.com>\r\nIn-Reply-To: <import-window-1@example.net>\r\nReferences: <import-window-1@example.net>\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThe next import will start at 10:00 a.m. Eastern on December 1."
}
Response · 200
{
  "addresses": {
    "from": [
      {
        "name": "Maya Chen",
        "address": "maya@example.com"
      }
    ],
    "to": [
      {
        "name": "Dev Team",
        "address": "dev@example.net"
      }
    ]
  },
  "subject": "Re: Import window for December",
  "date": "2026-11-23T14:30:00.000Z",
  "text": "The next import will start at 10:00 a.m. Eastern on December 1.\n",
  "attachments": [],
  "thread": {
    "messageId": "<import-window-2@example.com>",
    "inReplyTo": [
      "<import-window-1@example.net>"
    ],
    "references": [
      "<import-window-1@example.net>"
    ]
  }
}

Request body

application/json

includeContentboolean
Include decoded attachment bytes as Base64.

Then exactly one of these 2 shapes:

1. With text

textstring (max 1048576 chars)required
UTF-8 email, up to 1 MiB.

2. With base64

base64string (base64, max 1398104 chars)required
Raw email bytes as Base64, up to 1 MiB decoded. Use for legacy charsets.

Response

200 · application/json

headersarray of objectrequired
headers[].keystringrequired
headers[].originalKeystringrequired
headers[].valuestringrequired
addressesobjectrequired
addresses.fromarray of objectrequired
addresses.senderobject
addresses.replyToarray of objectrequired
addresses.toarray of objectrequired
addresses.ccarray of objectrequired
addresses.bccarray of objectrequired
addresses.returnPathstring
addresses.deliveredTostring
subjectstring
datestring (date-time)
dateRawstring
textstring
htmlstring
Original decoded HTML. Treat as untrusted email content.
attachmentsarray of objectrequired
Attachments at this message level. Parse an attached .eml to inspect its contents.
attachments[].namestring | nullrequired
attachments[].typestringrequired
attachments[].sizeinteger (-9007199254740991 to 9007199254740991)required
attachments[].sha256stringrequired
attachments[].inlinebooleanrequired
attachments[].cidstring
attachments[].contentBase64string
inlineImagesobjectrequired
Content-ID without angle brackets mapped to zero-based attachment indexes.
threadobjectrequired
thread.messageIdstring
thread.inReplyToarray of stringrequired
thread.referencesarray of stringrequired

Try it

email.parse

$0.03/call

No key needed · 10 free calls per IP per day

Response

Run the request to see the live response here.

Errors

Errors are JSON {"error":{"code","message"}}. An operation may add its own 400 codes; the message says what to fix.

StatusCode and meaning
400invalid_input

The body does not match the request schema. The message names each field.

400invalid_json

The body is missing or is not valid JSON.

400invalid_idempotency_key

Idempotency-Key must be 1–128 visible ASCII characters.

401invalid_api_key

The Bearer key is missing, malformed, invalid or inactive.

402free_allowance_exhausted

This month's free usage is used up and the account has no subscription. Subscribe from the dashboard, or wait for the next UTC month; Retry-After gives the seconds left.

404not_found

No operation at this path.

409idempotency_conflict

The Idempotency-Key was already used with a different body.

413payload_too_large

JSON bodies may be at most 64 KiB.

429trial_limit

The anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left.

500internal_error

The call failed on our side. It is not billed; retry with the same Idempotency-Key.

JSON Schema

Request schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "includeContent": {
          "default": false,
          "description": "Include decoded attachment bytes as Base64.",
          "type": "boolean"
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1048576,
          "description": "UTF-8 email, up to 1 MiB."
        }
      },
      "required": [
        "text"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "includeContent": {
          "default": false,
          "description": "Include decoded attachment bytes as Base64.",
          "type": "boolean"
        },
        "base64": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1398104,
          "format": "base64",
          "contentEncoding": "base64",
          "pattern": "^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$",
          "description": "Raw email bytes as Base64, up to 1 MiB decoded. Use for legacy charsets."
        }
      },
      "required": [
        "base64"
      ],
      "additionalProperties": false
    }
  ],
  "examples": [
    {
      "text": "From: Maya Chen <maya@example.com>\r\nTo: Dev Team <dev@example.net>\r\nSubject: Re: Import window for December\r\nDate: Mon, 23 Nov 2026 09:30:00 -0500\r\nMessage-ID: <import-window-2@example.com>\r\nIn-Reply-To: <import-window-1@example.net>\r\nReferences: <import-window-1@example.net>\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nThe next import will start at 10:00 a.m. Eastern on December 1."
    }
  ],
  "type": "object"
}
Response schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "headers": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "originalKey": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "originalKey",
          "value"
        ],
        "additionalProperties": false
      }
    },
    "addresses": {
      "type": "object",
      "properties": {
        "from": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "address"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "group": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "address": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "address"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "name",
                  "group"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "sender": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "address": {
                  "type": "string"
                }
              },
              "required": [
                "name",
                "address"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "group": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "address": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "name",
                      "address"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "name",
                "group"
              ],
              "additionalProperties": false
            }
          ]
        },
        "replyTo": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "address"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "group": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "address": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "address"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "name",
                  "group"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "to": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "address"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "group": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "address": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "address"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "name",
                  "group"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "cc": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "address"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "group": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "address": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "address"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "name",
                  "group"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "bcc": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "address"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "group": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "address": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "address"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "name",
                  "group"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "returnPath": {
          "type": "string"
        },
        "deliveredTo": {
          "type": "string"
        }
      },
      "required": [
        "from",
        "replyTo",
        "to",
        "cc",
        "bcc"
      ],
      "additionalProperties": false
    },
    "subject": {
      "type": "string"
    },
    "date": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
    },
    "dateRaw": {
      "type": "string"
    },
    "text": {
      "type": "string"
    },
    "html": {
      "description": "Original decoded HTML. Treat as untrusted email content.",
      "type": "string"
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "sha256": {
            "type": "string"
          },
          "inline": {
            "type": "boolean"
          },
          "cid": {
            "type": "string"
          },
          "contentBase64": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "type",
          "size",
          "sha256",
          "inline"
        ],
        "additionalProperties": false
      },
      "description": "Attachments at this message level. Parse an attached .eml to inspect its contents."
    },
    "inlineImages": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "description": "Content-ID without angle brackets mapped to zero-based attachment indexes."
    },
    "thread": {
      "type": "object",
      "properties": {
        "messageId": {
          "type": "string"
        },
        "inReplyTo": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "references": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "inReplyTo",
        "references"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "headers",
    "addresses",
    "attachments",
    "inlineImages",
    "thread"
  ],
  "additionalProperties": false
}