---
title: "Generate or modify a JSON schema based on a search query"
method: POST
path: "/v1/generate_schema"
tags: ["SchemaGenerator"]
---

# Generate or modify a JSON schema based on a search query

`POST /v1/generate_schema`

Generate a refined search prompt and a structured JSON schema for analyzing search results.
    Optionally modify an existing schema to better fit the current search query.

## Request body

- SchemaGenerationRequest — Request model for schema generation
  - `user_prompt` string, required — The user's search query to be refined
  - `existing_schema` object, nullable — Optional existing JSON schema to modify/extend

## Response `200`

Successful Response

- SchemaGenerationResponse — Response model for schema generation
  - `request_id` string, uuid, required
  - `status` string, required
  - `user_prompt` string, required
  - `refined_prompt` string, required — The refined search query
  - `generated_schema` object, required — The generated JSON schema
  - `error` string, nullable

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/scrapegraphai/apis/fastapi.md) · [All operations](https://skmtc.dev/scrapegraphai/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/scrapegraphai/fastapi/revisions/7583b63abb6e/schema)
