Reflexible API Documentation

The Reflexible API provides programmatic access to your Reflexible account, allowing you to manage projects, files, compile RFX code, and interact with AI assistants from external applications.

🚀 Getting Started

To get started with the Reflexible API, you'll need to create an API key from your workspace. Click the Developer Tools button (<>) in your workspace to manage API keys.

Base URL

https://reflexible.ai/api/v1

API Features

📁 Project Management

Create, read, update, and delete projects programmatically.

📄 File Operations

Upload, download, and manage files within your projects.

⚙️ RFX Compilation

Compile and verify RFX code with detailed error reporting.

💬 AI Integration

Start chat sessions and interact with AI assistants.

🏗️ Temporary Workspaces

Create isolated environments for anonymous workflows.

🔐 Secure Access

Fine-grained permissions and access controls.

Authentication

The Reflexible API uses API keys for authentication. You can create and manage API keys from the Developer Tools panel in your workspace.

API Key Types

Permission LevelDescriptionCapabilities
Read OnlyCan only read and download filesGET requests, file downloads
Read/WriteCan read and write filesAll read operations + file uploads, RFX compilation
ManagerFull project managementAll operations + create/delete projects

Project Restrictions

  • No project access: Cannot access any projects
  • Account-wide: Can access all projects in your account
  • Specific project: Limited to a single project

Making Authenticated Requests

Include your API key in the request headers using one of these methods:

Authorization Header (Recommended)

Authorization: Bearer rfx_your_api_key_here

X-API-Key Header

X-API-Key: rfx_your_api_key_here

⚠️ Security Best Practices

  • Never expose API keys in client-side code
  • Use environment variables to store API keys
  • Regularly rotate your API keys
  • Use the least privileged access level needed

Projects

Manage your Reflexible projects programmatically.

GET/api/v1/projects

List Projects

Retrieve a list of projects accessible to your API key.

Example Response
{
  "projects": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "My Robot Controller",
      "updatedAt": 1640995200000,
      "createdAt": 1640908800000
    }
  ]
}
POST/api/v1/projects

Create Project

Create a new project. Requires Manager permissions.

Request Body
{
  "name": "New Project Name"
}
GET/api/v1/projects/{projectId}

Get Project Details

Retrieve detailed information about a specific project.

PATCH/api/v1/projects/{projectId}

Update Project

Update project name or settings. Requires Write permissions.

DELETE/api/v1/projects/{projectId}

Delete Project

Delete a project permanently. Requires Manager permissions.

Files

Upload, download, and manage files within your projects.

GET/api/v1/projects/{projectId}/files

List Files

Get a list of all files in a project.

Example Response
{
  "files": [
    {
      "id": "file-uuid",
      "path": "src/main.rfx",
      "extension": "rfx",
      "sizeBytes": 1024,
      "mimeType": "text/plain",
      "createdAt": 1640995200000,
      "updatedAt": 1640995200000
    }
  ]
}
GET/api/v1/projects/{projectId}/files/{filePath}

Download File

Download the content of a specific file.

Example Response
{
  "file": {
    "id": "file-uuid",
    "path": "src/main.rfx",
    "content": "// RFX code content here",
    "sizeBytes": 1024,
    "mimeType": "text/plain",
    "contentHash": "sha256-hash",
    "updatedAt": 1640995200000
  }
}
PUT/api/v1/projects/{projectId}/files/{filePath}

Upload/Update File

Upload a new file or update an existing one. Requires Write permissions.

Request Body
// Send file content as raw text in request body
// Content-Type: text/plain (or appropriate MIME type)
DELETE/api/v1/projects/{projectId}/files/{filePath}

Delete File

Delete a file from the project. Requires Write permissions.

RFX Compilation

Compile and verify your RFX code using the API.

POST/api/v1/projects/{projectId}/rfx/compile

Compile RFX File

Compile an RFX file and get compilation results.

Request Body
{
  "filePath": "src/main.rfx",
  "content": "// Optional: RFX code to compile"
}
Success Response
{
  "success": true,
  "result": {
    "filePath": "src/main.rfx",
    "compiledAt": "2024-01-01T12:00:00Z",
    "output": "Compilation successful",
    "warnings": [],
    "metrics": {
      "compilationTimeMs": 120,
      "linesOfCode": 45
    }
  }
}
Error Response
{
  "success": false,
  "errors": [
    "Syntax error on line 5: unexpected token"
  ],
  "warnings": []
}
POST/api/v1/projects/{projectId}/rfx/verify

Verify RFX File

Perform static analysis and verification on RFX code.

Request Body
{
  "filePath": "src/main.rfx",
  "checkLevel": "standard",  // basic, standard, strict
  "content": "// Optional: RFX code to verify"
}

AI Chat

Interact with AI assistants programmatically.

GET/api/v1/projects/{projectId}/chat/sessions

List Chat Sessions

Get all chat sessions for a project.

POST/api/v1/projects/{projectId}/chat/sessions

Create Chat Session

Start a new AI chat session.

POST/api/v1/projects/{projectId}/chat/sessions/{sessionId}/messages

