DocsAPI ReferenceAll docs

DEVELOPER

API Reference

Programmatic access to ForLoop via authenticated API endpoints.

API Reference

Programmatic access to ForLoop via the /api/opencode/* endpoints. Authenticate using an API token passed in the x-api-token header.

Authentication

All API requests require an API token. Tokens are scoped and time-limited.

curl -H "x-api-token: floop_YOUR_TOKEN" \
  https://api.forloop.cc/api/opencode/sprints

Getting a Token

  1. Go to Profile → API Tokens in the ForLoop web app
  2. Click Create Your First Token
  3. Choose a preset or configure custom scopes
  4. Copy the token — it's shown only once

Token Format

floop_<base64-encoded-payload>

Tokens are stored as SHA-256 hashes on the server. The plaintext token is only shown once during creation.

Scopes

ScopeDescription
sprint:readView sprint details and stories
sprint:writeCreate and update sprints
story:readView story details
story:writeCreate and update stories
story:deleteDelete stories
agent:readView AI agent definitions
agent:queryChat with AI agents
profile:readRead user profile
profile:writeUpdate user profile
organization:readView organization details
organization:writeCreate and update organizations
organization:deleteDelete organizations
secrets:readRead space environment secrets
secrets:writeCreate, update, and delete space secrets
a2a:readRead A2A connections and contracts
a2a:writeManage A2A connections
catalog:adminAccess space catalog administration
admin:panelAccess admin panel operations

Endpoints

Sprints

GET    /api/opencode/sprints              List sprints (sprint:read)
GET    /api/opencode/sprints/:id          Get sprint details (sprint:read)
POST   /api/opencode/sprints              Create sprint (sprint:write)
PUT    /api/opencode/sprints/:id          Update sprint (sprint:write)
DELETE /api/opencode/sprints/:id          Delete sprint (sprint:write)
PUT    /api/opencode/sprints/:id/ai-agents Update AI agents (sprint:write)

Stories

GET    /api/opencode/stories/:id          Get story (story:read)
POST   /api/opencode/stories              Create story (story:write)
PUT    /api/opencode/stories/:id          Update story (story:write)
DELETE /api/opencode/stories/:id          Delete story (story:delete)
GET    /api/opencode/stories/:id/comments List comments (story:read)
POST   /api/opencode/stories/:id/comments Create comment (story:write)

AI Agents

GET    /api/opencode/ai/agents            List available agents (agent:read)
POST   /api/opencode/agents/chat          Chat with AI (agent:query)
POST   /api/opencode/agents/suggestions   Get story suggestions (agent:query)
GET    /api/opencode/agents/tasks         List AI tasks (agent:query)
GET    /api/opencode/agents/summary       Get sprint summaries (sprint:read)

Autopilot

Autopilot runs through the sprint board and its approval checkpoints. The current public router does not expose /api/opencode/autopilot/* endpoints; do not build integrations against those paths.

User Profile

GET    /api/opencode/user/profile         Get profile (profile:read)
PUT    /api/opencode/user/profile         Update profile (profile:write)
GET    /api/opencode/user/quotas          Get quotas (profile:read)

Organizations

GET    /api/opencode/organizations          List user orgs (organization:read)
GET    /api/opencode/organizations/owned    List owned orgs (organization:read)
POST   /api/opencode/organizations          Create org (organization:write)
PUT    /api/opencode/organizations/:id      Update org (organization:write)
DELETE /api/opencode/organizations/:id      Delete org (organization:delete)
GET    /api/opencode/organization/:id/quotas Get org quotas (organization:read)

Files

POST   /api/opencode/files/upload       Upload canvas file (story:write)
POST   /api/opencode/files/presign      Get presigned URL (story:write)
POST   /api/opencode/files/complete     Complete upload (story:write)
GET    /api/opencode/files/download/:id Download file (story:read)
GET    /api/opencode/files/open-url/:id Get open URL (story:read)
GET    /api/opencode/files/sprint/:id   List sprint files (story:read)
PUT    /api/opencode/files/:id/position Update position (story:write)
DELETE /api/opencode/files/:id          Delete file (story:write)

Templates

GET    /api/opencode/templates          List templates (story:read)
# Template creation is system-owned; POST /api/opencode/templates returns 403.

Creating API Tokens via API

Tokens can also be created programmatically using Clerk authentication:

POST /api/opencode/auth/tokens
Authorization: Bearer <clerk-token>

{
  "name": "My Token",
  "expiresIn": "30d",
  "scopes": ["sprint:read", "story:read", "story:write"]
}

Response

{
  "token": "floop_eyJpYXQiOjE3MTQ5...",
  "tokenId": 42,
  "name": "My Token",
  "expiresAt": "2024-06-15T00:00:00.000Z",
  "scopes": ["sprint:read", "story:read", "story:write"]
}

Expiration Options

ValueDuration
7d7 days
30d30 days
90d90 days
1y1 year

Manage Tokens

GET    /api/opencode/auth/tokens          List tokens
DELETE /api/opencode/auth/tokens/:id      Revoke token

Error Responses

StatusError CodeDescription
401invalid_tokenMissing or invalid API token
403insufficient_scopeToken lacks required scope
400VariousInvalid request parameters
404not_foundResource not found
500internal_errorServer error

Rate Limits

API requests are rate-limited based on your subscription tier. Check your quotas via GET /api/opencode/user/quotas.


OpenAPI

The public OpenAPI description is available at /openapi.json. It covers the documented public subset and uses generic resource schemas until the full response contract is verified.

Base URL

EnvironmentURL
Productionhttps://api.forloop.cc
Developmenthttps://api.dev.forloop.cc