---
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

---

[API](https://skmtc.net/run-llama/apis/llama-platform.md) · [All operations](https://skmtc.net/run-llama/apis/llama-platform/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/run-llama/llama-platform/versions/b17341164de9/schema)
