Skip to Content
ReferenceAPI Reference

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/conversations

Response:

{ "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-stream

Returns 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-stream

Get Build Logs

GET /api/builds/{id}/logs

Download ISO

GET /api/builds/{id}/download

Returns the ISO file for download.

Tests

Get Test Results

GET /api/builds/{id}/tests

Response:

{ "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/organizations

Get Organization

GET /api/organizations/{id}

Create Organization

POST /api/organizations Content-Type: application/json { "name": "My Company" }

List Members

GET /api/organizations/{id}/members

Invite Member

POST /api/organizations/{id}/invites Content-Type: application/json { "email": "user@example.com", "role": "member" }

Units

List Units

GET /api/organizations/{orgId}/units

Create 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}/teams

Create 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 user
  • group - Share with group
  • unit - Share with unit
  • team - Share with team
  • organization - Share with organization

List Shares

GET /api/conversations/{id}/shares

Remove 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

CodeHTTP StatusDescription
UNAUTHORIZED401Invalid/missing token
FORBIDDEN403Insufficient permissions
NOT_FOUND404Resource not found
VALIDATION_ERROR400Invalid request data
RATE_LIMITED429Too many requests
SERVER_ERROR500Internal 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: 1705320000

Webhooks

Configure webhooks to receive build notifications:

POST /api/webhooks Content-Type: application/json { "url": "https://example.com/webhook", "events": ["build.completed", "build.failed"] }

Events

EventDescription
build.startedBuild has started
build.completedBuild succeeded
build.failedBuild failed
test.completedTests finished