The Prompt API allows you to manage prompts that are used to generate SQL queries and natural language responses. This API provides endpoints for creating, retrieving, updating, and deleting prompts.
To create a new prompt, send a POST request to /api/v1/prompts:
Request:
POST /api/v1/prompts
Content-Type: application/json
{
"text": "Generate a sales report for the last month",
"db_connection_id": "db123",
"schemas": ["public"],
"context": [{"user": "admin"}],
"metadata": {"created_by": "admin"}
}
Response:
{
"id": "prompt123",
"text": "Generate a sales report for the last month",
"db_connection_id": "db123",
"schemas": ["public"],
"context": [{"user": "admin"}],
"metadata": {"created_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
Retrieving All Prompts
To retrieve a list of all prompts, send a GET request to /api/v1/prompts:
Request:
GET /api/v1/prompts
Response:
[
{
"id": "prompt123",
"text": "Generate a sales report for the last month",
"db_connection_id": "db123",
"schemas": ["public"],
"context": [{"user": "admin"}],
"metadata": {"created_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
]
Retrieving a Specific Prompt
To retrieve a specific prompt, send a GET request to /api/v1/prompts/{prompt_id}:
Request:
GET /api/v1/prompts/prompt123
Response:
{
"id": "prompt123",
"text": "Generate a sales report for the last month",
"db_connection_id": "db123",
"schemas": ["public"],
"context": [{"user": "admin"}],
"metadata": {"created_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
Updating a Prompt
To update a prompt, send a PUT request to /api/v1/prompts/{prompt_id}:
Request:
PUT /api/v1/prompts/prompt123
Content-Type: application/json
{
"text": "Generate a detailed sales report for the last quarter",
"db_connection_id": "db123",
"schemas": ["public"],
"context": [{"user": "admin"}],
"metadata": {"updated_by": "admin"}
}
Response:
{
"id": "prompt123",
"text": "Generate a detailed sales report for the last quarter",
"db_connection_id": "db123",
"schemas": ["public"],
"context": [{"user": "admin"}],
"metadata": {"updated_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
Deleting a Prompt
To delete a prompt, send a DELETE request to /api/v1/prompts/{prompt_id}:
Request:
DELETE /api/v1/prompts/prompt123
Response:
{
"id": "prompt123",
"text": "Generate a detailed sales report for the last quarter",
"db_connection_id": "db123",
"schemas": ["public"],
"context": [{"user": "admin"}],
"metadata": {"updated_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}