API Reference
Complete reference for the FetchPrompt REST API — endpoints, authentication, request/response formats, and error codes.
API Reference
The FetchPrompt REST API lets you fetch prompt content at runtime from any application. All endpoints are served from the Edge for low latency worldwide.
Base URL: https://www.fetchprompt.com/api/v1
Authentication
All API requests require a Bearer token in the Authorization header:
Authorization: Bearer fp_prod_your_key_hereThe API key determines both the organization and environment (Stage or Production) for the request. See API Keys for details on creating and managing keys.
Endpoints
List all prompts
Returns all prompts for the organization and environment associated with your API key.
GET /api/v1/promptsHeaders:
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer {api_key} |
Response 200 OK:
{
"data": [
{
"slug": "customer-support-bot",
"name": "Customer Support Bot",
"version": 3,
"environment": "prod",
"updated_at": "2026-02-24T10:30:00Z"
},
{
"slug": "email-subject-generator",
"name": "Email Subject Generator",
"version": 1,
"environment": "prod",
"updated_at": "2026-02-23T15:00:00Z"
}
]
}Prompts are ordered by updated_at (most recently updated first).
Fetch a prompt (GET)
Fetches a single prompt by slug. Supports variable interpolation via query parameters and ETag caching.
GET /api/v1/prompts/{slug}Path parameters:
| Parameter | Description |
|---|---|
slug | The prompt's URL-friendly identifier (e.g., customer-support-bot) |
Query parameters (optional):
Any query parameter is treated as a variable for interpolation. For example:
GET /api/v1/prompts/my-prompt?user_name=Sarah&tone=friendlyThis replaces {{user_name}} with Sarah and {{tone}} with friendly in the prompt content.
Headers:
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer {api_key} |
If-None-Match | No | ETag value for conditional requests |
Response 200 OK:
{
"slug": "customer-support-bot",
"name": "Customer Support Bot",
"content": "You are a helpful customer support agent. The customer's name is Sarah.",
"version": 3,
"environment": "prod"
}If some variables in the prompt were not provided, the response includes a missing_variables field:
{
"slug": "customer-support-bot",
"name": "Customer Support Bot",
"content": "You are a helpful customer support agent for {{company_name}}. The customer's name is Sarah.",
"version": 3,
"environment": "prod",
"missing_variables": ["company_name"]
}Response 304 Not Modified:
Returned when the If-None-Match header matches the current ETag. No body is returned.
Response headers:
| Header | Description |
|---|---|
ETag | Content hash for conditional requests (e.g., "a1b2c3d4e5f67890") |
Cache-Control | public, max-age=60 |
X-RateLimit-Limit | Monthly API call limit (e.g., 30000) |
X-RateLimit-Remaining | Calls remaining this month |
X-RateLimit-Reset | Unix timestamp when the limit resets |
Render a prompt (POST)
Fetches a prompt and renders it with variables provided in a JSON body. Use this when you have many variables or values that contain special characters.
POST /api/v1/prompts/{slug}Path parameters:
| Parameter | Description |
|---|---|
slug | The prompt's URL-friendly identifier |
Headers:
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer {api_key} |
Content-Type | Yes | application/json |
If-None-Match | No | ETag value for conditional requests |
Request body:
{
"user_name": "Sarah",
"company_name": "Acme Inc",
"tone": "friendly"
}Pass variables as a flat JSON object. The body is optional — if omitted or empty, the prompt content is returned without interpolation.
Response 200 OK:
{
"slug": "customer-support-bot",
"name": "Customer Support Bot",
"content": "You are a helpful customer support agent for Acme Inc. The customer's name is Sarah. Respond in a friendly tone.",
"version": 3,
"environment": "prod"
}If some variables in the prompt were not provided, the response includes a missing_variables field:
{
"slug": "customer-support-bot",
"name": "Customer Support Bot",
"content": "You are a helpful customer support agent for {{company_name}}. The customer's name is Sarah. Respond in a friendly tone.",
"version": 3,
"environment": "prod",
"missing_variables": ["company_name"]
}Response 304 Not Modified:
Returned when the If-None-Match header matches the current ETag. No body is returned.
Response headers:
| Header | Description |
|---|---|
ETag | Content hash for conditional requests (e.g., "a1b2c3d4e5f67890") |
Cache-Control | public, max-age=60 |
X-RateLimit-Limit | Monthly API call limit (e.g., 30000) |
X-RateLimit-Remaining | Calls remaining this month |
X-RateLimit-Reset | Unix timestamp when the limit resets |
Error responses
All error responses follow this format:
{
"error": "Error message describing what went wrong"
}| Status Code | Error | Description |
|---|---|---|
400 | Invalid JSON body. Expected format: { "key": "value" } | The POST request body is not valid JSON |
401 | Missing or invalid API key | No Authorization header or the header doesn't start with Bearer |
401 | Invalid API key | The API key is not recognized or has been revoked |
404 | Prompt not found | No prompt exists with the given slug in the API key's organization and environment |
429 | Rate limit exceeded | The organization has exceeded its monthly API call limit |
500 | Failed to fetch prompts | An internal error occurred while querying the database |