---
title: "Create database query with assertions and variables"
method: POST
path: "/database/query/generated"
tags: ["DatabaseQueryExecution"]
---

# Create database query with assertions and variables

`POST /database/query/generated`

## Request body

- GenerateQueryRequest — Extension of GenerateCodeRequest for generating database queries
  - `workspace_id` string, required — The ID of the workspace that is requesting the code generation
  - `snippet_type` 'css' | 'javascript' | 'xpath' | 'sql' | 'postman'
  - `test_type` 'api' | 'browser' | 'performance' | 'mobile' — Type of test
  - `name` string — The name of the snippet
  - `prompt` string — Client provided prompt for code snippet generation
  - `additional_context` string — Additional context for the code generation request
  - `parameters` SnippetParameter[] — Snippet parameters supplied to the snippet
    - `id` string, required — The ID of the parameter
    - `name` string, required — The name of the parameter
    - `description` string — The description of the parameter
    - `default_value` string — The default value of the parameter
  - `current_snippet` string — The current snippet body for the code generation request
  - `session_id` string — The session id for the prompt
  - `override` GenAiOverrideOptions
    - `model_id` string — The model ID to use instead of the default model used by the endpoint
    - `meta_prompt` string — The meta-prompt to use instead of the default used by the endpoint
    - `temperature` number, float — The temperature to use instead of the default used by the endpoint
  - `database_schema_query_execution_id` string — ID of query result with the database schema
  - `database_type` 'mariadb' | 'mongodb' | 'mssql' | 'mysql' | 'oracle' | 'postgres'

## Response `200`

The generated DatabaseQueryExecution entity for the requested execution

- GenerateQueryResult — Query generator result
  - `body` string — The code generated by the AI model
  - `description` string — An optional extended description field for the generated result
  - `prompt_id` string — The id of the prompt request
  - `session_id` string — The session id for the prompt
  - `success` boolean — Indicates if the code generation was successful
  - `title` string — A brief description of the generated code result
  - `user_id` string — The id of the user asking for the prompt
  - `workspace_id` string — The workspace id
  - `query` string — Generated SQL query
  - `nosql_operation` object — Generated operation details for non-SQL query operations
  - `parameters` GeneratedQueryParameter[] — Parameters for the generated query
    - `name` string — Parameter name
    - `value` string — Parameter value

## Other responses

- `400` — Invalid or missing parameter
- `401` — User not authenticated
- `403` — User not authorized
- `default` — Unknown error

---

[API](https://skmtc.net/mabl/apis/mabl-api.md) · [All operations](https://skmtc.net/mabl/apis/mabl-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mabl/mabl-api/revisions/d0fc0114da66/schema)
