---
title: "Extract attachment text"
method: GET
path: "/v1/attachments/{messageId}/{filename}/text"
tags: ["attachments"]
---

# Extract attachment text

`GET /v1/attachments/{messageId}/{filename}/text`

## Request

- Base URL: `https://api.openmail.sh`
- URL: `https://api.openmail.sh/v1/attachments/{messageId}/{filename}/text`
- Auth: HTTP bearer

Extracts and returns the plain text content of an attachment. Supports PDF, DOCX, XLSX, PPTX, images (via OCR), and other common formats. The result is cached on the message after the first extraction.

## Path parameters

- `messageId` string, required
- `filename` string, required

## Response `200`

Extracted text content

- object: Extracted text content
  - `filename` string
  - `inboxId` string: Inbox the parent message belongs to
  - `contentType` string
  - `extractionMethod` string: Method used to extract text (e.g. pdf, docx, ocr)
  - `text` string

## Other responses

- `404`: Attachment not found
- `422`: Text could not be extracted from the attachment

---

[API](https://skmtc.dev/openmail/apis/openmail-api.md) · [All operations](https://skmtc.dev/openmail/apis/openmail-api/llms.txt) · [OpenAPI document](https://skmtc.dev/openmail/apis/openmail-api/revisions/b943eecca7e2?raw)
