API Reference
OpenFactory provides a REST API for automation and integration.
Authentication
All API requests require authentication via JWT token.
Obtaining a Token
POST /api/auth/token
Content-Type: application/json
{
"email": "user@example.com",
"password": "password"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 3600
}Using the Token
Include the token in the Authorization header:
Authorization: Bearer <token>Conversations
List Conversations
GET /api/conversationsResponse:
{
"conversations": [
{
"id": "uuid",
"name": "My Build",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T11:45:00Z"
}
]
}Get Conversation
GET /api/conversations/{id}Create Conversation
POST /api/conversations
Content-Type: application/json
{
"name": "New Build Configuration"
}Delete Conversation
DELETE /api/conversations/{id}Chat
Send Message
POST /api/chat
Content-Type: application/json
{
"conversationId": "uuid",
"message": "Create a Debian server with SSH and Docker"
}Response:
{
"messageId": "uuid",
"response": "I'll create a Debian Bookworm server with...",
"recipe": { ... }
}Stream Response
GET /api/chat/stream?conversationId={id}&message={text}
Accept: text/event-streamReturns Server-Sent Events (SSE) for real-time responses.
Builds
Start Build
POST /api/builds
Content-Type: application/json
{
"conversationId": "uuid"
}Response:
{
"buildId": "uuid",
"status": "pending"
}Get Build Status
GET /api/builds/{id}Response:
{
"id": "uuid",
"status": "building",
"stage": "Config Agent",
"progress": 45,
"startedAt": "2025-01-15T10:30:00Z"
}Stream Build Status
GET /api/streams/builds/{id}
Accept: text/event-streamGet Build Logs
GET /api/builds/{id}/logsDownload ISO
GET /api/builds/{id}/downloadReturns the ISO file for download.
Tests
Get Test Results
GET /api/builds/{id}/testsResponse:
{
"status": "passed",
"tests": [
{
"description": "Boot verification",
"status": "passed",
"duration": 45.2
},
{
"description": "Service check",
"status": "passed",
"assertions": [
{
"type": "service_running",
"params": { "service": "ssh" },
"result": "passed"
}
]
}
]
}Run Custom Tests
POST /api/builds/{id}/tests
Content-Type: application/json
{
"assertions": [
{
"type": "http_responds",
"params": { "url": "http://localhost/health" }
}
]
}Organizations
List Organizations
GET /api/organizationsGet Organization
GET /api/organizations/{id}Create Organization
POST /api/organizations
Content-Type: application/json
{
"name": "My Company"
}List Members
GET /api/organizations/{id}/membersInvite Member
POST /api/organizations/{id}/invites
Content-Type: application/json
{
"email": "user@example.com",
"role": "member"
}Units
List Units
GET /api/organizations/{orgId}/unitsCreate Unit
POST /api/organizations/{orgId}/units
Content-Type: application/json
{
"name": "Engineering",
"type": "business"
}Get Unit
GET /api/units/{id}Teams
List Teams
GET /api/units/{unitId}/teamsCreate Team
POST /api/units/{unitId}/teams
Content-Type: application/json
{
"name": "Platform Team"
}Get Team
GET /api/teams/{id}Sharing
Share Conversation
POST /api/conversations/{id}/shares
Content-Type: application/json
{
"targetType": "user",
"targetId": "user-uuid",
"permission": "edit"
}Target Types:
user- Share with specific usergroup- Share with groupunit- Share with unitteam- Share with teamorganization- Share with organization
List Shares
GET /api/conversations/{id}/sharesRemove Share
DELETE /api/conversations/{id}/shares/{shareId}Error Responses
All errors follow this format:
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or expired token"
}
}Common Error Codes
| Code | HTTP Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid/missing token |
FORBIDDEN | 403 | Insufficient permissions |
NOT_FOUND | 404 | Resource not found |
VALIDATION_ERROR | 400 | Invalid request data |
RATE_LIMITED | 429 | Too many requests |
SERVER_ERROR | 500 | Internal error |
Rate Limiting
API requests are rate limited:
- Authenticated: 100 requests/minute
- Build operations: 10 builds/hour
Rate limit headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1705320000Webhooks
Configure webhooks to receive build notifications:
POST /api/webhooks
Content-Type: application/json
{
"url": "https://example.com/webhook",
"events": ["build.completed", "build.failed"]
}Events
| Event | Description |
|---|---|
build.started | Build has started |
build.completed | Build succeeded |
build.failed | Build failed |
test.completed | Tests finished |