---
title: "Generate Extraction Schema"
method: POST
path: "/api/v1/extraction/extraction-agents/schema/generate"
tags: ["LlamaExtract"]
---

# Generate Extraction Schema

`POST /api/v1/extraction/extraction-agents/schema/generate`

Generate or refine an extraction agent schema from a file, natural-language prompt, or existing schema.

## Query parameters

- `project_id` string, uuid, nullable
- `organization_id` string, uuid, nullable

## Cookies

- `session` string, nullable

## Request body

- ExtractSchemaGenerateRequest — Request schema for generating an extraction schema.
  - `prompt` string, nullable — Natural language description of the data structure to extract
  - `file_id` string, uuid, nullable — Optional file ID to analyze for schema generation
  - `data_schema` union — Optional schema to validate, refine, or extend during generation
    - object
    - string

## Response `200`

Successful Response

- ExtractSchemaGenerateResponse — Response schema for schema generation.
  - `data_schema` object, required — The generated JSON schema

## Other responses

- `422` — Validation Error

## Changes

- **2026-06-09** `614771991b52` — 2 warning
  - removed the optional property `detail/items/ctx` from the response with the `422` status
  - removed the optional property `detail/items/input` from the response with the `422` status
- **2026-06-09** `b17341164de9` — 2 info
  - added the optional property `detail/items/ctx` to the response with the `422` status
  - added the optional property `detail/items/input` to the response with the `422` status

[Change history](https://skmtc.dev/run-llama/apis/llama-platform/changes/api/v1/extraction/extraction-agents/schema/generate/post.md)

---

[API](https://skmtc.dev/run-llama/apis/llama-platform.md) · [All operations](https://skmtc.dev/run-llama/apis/llama-platform/llms.txt) · [OpenAPI document](https://skmtc.dev/run-llama/apis/llama-platform/revisions/614771991b52?raw)
