Skip to content

Prompts API

Create, read, update, and delete prompts.

List Prompts

http
GET /api/v1/prompts

Query Parameters

ParameterTypeDescription
limitnumberMax results (default: 20, max: 100)
offsetnumberPagination offset
tagsstringComma-separated tags to filter
statusstringFilter by status (active, draft, archived)

Response

json
{
  "data": [
    {
      "id": "prompt_123",
      "name": "Customer Support",
      "content": "You are a helpful...",
      "llmModel": "gpt-4o",
      "description": "Main support chatbot",
      "tags": ["support", "production"],
      "status": "active",
      "createdAt": "2025-01-15T10:00:00Z",
      "updatedAt": "2025-01-20T14:30:00Z"
    }
  ],
  "pagination": {
    "total": 15,
    "limit": 20,
    "offset": 0
  }
}

Get Prompt

http
GET /api/v1/prompts/:id

Response

json
{
  "id": "prompt_123",
  "name": "Customer Support",
  "content": "You are a helpful customer support agent...",
  "llmModel": "gpt-4o",
  "description": "Main support chatbot",
  "tags": ["support", "production"],
  "status": "active",
  "createdAt": "2025-01-15T10:00:00Z",
  "updatedAt": "2025-01-20T14:30:00Z"
}

Create Prompt

http
POST /api/v1/prompts

Request Body

json
{
  "name": "Customer Support",
  "content": "You are a helpful customer support agent...",
  "llmModel": "gpt-4o",
  "description": "Main support chatbot",
  "tags": ["support", "production"]
}

Required Fields

FieldTypeDescription
namestringDisplay name
contentstringPrompt content
llmModelstringTarget model (gpt-4o, claude-3-5-sonnet, etc.)

Optional Fields

FieldTypeDescription
descriptionstringWhat this prompt does
tagsstring[]Organization tags
temperaturenumberModel temperature (0-2)
maxTokensnumberMax response tokens

Response

json
{
  "id": "prompt_456",
  "name": "Customer Support",
  "content": "You are a helpful customer support agent...",
  "llmModel": "gpt-4o",
  "status": "active",
  "createdAt": "2025-01-20T14:30:00Z",
  "updatedAt": "2025-01-20T14:30:00Z"
}

Status: 201 Created

Update Prompt

http
PATCH /api/v1/prompts/:id

Request Body

json
{
  "content": "Updated prompt content...",
  "tags": ["support", "v2"]
}

All fields are optional. Only provided fields are updated.

Response

json
{
  "id": "prompt_123",
  "name": "Customer Support",
  "content": "Updated prompt content...",
  "updatedAt": "2025-01-20T15:00:00Z"
}

Delete Prompt

http
DELETE /api/v1/prompts/:id

Response

json
{
  "success": true,
  "message": "Prompt deleted"
}

Status: 200 OK

Get Prompt Status

http
GET /api/v1/prompts/:id/status

Get prompt details including optimization state and performance metrics.

Response

json
{
  "id": "prompt_123",
  "name": "Customer Support",
  "status": "active",
  "optimizationState": "idle",
  "metrics": {
    "conversationCount": 1247,
    "taskCompletionRate": 87.3,
    "avgSentiment": 0.72
  },
  "lastOptimized": "2025-01-18T10:00:00Z"
}

Get Prompt Insights

http
GET /api/v1/prompts/:id/insights

Get aggregated performance insights for a prompt based on conversation data.

Query Parameters

ParameterTypeDefaultDescription
daysnumber30Number of days to look back (7, 30, 90, or all)

Response

json
{
  "promptId": "prompt_123",
  "period": {
    "days": 30,
    "from": "2024-12-21T00:00:00Z",
    "to": "2025-01-20T23:59:59Z"
  },
  "summary": {
    "totalConversations": 1247,
    "completedConversations": 1089,
    "abandonedConversations": 158,
    "completionRate": 87.3
  },
  "metrics": {
    "taskCompletion": {
      "rate": 82.5,
      "trend": "+3.2%"
    },
    "sentiment": {
      "average": 0.72,
      "distribution": {
        "positive": 68,
        "neutral": 24,
        "negative": 8
      }
    },
    "avgResponseTime": 1.2,
    "avgConversationLength": 6.4
  },
  "topIssues": [
    {
      "issue": "Unclear refund policy explanation",
      "frequency": 23,
      "impact": "high"
    }
  ],
  "recommendations": [
    "Consider adding specific refund timelines to reduce follow-up questions"
  ]
}

Error Responses

Not Found

json
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Prompt not found"
  }
}

Status: 404 Not Found

Validation Error

json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body",
    "details": {
      "llmModel": "Must be a valid model name"
    }
  }
}

Status: 400 Bad Request