---
title: "Extract structured data from text"
method: POST
path: "/txt/to-struct"
tags: ["Smart Conversion"]
---

# Extract structured data from text

`POST /txt/to-struct`

## Request

- Base URL: `https://api.filegraph.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.filegraph.ai/txt/to-struct`
- Auth: API key in header `X-API-Key`

Extract structured data from text into JSON that matches your data structures.

Use this endpoint when you already have text content and don't need file upload.
For file uploads, use `/any/to-struct` instead.

## Request Body

```json
{
  "text": "John Doe\njohn@example.com\nSkills: Python, FastAPI...",
  "schema": {
    "type": "object",
    "properties": {
      "name": {"type": "string", "description": "Full name"},
      "email": {"type": "string", "format": "email", "description": "Email address"}
    }
  }
}
```

## Schema Requirements

All fields must include a `description` to help the LLM understand what to extract.

## Rate Limiting
This endpoint has 3x rate limit weight due to LLM processing costs.

## Request body

- TextToStructRequest: Request body for /txt/to-struct endpoint.
  - `text` string, required: Text content to extract structured data from
  - `schema` object, required: JSON Schema defining fields to extract

## Response `200`

Structured data successfully extracted

- TextStructuredExtractionResponse: Response for text-to-struct extraction endpoint. Similar to StructuredExtractionResponse but without file-specific fields like format_detected, raw_text, and used_ocr.
  - `extracted_data` object, required: Extracted data matching the provided schema
  - `model_used` string, required: LLM model used for extraction
  - `processing_time_ms` integer, required: Total processing time in milliseconds

## Other responses

- `400`: Invalid schema
- `401`: Invalid or missing API key
- `402`: Insufficient credits for this operation
- `422`: LLM extraction failed
- `500`: Unexpected internal error
- `503`: LLM not configured

---

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