VI EN

API Reference

REST API documentation for building integrations with TOSE.

Introduction

The TOSE API is a RESTful API that allows you to manage workspaces, projects, deployments, databases, and more programmatically.

Base URL

https://api-v2.tose.sh

Response Format

All responses return JSON with this structure:

{
  "success": true,
  "data": { ... }
}

Error responses:

{
  "success": false,
  "error": "Error message"
}

Authentication

All API requests require an API key passed via the X-API-Key header.

curl https://api-v2.tose.sh/api/workspaces \
  -H "X-API-Key: tose_sk_your_key_here"

Getting an API Key

Create API keys from the dashboard or via the API:

POST /api/workspaces/:slug/api-keys
{
  "name": "My CLI Key",
  "expires_in_days": 90
}

The full API key is only returned once on creation. Store it securely.

API key format: tose_sk_ followed by 40 hex characters.

Error Handling

StatusMeaning
400Bad Request — Invalid parameters
401Unauthorized — Missing or invalid API key
402Payment Required — Insufficient wallet balance
403Forbidden — No permission for this action
404Not Found — Resource does not exist
409Conflict — Resource already exists
500Internal Server Error

Workspaces

POST/api/workspaces

Create a new workspace.

// Request
{ "name": "My Workspace", "slug": "my-workspace" }

// Response
{ "id": "...", "name": "My Workspace", "slug": "my-workspace", "namespace": "..." }
GET/api/workspaces

List all workspaces you have access to.

GET/api/workspaces/:slug

Get workspace details.

PUT/api/workspaces/:slug

Update workspace name or settings.

DELETE/api/workspaces/:slug

Delete a workspace and all its resources.

Members

GET/api/workspaces/:slug/members
POST/api/workspaces/:slug/members
{ "user_id": "...", "role": "admin" }  // Roles: owner, admin, member
PUT/api/workspaces/:slug/members/:user_id
DELETE/api/workspaces/:slug/members/:user_id

Invitations

POST/api/workspaces/:slug/invitations
{ "email": "user@example.com", "role": "member" }
GET/api/workspaces/:slug/invitations
DELETE/api/workspaces/:slug/invitations/:id

API Keys

POST/api/workspaces/:slug/api-keys
// Request
{ "name": "Production Key", "expires_in_days": 90 }

// Response (key shown only once!)
{
  "id": "...",
  "name": "Production Key",
  "key": "tose_sk_abcdef...",
  "key_prefix": "tose_sk_abcd...",
  "expires_at": "2026-06-15T00:00:00Z"
}
GET/api/workspaces/:slug/api-keys
DELETE/api/workspaces/:slug/api-keys/:key_id

Projects

POST/api/workspaces/:slug/projects
// Request
{
  "name": "My App",
  "port": 3000,
  "replicas": 1,
  "cpu": "0.5",
  "ram": "0.5"
}

// Response
{
  "id": "...",
  "name": "My App",
  "slug": "my-app",
  "status": "pending",
  "port": 3000,
  "replicas": 1,
  "cpu": "0.5",
  "ram": "0.5",
  "created_at": "..."
}
GET/api/workspaces/:slug/projects

List all projects in a workspace.

GET/api/workspaces/:slug/projects/:project_slug

Get project details.

PUT/api/workspaces/:slug/projects/:project_slug

Update project settings (name, port, replicas, cpu, ram, etc.).

DELETE/api/workspaces/:slug/projects/:project_slug

Delete project and all associated resources.

Status & Control

GET/api/workspaces/:slug/projects/:project_slug/status
// Response
{
  "project": { "slug": "my-app", "status": "running" },
  "pods": {
    "ready": 1, "total": 1,
    "items": [{ "name": "...", "status": "Running", "restarts": 0, "age": "2h" }]
  },
  "resources": {
    "cpu": { "used": "50m", "limit": "500m" },
    "memory": { "used": "128Mi", "limit": "512Mi" }
  },
  "latestDeployment": { "id": "...", "status": "running", "created_at": "..." }
}
POST/api/workspaces/:slug/projects/:project_slug/restart

