Forge REST API documentation for version 1.0.
Base URL: http://localhost:3000/api/v1
Currently, Forge API uses API key authentication (JWT coming soon).
Authorization: Bearer YOUR_API_KEYCheck API server health and service status.
Response:
{
"status": "healthy",
"timestamp": "2024-12-09T12:00:00Z",
"version": "0.1.0",
"services": {
"database": "connected",
"redis": "connected",
"weaviate": "connected"
}
}Status Codes:
200- All services healthy503- One or more services unavailable
Create a new project.
Request:
{
"name": "My Project",
"description": "Project description",
"repoUrl": "https://github.com/user/repo"
}Response:
{
"id": "proj_abc123",
"name": "My Project",
"description": "Project description",
"repoUrl": "https://github.com/user/repo",
"createdAt": "2024-12-09T12:00:00Z",
"updatedAt": "2024-12-09T12:00:00Z"
}Status Codes:
201- Project created400- Invalid request409- Project already exists
List all projects.
Query Parameters:
page(optional) - Page number (default: 1)limit(optional) - Items per page (default: 20, max: 100)search(optional) - Search by name
Response:
{
"data": [
{
"id": "proj_abc123",
"name": "My Project",
"description": "Project description",
"specsCount": 5,
"jobsCount": 12,
"createdAt": "2024-12-09T12:00:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 42,
"pages": 3
}
}Get a specific project by ID.
Response:
{
"id": "proj_abc123",
"name": "My Project",
"description": "Project description",
"repoUrl": "https://github.com/user/repo",
"specs": [
{
"id": "spec_xyz789",
"description": "Add user authentication",
"status": "completed",
"createdAt": "2024-12-09T12:00:00Z"
}
],
"createdAt": "2024-12-09T12:00:00Z",
"updatedAt": "2024-12-09T12:00:00Z"
}Status Codes:
200- Success404- Project not found
Delete a project.
Status Codes:
204- Project deleted404- Project not found
Generate a specification from natural language.
Request:
{
"projectId": "proj_abc123",
"description": "Add user authentication with email and password",
"context": {
"framework": "express",
"database": "postgresql"
}
}Response:
{
"id": "spec_xyz789",
"projectId": "proj_abc123",
"description": "Add user authentication with email and password",
"status": "generated",
"spec": {
"files": [
{
"path": "src/auth/auth.service.ts",
"action": "create",
"content": "..."
},
{
"path": "src/users/user.model.ts",
"action": "modify",
"changes": [...]
}
],
"tests": [
{
"path": "src/auth/auth.service.test.ts",
"description": "Test login functionality"
}
],
"dependencies": [
"bcrypt",
"jsonwebtoken",
"@types/bcrypt"
],
"estimatedComplexity": "medium"
},
"createdAt": "2024-12-09T12:00:00Z"
}Status Codes:
201- Spec generated400- Invalid request422- Unable to generate spec
Get a specification by ID.
Response:
{
"id": "spec_xyz789",
"projectId": "proj_abc123",
"description": "Add user authentication",
"status": "generated",
"spec": { ... },
"jobs": [
{
"id": "job_123",
"status": "completed",
"createdAt": "2024-12-09T12:30:00Z"
}
],
"createdAt": "2024-12-09T12:00:00Z"
}Execute a specification.
Request:
{
"specId": "spec_xyz789",
"options": {
"autoApprove": false,
"createPR": true
}
}Response:
{
"id": "job_123",
"specId": "spec_xyz789",
"status": "pending",
"progress": 0,
"createdAt": "2024-12-09T12:00:00Z"
}Status Codes:
201- Job created400- Invalid request404- Spec not found
Get job status and results.
Response:
{
"id": "job_123",
"specId": "spec_xyz789",
"status": "running",
"progress": 45,
"logs": [
"Creating sandbox...",
"Generating code...",
"Applying changes..."
],
"result": null,
"createdAt": "2024-12-09T12:00:00Z",
"startedAt": "2024-12-09T12:01:00Z",
"completedAt": null
}Job Statuses:
pending- Waiting to startrunning- Executingcompleted- Successfailed- Error occurredcancelled- Manually stopped
Cancel a running job.
Status Codes:
200- Job cancelled400- Job cannot be cancelled404- Job not found
Prometheus-formatted metrics.
Response:
# HELP forge_api_requests_total Total API requests
# TYPE forge_api_requests_total counter
forge_api_requests_total{method="GET",endpoint="/projects",status="200"} 142
# HELP forge_ai_requests_total Total AI provider requests
# TYPE forge_ai_requests_total counter
forge_ai_requests_total{provider="openai",model="gpt-4"} 23
# HELP forge_job_duration_seconds Job execution duration
# TYPE forge_job_duration_seconds histogram
forge_job_duration_seconds_bucket{status="completed",le="10"} 5
forge_job_duration_seconds_bucket{status="completed",le="30"} 12
All errors follow this format:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": {
"field": "name",
"issue": "Required field missing"
}
},
"requestId": "req_xyz123"
}Common Error Codes:
VALIDATION_ERROR- Invalid inputNOT_FOUND- Resource not foundUNAUTHORIZED- Authentication requiredFORBIDDEN- Permission deniedRATE_LIMIT_EXCEEDED- Too many requestsINTERNAL_ERROR- Server error
Current limits:
- 100 requests per minute per IP
- 1000 requests per hour per API key
Headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1702134000
For list endpoints:
Request:
GET /api/v1/projects?page=2&limit=50
Response:
{
"data": [...],
"pagination": {
"page": 2,
"limit": 50,
"total": 250,
"pages": 5,
"hasNext": true,
"hasPrev": true
}
}# 1. Create a project
curl -X POST http://localhost:3000/api/v1/projects \
-H "Content-Type: application/json" \
-d '{
"name": "My App",
"repoUrl": "https://github.com/user/my-app"
}'
# Response: { "id": "proj_abc123", ... }
# 2. Generate a spec
curl -X POST http://localhost:3000/api/v1/specs \
-H "Content-Type: application/json" \
-d '{
"projectId": "proj_abc123",
"description": "Add user login"
}'
# Response: { "id": "spec_xyz789", ... }
# 3. Execute the spec
curl -X POST http://localhost:3000/api/v1/jobs \
-H "Content-Type: application/json" \
-d '{
"specId": "spec_xyz789"
}'
# Response: { "id": "job_123", "status": "pending" }
# 4. Check job status
curl http://localhost:3000/api/v1/jobs/job_123
# Response: { "id": "job_123", "status": "completed", ... }Subscribe to events:
job.completedjob.failedspec.generated
Interactive API documentation:
http://localhost:3000/api-docs
OpenAPI spec:
http://localhost:3000/api/v1/openapi.json
Need help? Check the Getting Started Guide or open an issue.
Last Updated: December 9, 2024