REST Endpoints
Using REST API endpoints
Overview
REST endpoints are automatically generated from tRPC procedures with OpenAPI metadata enabled. This allows external clients to consume your API using standard HTTP requests.
Accessing Endpoints
All OpenAPI-enabled procedures are available at /api/<path> where <path> is defined in the procedure's metadata.
Base URL
https://your-app.com/apiExample Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/api-keys | GET | List API keys |
/api/api-keys | POST | Create API key |
/api/health | GET | Health check |
Authentication
Protected endpoints require authentication via Bearer token in the Authorization header.
Getting a Token
Users can generate API keys through the dashboard at /dashboard/api-keys.
Using Bearer Token
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://your-app.com/api/api-keysPublic Endpoints
Some endpoints may be public (no authentication required):
curl https://your-app.com/api/healthRequest Examples
GET Request
# List resources
curl -X GET \
-H "Authorization: Bearer YOUR_API_KEY" \
https://your-app.com/api/api-keysPOST Request
# Create resource
curl -X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "My API Key"}' \
https://your-app.com/api/api-keysQuery Parameters
For GET requests with search params:
curl -X GET \
-H "Authorization: Bearer YOUR_API_KEY" \
"https://your-app.com/api/search?q=hello&page=1"Response Format
All endpoints return JSON in the ActionResponse format:
Success Response
{
"success": true,
"message": "Saved successfully",
"payload": {
"id": "123",
"name": "My Resource"
}
}Error Response
{
"success": false,
"message": "Invalid input"
}HTTP Status Codes
| Status | Description | When Used |
|---|---|---|
| 200 | OK | Successful request |
| 201 | Created | Resource created |
| 400 | Bad Request | Invalid input |
| 401 | Unauthorized | Missing/invalid token |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error |
Rate Limiting
All endpoints are rate-limited based on their configuration. When rate limit is exceeded:
{
"success": false,
"message": "Too many requests. Try again in 60 seconds."
}Rate limits are configured per procedure in the tRPC metadata. See Procedures for details.
JavaScript/TypeScript Client
Using fetch
const response = await fetch("https://your-app.com/api/api-keys", {
method: "GET",
headers: {
"Authorization": `Bearer ${apiKey}`,
},
});
const data = await response.json();
if (data.success) {
console.log(data.payload);
} else {
console.error(data.message);
}Creating a Resource
const response = await fetch("https://your-app.com/api/api-keys", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "My API Key",
}),
});
const data = await response.json();Python Client
import requests
# GET request
response = requests.get(
"https://your-app.com/api/api-keys",
headers={"Authorization": f"Bearer {api_key}"}
)
data = response.json()
if data["success"]:
print(data["payload"])
else:
print(data["message"])
# POST request
response = requests.post(
"https://your-app.com/api/api-keys",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
},
json={"name": "My API Key"}
)OpenAPI Documentation
The full OpenAPI specification is available at:
GET /api/openapi.jsonThis can be imported into tools like Postman, Insomnia, or Swagger UI.