REST API
Authentication

Authentication

The DevTeam API supports two authentication methods: API keys for server-to-server communication and JWT tokens for user sessions.

API Keys

API keys are the recommended method for programmatic access. They are prefixed with dtk_ for identification.

Using API Keys

# Header (preferred)
curl -H "Authorization: Bearer dtk_live_abc123def456" \
  https://devteam.marsala.dev/api/tasks
 
# Query parameter (for webhooks and URLs)
curl "https://devteam.marsala.dev/api/tasks?api_key=dtk_live_abc123def456"

Key Types

PrefixTypePermissions
dtk_live_ProductionFull access based on role
dtk_test_TestSandbox only, no production data
dtk_worker_WorkerTask execution only

Creating API Keys

# Via CLI
devteam config create-key --name "CI Pipeline" --role operator
# Created key: dtk_live_abc123def456
# Store this key securely -- it will not be shown again.
 
# Via API
curl -X POST https://devteam.marsala.dev/api/auth/keys \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "CI Pipeline", "role": "operator", "expiresIn": "90d"}'

Revoking Keys

devteam config revoke-key dtk_live_abc123
🚫

API keys grant persistent access. Rotate keys every 90 days and revoke immediately if compromised. Never store keys in source code or client-side applications.

JWT Authentication

JWT tokens are used for user sessions, typically from the dashboard or CLI.

Login

POST /api/auth/login
Content-Type: application/json
 
{
  "email": "admin@example.com",
  "password": "your-password"
}

Response:

{
  "success": true,
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIs...",
    "refreshToken": "dtr_refresh_abc123",
    "expiresAt": "2026-02-21T10:00:00Z",
    "user": {
      "id": "usr_001",
      "email": "admin@example.com",
      "role": "admin",
      "name": "Admin User"
    }
  }
}

Using JWT Tokens

curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
  https://devteam.marsala.dev/api/tasks

Token Refresh

POST /api/auth/refresh
Content-Type: application/json
 
{
  "refreshToken": "dtr_refresh_abc123"
}

Token Expiry

Token TypeDefault ExpiryMaximum
Access token24 hours7 days
Refresh token30 days90 days
API key90 daysNever (manual revocation)

Role-Based Access Control (RBAC)

Roles

RoleDescriptionPermissions
adminFull system accessAll operations
operatorTask and plan managementCreate/read/cancel tasks, plans, templates; manage HITL
viewerRead-only accessRead tasks, plans, templates, status
workerWorker node accessExecute tasks, update status, heartbeat

Permission Matrix

Resourceadminoperatorviewerworker
Tasks: createyesyesnono
Tasks: readyesyesyesyes
Tasks: cancelyesyesnono
Tasks: executeyesnonoyes
Plans: createyesyesnono
Plans: executeyesyesnono
Plans: readyesyesyesno
Templates: createyesyesnono
Templates: readyesyesyesno
Templates: deployyesyesnono
HITL: approve/rejectyesyesnono
HITL: readyesyesyesno
Workers: manageyesnonono
Auth: manage keysyesnonono
Auth: manage usersyesnonono

User Management

# Create a user (admin only)
curl -X POST https://devteam.marsala.dev/api/auth/users \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "operator@example.com",
    "password": "secure-password",
    "name": "Jane Operator",
    "role": "operator"
  }'
 
# List users
curl https://devteam.marsala.dev/api/auth/users \
  -H "Authorization: Bearer $ADMIN_TOKEN"
 
# Update role
curl -X PATCH https://devteam.marsala.dev/api/auth/users/usr_002 \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"role": "admin"}'

Security Headers

All API responses include security headers:

X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains

Next Steps

  • Tasks API -- Task management endpoints
  • Errors -- Authentication error codes