REST API
REST API Reference
Cloudillo provides a comprehensive REST API for building applications. All endpoints return JSON and use standard HTTP methods.
Base URL
https://your-cloudillo-server.comFor local development:
http://localhost:3000Authentication
Most endpoints require authentication via JWT tokens in the Authorization header:
Authorization: Bearer eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9...See Authentication for details on obtaining and managing tokens.
Response Format
All successful responses follow this format:
{
"data": <payload>,
"time": 1735000000,
"reqId": "req_abc123"
}For list endpoints, pagination metadata is included:
{
"data": [...],
"pagination": {
"total": 150,
"offset": 0,
"limit": 20,
"hasMore": true
},
"time": 1735000000,
"reqId": "req_abc123"
}Error Format
Errors return this structure:
{
"error": {
"code": "E-AUTH-UNAUTH",
"message": "Unauthorized access",
"details": {...}
},
"time": 1735000000,
"reqId": "req_abc123"
}See Error Handling for all error codes.
Common Query Parameters
Many list endpoints support these parameters:
_limit- Maximum number of results (default: 50, max: 200)_offset- Skip N results (for pagination)_sort- Sort field (e.g.,createdAt)_order- Sort order (ascordesc)
Endpoint Categories
Authentication
User authentication and token management.
POST /api/auth/register- Register new userPOST /api/auth/register-verify- Complete email verificationPOST /api/auth/login- Login and get tokenPOST /api/auth/logout- LogoutPOST /api/auth/password- Change passwordGET /api/auth/login-token- Refresh tokenGET /api/auth/access-token- Get scoped tokenGET /api/auth/proxy-token- Get federation tokenGET /api/me- Get tenant profile (public)GET /.well-known/cloudillo/id-tag- Resolve identity
Profiles
User and community profiles.
GET /api/me- Get own profilePATCH /api/me- Update own profilePUT /api/me/image- Upload profile imagePUT /api/me/cover- Upload cover imageGET /api/profiles- List profilesGET /api/profiles/:idTag- Get specific profilePATCH /api/profiles/:idTag- Update relationshipPATCH /api/admin/profiles/:idTag- Admin update profile
Actions
Social features: posts, comments, reactions, connections.
GET /api/actions- List actionsPOST /api/actions- Create actionGET /api/actions/:actionId- Get actionPATCH /api/actions/:actionId- Update actionDELETE /api/actions/:actionId- Delete actionPOST /api/actions/:actionId/accept- Accept actionPOST /api/actions/:actionId/reject- Reject actionPOST /api/actions/:actionId/stat- Update statisticsPOST /api/actions/:actionId/reaction- Add reactionPOST /api/inbox- Federation inbox
Files
File upload, download, and management.
GET /api/files- List filesPOST /api/files- Create file metadata (CRDT/RTDB)POST /api/files/{preset}/{file_name}- Upload file (BLOB)GET /api/files/:fileId- Download fileGET /api/files/:fileId/descriptor- Get file infoPATCH /api/files/:fileId- Update fileDELETE /api/files/:fileId- Delete filePUT /api/files/:fileId/tag/:tag- Add tagDELETE /api/files/:fileId/tag/:tag- Remove tagGET /api/files/variant/:variantId- Get variant
Settings
User preferences and configuration.
GET /api/settings- List all settingsGET /api/settings/:name- Get settingPUT /api/settings/:name- Update setting
References
Bookmarks and shortcuts.
GET /api/refs- List referencesPOST /api/refs- Create referenceGET /api/refs/:refId- Get referenceDELETE /api/refs/:refId- Delete reference
Tags
File and content tagging (see Files API).
GET /api/tags- List tagsPUT /api/files/:fileId/tag/:tag- Add tagDELETE /api/files/:fileId/tag/:tag- Remove tag
Rate Limiting
API requests are rate-limited per tenant:
- Default: 1000 requests per minute
- Authenticated: 5000 requests per minute
- Admin: Unlimited
Rate limit headers:
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4950
X-RateLimit-Reset: 1735000000CORS
CORS is enabled for all origins in development mode. In production, configure allowed origins in the server settings.
Timestamps
All timestamps are in Unix seconds (not milliseconds):
{
"createdAt": 1735000000
}Convert in JavaScript:
const date = new Date(timestamp * 1000)Content Types
Request Content-Type
Most endpoints accept:
Content-Type: application/jsonFile uploads use:
Content-Type: multipart/form-dataResponse Content-Type
All responses return:
Content-Type: application/json; charset=utf-8Except file downloads which return the appropriate MIME type.
HTTP Methods
GET- Retrieve resourcesPOST- Create resourcesPATCH- Partially update resourcesPUT- Replace resourcesDELETE- Delete resources
Idempotency
PUT, PATCH, and DELETE operations are idempotent. POST operations are not idempotent unless you provide an idempotencyKey:
{
"idempotencyKey": "unique-key-123",
"type": "POST",
"content": {...}
}Pagination
List endpoints return paginated results:
GET /actions?_limit=20&_offset=40Response includes pagination metadata:
{
"data": [...],
"pagination": {
"total": 150,
"offset": 40,
"limit": 20,
"hasMore": true
}
}Filtering
Many endpoints support filtering via query parameters:
GET /actions?type=POST&status=A&createdAfter=1735000000Field Selection
Request specific fields only (reduces response size):
GET /actions?_fields=actionId,type,content,createdAtExpansion
Expand related resources in a single request:
GET /actions?_expand=issuer,audienceThis resolves references instead of returning just IDs.
Batch Operations
Some endpoints support batch operations:
POST /actions/batch
Content-Type: application/json
{
"operations": [
{ "method": "POST", "data": {...} },
{ "method": "PATCH", "id": "act_123", "data": {...} }
]
}WebSocket Endpoints
For real-time features, use WebSocket connections:
WSS /ws/crdt- Collaborative documentsWSS /ws/rtdb/:fileId- Real-time databaseWSS /ws/bus- Message bus
See WebSocket API for details.
Quick Start
Using @cloudillo/base
import * as cloudillo from '@cloudillo/base'
await cloudillo.init('my-app')
const api = cloudillo.createApiClient()
// Make requests
const profile = await api.me.get()
const posts = await api.actions.get({ type: 'POST' })Using fetch directly
const response = await fetch('/api/me', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
})
const data = await response.json()
console.log(data.data) // Profile object
console.log(data.time) // Timestamp
console.log(data.reqId) // Request ID
Next Steps
Explore specific endpoint categories:
- Authentication - Login and tokens
- Profiles - User profiles
- Actions - Social features
- Files - File management
- Settings - User preferences
- References - Bookmarks