API Reference
UniSync exposes a comprehensive REST API built with FastAPI.
Base URL
http://localhost:8000/apiIn production: https://api.unisync.ai/api
Interactive Documentation
FastAPI automatically generates interactive API documentation:
- Swagger UI:
{base_url}/docs - ReDoc:
{base_url}/redoc
Authentication
Most endpoints require a JWT bearer token.
Obtaining a Token
http
POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "your_password"
}Response:
json
{
"access_token": "eyJ...",
"token_type": "bearer",
"user": { ... }
}Using the Token
Include the token in the Authorization header:
http
Authorization: Bearer eyJ...Token Refresh
http
POST /api/auth/refresh
Authorization: Bearer {current_token}Response Format
All API responses follow a consistent structure:
Success
json
{
"data": { ... },
"message": "Operation successful"
}Error
json
{
"detail": "Error description"
}Common HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
201 | Created |
400 | Bad request (validation error) |
401 | Unauthorized (invalid/missing token) |
403 | Forbidden (insufficient role) |
404 | Resource not found |
422 | Validation error |
500 | Internal server error |
Role-Based Access
Endpoints enforce role requirements:
| Role | Access Level |
|---|---|
super_admin | All endpoints |
admin | All except system-level |
editor | Content and agent management |
viewer | Read-only endpoints |
API Groups
| Group | Prefix | Endpoints |
|---|---|---|
| Authentication | /api/auth | Login, register, profile, 2FA |
| Agents | /api/agents | CRUD, assignments, execution |
| Environments | /api/environments | CRUD, configuration |
| Configurations | /api/configurations | API credentials |
| SEO Intelligence | /api/seo | Keywords, campaigns, scout, strategies |
| Content Intelligence | /api/cie | Archetypes |
| OpenChat | /api/openchat | Conversations, messages |
| Live Agents | /api/live-agents | Sessions, generation |
| WordPress Posts | /api/wordpress-posts | Post management |
| Astro Posts | /api/astro-posts | Post CRUD |
| CMS | /api/cms | Categories, tags |
| Token Analytics | /api/token-analytics | Usage, costs |
| AutoPilot | /api/autopilot | Automation control |
| Backup | /api/backup | Backup/restore |
| Search Phrases | /api/search-phrases | Automation |
| Web Sources | /api/web-sources | Automation |
| Settings | /api/settings/ai-content | AI content config |
| Notifications | /api/notifications | User notifications |
| Messages | /api/messages | Messaging |
Rate Limits
UniSync does not enforce internal rate limits, but external API providers do. Monitor usage through Token Analytics.