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

## Request

- Base URL: `https://api.scrapegraphai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.scrapegraphai.com/v1/generate_schema`
- Auth: none declared

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/scrapegraphai-api.md) - [All operations](https://skmtc.dev/scrapegraphai/apis/scrapegraphai-api/llms.txt) - [OpenAPI document](https://skmtc.dev/scrapegraphai/apis/scrapegraphai-api/revisions/a0e42195429f?raw)
