Skip to main content

Example Workflows

Registering a User and Logging In

# Register
curl -X POST http://localhost:3000/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"jane@example.com","password":"secure123","display_name":"Jane"}'

# Login — save the returned accessToken
curl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"jane@example.com","password":"secure123"}'

# Store token
export TOKEN="<accessToken from response>"

Defining a Model and Using the CRUD API

# 1. Create model (admin role required)
curl -X POST http://localhost:3000/admin/api/schema \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"name": "Product",
"fields": {
"name": {"type": "string", "required": true},
"price": "number",
"in_stock": "boolean"
}
}'

# 2. Create a record
curl -X POST http://localhost:3000/api/products \
-H "Content-Type: application/json" \
-d '{"name":"Widget","price":9.99,"in_stock":true}'

# 3. List with sort and filter
curl "http://localhost:3000/api/products?sort=price&order=ASC&in_stock=1"

# 4. Get one
curl http://localhost:3000/api/products/<id>

# 5. Update
curl -X PUT http://localhost:3000/api/products/<id> \
-H "Content-Type: application/json" \
-d '{"price":14.99}'

# 6. Delete
curl -X DELETE http://localhost:3000/api/products/<id>

Uploading and Downloading Files

# Upload a public file
curl -X POST http://localhost:3000/files/upload \
-H "Authorization: Bearer $TOKEN" \
-F "file=@/path/to/photo.jpg" \
-F "visibility=public"

# Download public file (no auth needed)
curl http://localhost:3000/files/<id>/download -o photo.jpg

# Upload a private file
curl -X POST http://localhost:3000/files/upload \
-H "Authorization: Bearer $TOKEN" \
-F "file=@/path/to/document.pdf" \
-F "visibility=private"

# Get a signed URL for the private file
curl http://localhost:3000/files/<id>/signed-url \
-H "Authorization: Bearer $TOKEN"

# Download using the signed URL
curl "<signed-url>" -o document.pdf

Calling an AI Model

# Generate a completion
curl -X POST http://localhost:3000/api/ai/generate \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"model": "gpt-4o",
"prompt": "Write a one-sentence tagline for a productivity app.",
"maxTokens": 60
}'

# Multi-turn chat
curl -X POST http://localhost:3000/api/ai/chat \
-H "Content-Type: application/json" \
-d '{
"provider": "anthropic",
"model": "claude-sonnet-4-6",
"messages": [
{"role": "user", "content": "What is the capital of France?"}
]
}'

Creating and Running an AI Agent

# 1. Create an agent (admin required)
curl -X POST http://localhost:3000/admin/api/agents \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"name": "Math Helper",
"provider": "openai",
"model": "gpt-4o",
"systemPrompt": "You are a precise math assistant. Use the calculator tool for all computations.",
"tools": ["calculate"],
"temperature": 0.2,
"maxIterations": 5
}'

# 2. Run the agent
curl -X POST http://localhost:3000/api/agents/<id>/run \
-H "Content-Type: application/json" \
-d '{"input": "What is (144 / 12) * 7.5 plus 33?"}'

Refreshing an Expired Token

curl -X POST http://localhost:3000/auth/refresh \
-H "Content-Type: application/json" \
-d '{"refreshToken":"<your-refresh-token>"}'