Send Message

Send a message to the AI assistant.

Request Body
{
  "role": "user",
  "content": "Help me debug this RFX code",
  "metadata": {
    "context": "debugging"
  }
}
GET/api/v1/projects/{projectId}/chat/sessions/{sessionId}/messages

Get Messages

Retrieve chat messages from a session.

Query Parameters
  • limit - Number of messages to return (max 100)
  • offset - Number of messages to skip
  • since - ISO timestamp to get messages after
GET/api/v1/projects/{projectId}/chat/sessions/{sessionId}/status

Get Session Status

Check the status of a chat session and workspace.

Temporary Workspaces

Create isolated environments for anonymous workflows.

🔒 Permission Required

Your API key must have "Allow anonymous workflows" enabled to use temporary workspaces.

POST/api/v1/workspaces/temporary

Create Temporary Workspace

Create a new temporary workspace that expires after 30 minutes of inactivity.

Response
{
  "workspace": {
    "token": "tmp_workspace_token_here",
    "path": "/tmp/workspaces/tmp_workspace_token_here",
    "expiresAt": 1640995200000,
    "createdAt": 1640993400000
  }
}
GET/api/v1/workspaces/temporary/{token}

Get Workspace Status

Check the status of a temporary workspace.

DELETE/api/v1/workspaces/temporary/{token}

Delete Workspace

Mark a temporary workspace for cleanup.

Error Handling

Understanding API error responses and status codes.

HTTP Status Codes

CodeStatusDescription
200OKRequest successful
201CreatedResource created successfully
400Bad RequestInvalid request parameters
401UnauthorizedInvalid or missing API key
403ForbiddenInsufficient permissions
404Not FoundResource not found
422Unprocessable EntityCompilation or validation errors
500Internal Server ErrorServer error

Error Response Format

{
  "error": "Error message",
  "details": {
    "field": "specific error details"
  },
  "timestamp": "2024-01-01T12:00:00Z"
}

Examples

Code examples for common API operations.

JavaScript/Node.js

// Initialize API client
const API_KEY = 'rfx_your_api_key_here';
const BASE_URL = 'https://reflexible.ai/api/v1';

const headers = {
  'Authorization': `Bearer ${API_KEY}`,
  'Content-Type': 'application/json'
};

// List projects
async function listProjects() {
  const response = await fetch(`${BASE_URL}/projects`, { headers });
  const data = await response.json();
  return data.projects;
}

// Upload a file
async function uploadFile(projectId, filePath, content) {
  const response = await fetch(
    `${BASE_URL}/projects/${projectId}/files/${filePath}`,
    {
      method: 'PUT',
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'text/plain'
      },
      body: content
    }
  );
  return await response.json();
}

// Compile RFX code
async function compileRfx(projectId, filePath) {
  const response = await fetch(
    `${BASE_URL}/projects/${projectId}/rfx/compile`,
    {
      method: 'POST',
      headers,
      body: JSON.stringify({ filePath })
    }
  );
  return await response.json();
}

Python

import requests
import json

API_KEY = 'rfx_your_api_key_here'
BASE_URL = 'https://reflexible.ai/api/v1'

headers = {
    'Authorization': f'Bearer {API_KEY}',
    'Content-Type': 'application/json'
}

# List projects
def list_projects():
    response = requests.get(f'{BASE_URL}/projects', headers=headers)
    return response.json()['projects']

# Upload a file
def upload_file(project_id, file_path, content):
    response = requests.put(
        f'{BASE_URL}/projects/{project_id}/files/{file_path}',
        headers={'Authorization': f'Bearer {API_KEY}'},
        data=content
    )
    return response.json()

# Start chat session
def start_chat(project_id):
    response = requests.post(
        f'{BASE_URL}/projects/{project_id}/chat/sessions',
        headers=headers
    )
    return response.json()['session']

# Send chat message
def send_message(project_id, session_id, message):
    payload = {
        'role': 'user',
        'content': message
    }
    response = requests.post(
        f'{BASE_URL}/projects/{project_id}/chat/sessions/{session_id}/messages',
        headers=headers,
        json=payload
    )
    return response.json()

cURL

# List projects
curl -H "Authorization: Bearer rfx_your_api_key_here" \
     https://reflexible.ai/api/v1/projects

# Upload a file
curl -X PUT \
     -H "Authorization: Bearer rfx_your_api_key_here" \
     -H "Content-Type: text/plain" \
     -d "// RFX code content" \
     https://reflexible.ai/api/v1/projects/PROJECT_ID/files/src/main.rfx

# Compile RFX
curl -X POST \
     -H "Authorization: Bearer rfx_your_api_key_here" \
     -H "Content-Type: application/json" \
     -d '{"filePath": "src/main.rfx"}' \
     https://reflexible.ai/api/v1/projects/PROJECT_ID/rfx/compile

# Create temporary workspace
curl -X POST \
     -H "Authorization: Bearer rfx_your_api_key_here" \
     https://reflexible.ai/api/v1/workspaces/temporary