PromptMia Info
API Reference
PromptMia provides a REST API for managing prompt templates, compiling variable-filled prompts, and automating workflows — from scripts, CI pipelines, or AI agents.
Base URL
https://promptmia.com All API responses are application/json unless otherwise noted. Timestamps are ISO 8601 UTC strings.
Authentication
Protected endpoints accept two auth methods. Most programmatic use cases should use API keys.
API Key (Bearer token)
Generate a key in Settings. The raw key is shown once on creation — store it securely. Keys start with pt_.
Authorization: Bearer pt_your_api_key_hereSession Cookie (browser)
The browser session set by POST /api/auth/login is accepted by all protected endpoints. Not recommended for programmatic use — prefer API keys.
Note
GET/POST/DELETE /api/keys) require a browser session — they cannot be called via API key auth. Variable Syntax
Template content uses {{variable}} placeholders. When compiled, each placeholder is replaced with its value (or [name] if not provided).
| Syntax | Type | Notes |
|---|---|---|
| {{name}} | text | Default type, max 128 chars |
| {{name|text}} | text | Explicit single-line text |
| {{name|textarea:512}} | textarea | Multi-line text, max 512 chars |
| {{name|number}} | number | Numeric input |
| {{name|email}} | Email address | |
| {{name|phone}} | phone | Phone number |
| {{name|list}} | list | Comma-separated values |
| {{name|type:maxLen|hint}} | any | All three segments: type, max length, description |
Quick Start
The most common use case: create a template, then compile it with variable values to get a ready-to-use prompt string.
// Install: npm install node-fetch (or use native fetch in Node 18+)
const BASE = 'https://promptmia.com'
const API_KEY = 'pt_your_api_key_here'
const headers = {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
}
// 1. Create a template
const { template } = await fetch(`${BASE}/api/templates`, {
method: 'POST',
headers,
body: JSON.stringify({
title: 'Blog Post Intro',
content: 'Write an intro for a blog post about {{topic|text}} for a {{audience|text}} audience.',
tags: ['writing'],
}),
}).then(r => r.json())
// 2. Compile with variable values
const { compiled, missing_variables } = await fetch(`${BASE}/api/templates/${template.id}/compile`, {
method: 'POST',
headers,
body: JSON.stringify({
variables: { topic: 'AI agents', audience: 'developers' },
}),
}).then(r => r.json())
console.log(compiled)
// → "Write an intro for a blog post about AI agents for a developers audience."Templates
/api/templatesList all templates owned by the authenticated user, ordered by most recently updated.
Response
{
"templates": [
{
"id": "uuid",
"title": "Customer Support Reply",
"description": "...",
"tags": ["support"],
"is_public": false,
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-02T00:00:00Z"
}
]
}Example
curl https://promptmia.com/api/templates \ -H "Authorization: Bearer pt_your_api_key_here"
/api/templatesCreate a new template.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| title | string | yes | Template name (1–255 chars) |
| content | string | yes | Markdown content with {{variable}} placeholders |
| description | string | no | Optional short description |
| tags | string[] | no | Tag list for filtering |
| is_public | boolean | no | Whether to list on explore page (default: false) |
Response
{
"template": {
"id": "uuid",
"user_id": "uuid",
"title": "...",
"content": "...",
"tags": [],
"is_public": false,
"created_at": "...",
"updated_at": "..."
}
}Example
curl -X POST https://promptmia.com/api/templates \
-H "Authorization: Bearer pt_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"title": "Customer Support Reply",
"content": "Hi {{customer_name|text}},\n\nThank you for reaching out about {{issue|textarea:512|Describe the issue}}.\n\n{{resolution|textarea:512|Describe the resolution}}\n\nBest regards,\n{{agent_name|text}}",
"tags": ["support", "email"],
"is_public": false
}'/api/templates/:idGet a single template by ID. Must be the owner.
Response
{
"template": { /* full Template object */ }
}/api/templates/:idUpdate a template. All fields are optional — only provided fields are changed.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| title | string | no | 1–255 chars |
| content | string | no | Full template content |
| description | string | null | no | Pass null to clear |
| tags | string[] | no | Replaces the existing tag list |
| is_public | boolean | no | Publish / unpublish |
Response
{
"template": { /* updated Template object */ }
}/api/templates/:idPermanently delete a template and all its associated share links.
Response
{ "success": true }Compile & Download
These are the primary endpoints for programmatic use. Authentication is always required; non-owners can access public templates with either an API key or a session.
/api/templates/:id/compileReplace template variables with provided values and return the compiled string. Non-owners can compile public templates with valid credentials.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| variables | Record<string, string> | no | Map of variable names to values. Missing variables become [name] placeholders. |
Response
{
"compiled": "Hi Alice, ...",
"missing_variables": ["unset_field"]
}Example
curl -X POST https://promptmia.com/api/templates/{id}/compile \
-H "Authorization: Bearer pt_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"variables": {
"customer_name": "Alice",
"issue": "billing discrepancy on invoice #1234",
"resolution": "We have applied a credit to your account.",
"agent_name": "Support Team"
}
}'
# Response:
# {
# "compiled": "Hi Alice,\n\nThank you for reaching out about billing discrepancy on invoice #1234...",
# "missing_variables": []
# }/api/templates/:id/downloadDownload the template as a .md file. Supports compiled output with optional variable values. Non-owners can download public templates with valid credentials.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| format | 'raw' | 'compiled' | no | Default: compiled. Use raw to download the template source. |
| variables | string (base64 JSON) | no | Base64-encoded JSON object of variable values, e.g. btoa(JSON.stringify({name: 'Alice'})) |
Response
Returns text/markdown with Content-Disposition: attachment; filename="..."
Example
# Download compiled .md file
curl "https://promptmia.com/api/templates/{id}/download?format=compiled&variables=$(printf '{"name":"Alice"}' | base64)" \
-H "Authorization: Bearer pt_your_api_key_here" \
--output compiled-prompt.mdPublic Templates
These endpoints do not require authentication and are suitable for embedding or discovery.
/api/templates/publicBrowse publicly listed templates with search, tag filtering, sorting, and pagination.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| q | string | no | Full-text search on title and description |
| tag | string | no | Filter by a single tag (exact match) |
| author | string (userId) | no | Filter by author's user ID |
| sort | 'newest' | 'oldest' | no | Default: newest |
| page | number | no | Page number, default 1. Page size is 18. |
Response
{
"templates": [
{
"id": "uuid",
"title": "...",
"description": "...",
"content": "...",
"tags": ["support"],
"created_at": "...",
"author": {
"id": "uuid",
"display_name": "Alice",
"username": "alice",
"avatar_url": "..."
}
}
],
"total": 42,
"page": 1,
"page_size": 18,
"total_pages": 3
}Example
curl "https://promptmia.com/api/templates/public?q=customer+support&tag=email&sort=newest&page=1"
/api/templates/:id/publicFetch a single public template by ID. Returns 404 for private templates.
Response
{
"template": {
"id": "uuid",
"title": "...",
"description": "...",
"content": "...",
"tags": [],
"created_at": "..."
}
}Example
curl https://promptmia.com/api/templates/{id}/publicAPI Keys
API keys are managed in Settings. These endpoints require a browser session — they are not callable via API key auth (to prevent recursion and key-created-key escalation).
pt_ followed by 64 hex characters. The raw key is shown once at creation time. Store it securely — it cannot be retrieved again. /api/keysList all API keys for the authenticated user. Key hashes are never returned.
Response
{
"keys": [
{
"id": "uuid",
"name": "my-agent-key",
"key_prefix": "abcd1234",
"last_used": "2026-03-01T00:00:00Z",
"created_at": "..."
}
]
}/api/keysCreate a new API key. The raw key is returned once and never again — save it immediately.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | yes | Friendly label for the key (1–100 chars) |
Response
{
"api_key": {
"id": "uuid",
"name": "my-agent-key",
"key_prefix": "abcd1234",
"created_at": "..."
},
"raw_key": "pt_abcd1234ef567890..." // save this — shown once only
}Example
curl -X POST https://promptmia.com/api/keys \
-H "Content-Type: application/json" \
-H "Cookie: <your-session-cookie>" \
-d '{"name": "my-agent-key"}'
# Response:
# {
# "api_key": { "id": "...", "name": "my-agent-key", "key_prefix": "abcd1234", "created_at": "..." },
# "raw_key": "pt_abcd1234..." ← save this, shown once only
# }/api/keys/:idRevoke an API key by its ID. Any requests using the revoked key will immediately receive 401.
Response
{ "success": true }Profile
/api/profileGet the authenticated user's own profile including email.
Response
{
"profile": {
"id": "uuid",
"display_name": "Alice Smith",
"username": "alice",
"avatar_url": "...",
"bio": "...",
"email": "[email protected]",
"created_at": "..."
}
}/api/profileUpdate the authenticated user's profile.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| display_name | string | no | 1–80 chars |
| bio | string | no | Max 300 chars |
| username | string | null | no | 3–30 chars, lowercase letters, numbers, underscores only. Pass null to clear. |
Response
{
"profile": { /* updated profile object */ }
}/api/profile/:userIdGet a public profile by user ID, along with their public templates. No email is returned.
Response
{
"profile": {
"id": "uuid",
"display_name": "Alice Smith",
"username": "alice",
"avatar_url": "...",
"bio": "...",
"created_at": "..."
},
"templates": [ /* public templates */ ]
}/api/u/:usernameGet a public profile and their public templates by username.
Response
{
"profile": { "id": "...", "display_name": "...", "username": "alice", ... },
"templates": [ /* public templates */ ]
}Error Handling
All errors return a JSON object with a statusMessage field and the appropriate HTTP status code. Stack traces are never included in responses.
| Status | Meaning |
|---|---|
| 400 | Invalid request body or query parameters (Zod validation failed) |
| 401 | Missing or invalid authentication (no session, bad or unknown API key) |
| 403 | Authenticated but not authorized (e.g. accessing another user's template) |
| 404 | Resource not found |
| 409 | Conflict — e.g. username already taken |
| 410 | Gone — share link has expired |
| 429 | Rate limit exceeded (AI endpoints: 10 req/min per user) |
| 500 | Internal server error — retry with backoff |
# Example error response
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"statusCode": 401,
"statusMessage": "Invalid API key"
}LLMs.txt
A condensed plain-text reference designed to be pasted into an LLM system prompt or agent context window. Also available as a static file you can fetch directly:
https://promptmia.com/llms.txtOpen ↗# PromptMia API — Machine-Readable Reference
Base URL: https://promptmia.com
Auth: Bearer {api_key} (header: Authorization)
Session cookie (browser only — no header needed)
## Core workflow for LLM agents
1. POST /api/auth/login → obtains session (or use pre-generated API key)
2. POST /api/templates → create a template
3. POST /api/templates/{id}/compile → compile with variable values → get plain text
4. GET /api/templates → list owned templates
5. GET /api/templates/public → browse public templates (no auth)
## Template endpoints (auth: API key or session)
POST /api/templates
Body: { title: string, content: string, tags?: string[], description?: string, is_public?: bool }
Returns: { template: { id, user_id, title, content, tags, is_public, created_at, updated_at } }
GET /api/templates
Returns: { templates: Template[] }
GET /api/templates/{id}
Returns: { template: Template }
PUT /api/templates/{id}
Body: { title?, content?, tags?, description?, is_public? }
Returns: { template: Template }
DELETE /api/templates/{id}
Returns: { success: true }
## Compile & Download (auth: API key or session — non-owners may access public templates)
POST /api/templates/{id}/compile
Body: { variables: Record<string,string> }
Returns: { compiled: string, missing_variables: string[] }
GET /api/templates/{id}/download?format=raw|compiled&variables={base64-json}
Returns: text/markdown file attachment
## Public templates (no auth required)
GET /api/templates/public?q={search}&tag={tag}&author={userId}&sort=newest|oldest&page={n}
Returns: { templates: Template[], total, page, page_size, total_pages }
GET /api/templates/{id}/public
Returns: { template: { id, title, description, content, tags, created_at } }
## Share links (auth: API key or session — must be template owner, except GET /api/share/{token})
POST /api/templates/{id}/share
Body: { prefilled_variables?: Record<string,string>, expires_in_hours?: number }
Returns: { token: string, share_url: string, expires_at?: string }
GET /api/templates/{id}/shares
Returns: { shares: [{ id, token, share_url, prefilled_variables, expires_at, created_at }] }
PUT /api/templates/{id}/shares/{shareId}
Body: { prefilled_variables: Record<string,string> }
Returns: { success: true }
DELETE /api/templates/{id}/shares/{shareId}
Returns: { success: true }
GET /api/share/{token} (no auth required)
Returns: { template: { id, title, description, content, tags }, prefilled_variables: Record<string,string>, expires_at?: string }
GET /api/shares (auth: session only)
Query: template_id? (optional filter)
Returns: { shares: [{ id, token, share_url, prefilled_variables, expires_at, created_at, is_expired: bool, template: { id, title } }] }
## API Keys (auth: session only — cannot be managed via API key)
GET /api/keys
Returns: { keys: [{ id, name, key_prefix, last_used, created_at }] }
POST /api/keys
Body: { name: string }
Returns: { api_key: { id, name, key_prefix, created_at }, raw_key: string } <- raw_key shown once
DELETE /api/keys/{id}
Returns: { success: true }
## Profile (GET/PUT own profile: session only; GET by userId or username: no auth)
GET /api/profile (session only)
Returns: { profile: { id, display_name, username, avatar_url, bio, email, created_at } }
PUT /api/profile (session only)
Body: { display_name?, bio?, username? }
Returns: { profile: { ... } }
GET /api/profile/{userId} (no auth)
Returns: { profile: { id, display_name, username, avatar_url, bio, created_at }, templates: Template[] }
GET /api/u/{username} (no auth)
Returns: { profile: { id, display_name, username, avatar_url, bio, created_at }, templates: Template[] }
## Variable syntax in template content
{{name}} text field, max 128 chars
{{name|text}} explicit text type
{{name|textarea:512}} textarea, max 512 chars
{{name|number}} numeric input
{{name|email}} email input
{{name|phone}} phone input
{{name|list}} comma-separated list
{{name|type:maxLength|description}} full form: all three segments
## API Key format
All API keys start with 'pt_' followed by 64 hex characters.
Keys are hashed server-side. The raw key is shown once on creation.
Create keys at: https://promptmia.com/settings