Git Connection

POST/api/workspaces/:slug/projects/:project_slug/git
{
  "repo_full_name": "owner/repo",
  "branch": "main",
  "installation_id": 12345,
  "auto_deploy": true
}
PUT/api/workspaces/:slug/projects/:project_slug/git
DELETE/api/workspaces/:slug/projects/:project_slug/git

Environment Variables

GET/api/workspaces/:slug/projects/:project_slug/env
POST/api/workspaces/:slug/projects/:project_slug/env
{ "key": "DATABASE_URL", "value": "postgres://...", "is_secret": true }
PUT/api/workspaces/:slug/projects/:project_slug/env/:env_id
DELETE/api/workspaces/:slug/projects/:project_slug/env/:env_id

Bulk Update

PUT/api/workspaces/:slug/projects/:project_slug/env/bulk
// Request
{
  "variables": {
    "DB_HOST": "localhost",
    "DB_PORT": "5432",
    "API_KEY": "secret"
  },
  "merge": true  // false = replace all
}

// Response
{ "created": 2, "updated": 1, "deleted": 0 }

Deployments

GET/api/workspaces/:slug/projects/:project_slug/deployments

Query params: page (default: 1), limit (1-50, default: 20)

// Response
{
  "deployments": [...],
  "total": 42,
  "page": 1,
  "limit": 20
}
GET/api/workspaces/:slug/projects/:project_slug/deployments/:id
POST/api/workspaces/:slug/projects/:project_slug/deploy

Trigger a new deployment (builds from Git).

POST/api/workspaces/:slug/projects/:project_slug/redeploy

Redeploy using existing image (no rebuild).

POST/api/workspaces/:slug/projects/:project_slug/deployments/:id/stop

Stop a specific deployment.

POST/api/workspaces/:slug/projects/:project_slug/deployments/:id/rollback

Rollback to a previous deployment.

Domains

GET/api/workspaces/:slug/projects/:project_slug/domains
POST/api/workspaces/:slug/projects/:project_slug/domains
{ "domain": "app.example.com" }
DELETE/api/workspaces/:slug/projects/:project_slug/domains/:domain_id

Databases

POST/api/workspaces/:slug/databases
// Request
{ "name": "my-postgres", "type": "postgresql" }
// Types: postgresql, mysql, redis, mongo

// Response
{
  "id": "...",
  "name": "my-postgres",
  "type": "postgresql",
  "status": "running",
  "host": "...",
  "port": 5432,
  "username": "...",
  "password": "...",
  "database_name": "...",
  "connection_string": "postgresql://..."
}
GET/api/workspaces/:slug/databases
GET/api/workspaces/:slug/databases/:db_slug
DELETE/api/workspaces/:slug/databases/:db_slug

Templates

GET/api/workspaces/available-templates

List available pre-built templates (catalog).

// Response
[{
  "name": "Goclaw",
  "key": "goclaw",
  "description": "AI-powered development platform",
  "source": "https://github.com/...",
  "default_port": "3000",
  "default_cpu": "2",
  "default_ram": "4",
  "required_envs": [
    { "key": "GOCLAW_POSTGRES_DSN", "placeholder": "postgresql://..." },
    { "key": "GOCLAW_ENCRYPTION_KEY", "placeholder": "32-char hex" },
    { "key": "GOCLAW_GATEWAY_TOKEN", "placeholder": "token" }
  ]
}]
POST/api/workspaces/:slug/templates
{ "name": "My App", "template_name": "goclaw" }
GET/api/workspaces/:slug/templates
GET/api/workspaces/:slug/templates/:template_slug
PUT/api/workspaces/:slug/templates/:template_slug
DELETE/api/workspaces/:slug/templates/:template_slug
POST/api/workspaces/:slug/templates/:template_slug/deploy
{ "mode": "image" }  // or "build"
POST/api/workspaces/:slug/templates/:template_slug/stop

