Workspace Prompt Lab
Create, test, and publish prompt templates for consistent AI interactions.
Endpoints
| Method | Path | Description | Auth | Rate Limit |
|---|---|---|---|---|
| GET | /workspaces/:workspaceId/ai/prompt-lab/templates | List templates | JWT + Entitlement | 60/min |
| POST | /workspaces/:workspaceId/ai/prompt-lab/templates | Create a template | JWT + Entitlement | 10/min |
| POST | /workspaces/:workspaceId/ai/prompt-lab/templates/:templateId/test | Test a template | JWT + Entitlement | 20/min |
| POST | /workspaces/:workspaceId/ai/prompt-lab/templates/:templateId/publish | Publish a template | JWT + Entitlement | 10/min |
Create Template
Request
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name |
template | string | Yes | Prompt template with placeholders |
variables | string[] | No | List of variable names used in the template |
Response
Response Example
json
{
"data": {
"id": "cm5prompt01",
"workspaceId": "cm5ws01",
"name": "Chain Review Prompt",
"template": "Analyze the following chain data...",
"variables": ["chainName", "currentStreak", "completionRate"],
"status": "draft",
"createdAt": "2026-03-17T10:00:00.000Z"
}
}Code Examples
Use the id of the workspace as $WORKSPACE_ID.
bash
curl -X POST https://api.chainabit.com/api/v1/workspaces/$WORKSPACE_ID/ai/prompt-lab/templates \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Chain Review Prompt",
"template": "Analyze the following chain data:\n\nChain: {{chainName}}\nStreak: {{currentStreak}} days\nCompletion Rate: {{completionRate}}%\n\nProvide 3 specific recommendations.",
"variables": ["chainName", "currentStreak", "completionRate"]
}'javascript
const BASE_URL = process.env.BASE_URL;
const TOKEN = process.env.TOKEN;
const workspaceId = process.env.WORKSPACE_ID;
const response = await fetch(
`${BASE_URL}/workspaces/${workspaceId}/ai/prompt-lab/templates`,
{
method: "POST",
headers: {
Authorization: `Bearer ${TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Chain Review Prompt",
template:
"Analyze the following chain data:\n\nChain: {{chainName}}\nStreak: {{currentStreak}} days\nCompletion Rate: {{completionRate}}%\n\nProvide 3 specific recommendations.",
variables: ["chainName", "currentStreak", "completionRate"],
}),
}
);
const { data } = await response.json();python
import requests, os
workspace_id = os.environ["WORKSPACE_ID"]
response = requests.post(
f"{os.environ['BASE_URL']}/workspaces/{workspace_id}/ai/prompt-lab/templates",
headers={"Authorization": f"Bearer {os.environ['TOKEN']}"},
json={
"name": "Chain Review Prompt",
"template": "Analyze the following chain data:\n\nChain: {{chainName}}\nStreak: {{currentStreak}} days\nCompletion Rate: {{completionRate}}%\n\nProvide 3 specific recommendations.",
"variables": ["chainName", "currentStreak", "completionRate"],
},
)
data = response.json()["data"]Test Template
Request
- Path params:
workspaceId,templateId - Body:
variables— values for the template'splaceholders
Response
json
{
"data": {
"renderedPrompt": "Analyze the following chain data:\n\nChain: Daily Vocabulary Practice\nStreak: 5 days\nCompletion Rate: 85%\n\nProvide 3 specific recommendations.",
"response": "Here are 3 recommendations for your Daily Vocabulary Practice chain...",
"tokensUsed": 450,
"latencyMs": 1800
}
}Code Examples
Use the id from Create Template's response (data.id) as $TEMPLATE_ID.
bash
curl -X POST https://api.chainabit.com/api/v1/workspaces/$WORKSPACE_ID/ai/prompt-lab/templates/$TEMPLATE_ID/test \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"variables": {
"chainName": "Daily Vocabulary Practice",
"currentStreak": 5,
"completionRate": 85
}
}'javascript
const BASE_URL = process.env.BASE_URL;
const TOKEN = process.env.TOKEN;
const workspaceId = process.env.WORKSPACE_ID;
const templateId = process.env.TEMPLATE_ID; // from Create Template's response
const response = await fetch(
`${BASE_URL}/workspaces/${workspaceId}/ai/prompt-lab/templates/${templateId}/test`,
{
method: "POST",
headers: {
Authorization: `Bearer ${TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
variables: {
chainName: "Daily Vocabulary Practice",
currentStreak: 5,
completionRate: 85,
},
}),
}
);
const { data } = await response.json();python
import requests, os
workspace_id = os.environ["WORKSPACE_ID"]
template_id = os.environ["TEMPLATE_ID"] # from Create Template's response
response = requests.post(
f"{os.environ['BASE_URL']}/workspaces/{workspace_id}/ai/prompt-lab/templates/{template_id}/test",
headers={"Authorization": f"Bearer {os.environ['TOKEN']}"},
json={"variables": {"chainName": "Daily Vocabulary Practice", "currentStreak": 5, "completionRate": 85}},
)
data = response.json()["data"]