---
title: "Generates code for a Snippet"
method: POST
path: "/snippets/generated"
tags: ["snippet"]
---

# Generates code for a Snippet

`POST /snippets/generated`

## Request body

- GenerateCodeRequest — Codegen request configurations
  - `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

## Response `201`

The prompt result

- GenerateCodeResult — Code 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

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