Template Environment Variables

GET/api/workspaces/:slug/templates/:template_slug/envs
POST/api/workspaces/:slug/templates/:template_slug/envs
// Request (array of key-value pairs)
[
  { "key": "DATABASE_URL", "value": "postgres://..." },
  { "key": "API_KEY", "value": "secret", "is_secret": true }
]
DELETE/api/workspaces/:slug/templates/:template_slug/envs/:key

Template Domains

GET/api/workspaces/:slug/templates/:template_slug/domains
POST/api/workspaces/:slug/templates/:template_slug/domains
{ "domain": "app.example.com" }
DELETE/api/workspaces/:slug/templates/:template_slug/domains/:domain_id

Template Deployments

GET/api/workspaces/:slug/templates/:template_slug/deployments
GET/api/workspaces/:slug/templates/:template_slug/deployments/:id

Wallet & Billing

GET/api/workspaces/:slug/wallet

Get wallet balance and currency.

// Response
{ "balance": 50000, "currency": "VND" }
GET/api/workspaces/:slug/wallet/transactions

List billing transactions (paginated).

GET/api/workspaces/:slug/wallet/usage

Get current usage statistics.

GET/api/workspaces/:slug/wallet/payments

List payment history.

POST/api/workspaces/:slug/wallet/topup/sepay
{ "amount": 100000 }
POST/api/workspaces/:slug/wallet/topup/polar
{ "amount": 10 }
PUT/api/workspaces/:slug/wallet/alert-threshold
{ "threshold": 10000 }

Logs

GET/api/workspaces/:slug/projects/:project_slug/logs

Query params: limit, direction (asc/desc), start, end

GET/api/workspaces/:slug/projects/:project_slug/logs/download

Download logs as gzipped file.

GET/api/workspaces/:slug/projects/:project_slug/logs/usage

Get log storage usage statistics.

POST/api/workspaces/:slug/projects/:project_slug/logs/analyze

AI-powered log analysis.

{ "logs": "error log content here..." }

Uptime Monitoring

GET/api/workspaces/:slug/projects/:project_slug/uptime
// Response
{
  "enabled": true,
  "check_interval_sec": 60,
  "check_url": "https://my-app.tose.sh/health",
  "discord_webhook_url": "...",
  "notify_email": "admin@example.com",
  "status": "up",
  "last_checked_at": "...",
  "last_response_ms": 120
}
PUT/api/workspaces/:slug/projects/:project_slug/uptime
{
  "enabled": true,
  "check_interval_sec": 60,
  "discord_webhook_url": "https://discord.com/api/webhooks/...",
  "notify_email": "admin@example.com"
}

WebSocket Endpoints

Real-time log streaming via WebSocket. Pass API key via the X-API-Key header.

Project Build Logs

WS/api/workspaces/:slug/projects/:project_slug/deployments/:id/logs

Project Live Logs

WS/api/workspaces/:slug/projects/:project_slug/live-logs

Template Build Logs

WS/api/workspaces/:slug/templates/:template_slug/deployments/:id/logs

Template Live Logs

WS/api/workspaces/:slug/templates/:template_slug/live-logs

Connection Example

// Using WebSocket with headers (via ws library)
const WebSocket = require('ws');
const ws = new WebSocket(
  'wss://api-v2.tose.sh/api/workspaces/my-ws/projects/my-app/live-logs',
  { headers: { 'X-API-Key': 'tose_sk_...' } }
);

ws.onmessage = (event) => {
  const data = event.data;
  if (data === '[END]') {
    ws.close();
    return;
  }
  if (data.startsWith('[ERROR]')) {
    console.error(data);
    ws.close();
    return;
  }
  console.log(data);
};

Note: Browser WebSocket does not support custom headers. Use the ws npm package or pass the API key as a query parameter ?api_key=tose_sk_... as a fallback for browser clients.

Special Messages

MessageMeaning
[END]Stream has ended (build complete)
[ERROR] ...An error occurred