REST API
Errors

Error Codes

All API errors follow a consistent format with a machine-readable code, human-readable message, and a request ID for debugging.

Error Response Format

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Field 'prompt' is required",
    "details": {
      "field": "prompt",
      "rule": "required"
    }
  },
  "meta": {
    "requestId": "req_abc123def456",
    "timestamp": "2026-02-20T10:00:00Z"
  }
}

HTTP Status Codes

StatusMeaningWhen
200OKSuccessful GET, PATCH, DELETE
201CreatedSuccessful POST (task/plan/template creation)
400Bad RequestInvalid input, missing required fields
401UnauthorizedMissing or invalid authentication
403ForbiddenInsufficient permissions for the requested action
404Not FoundResource does not exist
409ConflictDuplicate idempotency key or resource conflict
422Unprocessable EntityValid JSON but semantically invalid (e.g., circular deps)
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error
502Bad GatewayTemporal or upstream service unavailable
503Service UnavailableAPI is temporarily overloaded or in maintenance
504Gateway TimeoutUpstream request timed out

Error Codes Reference

Authentication Errors (401, 403)

CodeMessageResolution
AUTH_REQUIREDAuthentication is requiredInclude Authorization header
AUTH_INVALID_TOKENThe provided token is invalidCheck token format and validity
AUTH_TOKEN_EXPIREDThe authentication token has expiredRefresh the token or re-authenticate
AUTH_INSUFFICIENT_PERMISSIONSYou do not have permission for this actionCheck your role's permission set
AUTH_INVALID_API_KEYThe API key is invalid or revokedGenerate a new API key

Validation Errors (400, 422)

CodeMessageResolution
VALIDATION_ERRORInput validation failedCheck the details.field for the specific issue
INVALID_MODELThe specified model is not availableUse a supported model identifier
INVALID_QUEUEThe specified queue does not existCheck available queues
CIRCULAR_DEPENDENCYPlan contains circular step dependenciesReview dependsOn fields in your steps
MISSING_DEPENDENCYStep references a non-existent dependencyCheck that all dependsOn IDs match step IDs
INVALID_TEMPLATE_SCHEMATemplate input schema is invalidValidate against JSON Schema spec
DUPLICATE_STEP_IDTwo steps share the same IDUse unique IDs for each step

Resource Errors (404, 409)

CodeMessageResolution
NOT_FOUNDThe requested resource was not foundVerify the resource ID
TASK_NOT_FOUNDTask with the given ID does not existCheck the task ID
PLAN_NOT_FOUNDPlan with the given ID does not existCheck the plan ID
TEMPLATE_NOT_FOUNDTemplate with the given ID does not existCheck the template ID
EXECUTION_NOT_FOUNDExecution with the given ID does not existCheck the execution ID
IDEMPOTENCY_CONFLICTA request with this idempotency key already existsUse a different key or retry the original

Task Execution Errors

CodeMessageResolution
TASK_TIMEOUTTask execution timed outIncrease timeoutMs or simplify the prompt
TASK_CANCELLEDTask was cancelled by userNot an error; expected cancellation
MODEL_UNAVAILABLEThe requested model is temporarily unavailableRetry or use a fallback model
MODEL_RATE_LIMITModel provider rate limit hitWait and retry; the SDK handles this automatically
WORKER_UNAVAILABLENo workers available for the specified queueCheck worker health and queue configuration
CONTEXT_TOO_LARGEInput exceeds the model's context windowReduce input size or use a model with larger context

HITL Errors

CodeMessageResolution
HITL_NOT_PENDINGTask is not in awaiting_approval statusCheck task status before approving
HITL_ALREADY_REVIEWEDTask has already been approved or rejectedNo action needed
HITL_TIMEOUTHITL review period has expiredTask was auto-escalated or auto-rejected
HITL_INVALID_REVIEWERThe reviewer ID is not authorizedCheck reviewer permissions

Rate Limiting (429)

CodeMessageResolution
RATE_LIMIT_EXCEEDEDToo many requestsWait for Retry-After seconds

Response includes:

{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Try again in 12 seconds.",
    "details": {
      "limit": 300,
      "remaining": 0,
      "resetAt": "2026-02-20T10:01:00Z",
      "retryAfterMs": 12000
    }
  }
}

Server Errors (500, 502, 503)

CodeMessageResolution
INTERNAL_ERRORAn unexpected error occurredContact support with the requestId
TEMPORAL_UNAVAILABLECannot connect to Temporal serverCheck Temporal server health
DATABASE_ERRORDatabase connection or query errorCheck PostgreSQL health
SERVICE_OVERLOADEDAPI is temporarily overloadedRetry with exponential backoff

Error Handling Best Practices

SDK Error Handling

import {
  DevTeamError,
  AuthError,
  TimeoutError,
  ValidationError,
  RateLimitError,
  NotFoundError,
} from 'devteam-sdk';
 
try {
  const task = await client.createTask({ prompt: '...' });
} catch (error) {
  if (error instanceof AuthError) {
    // Re-authenticate
    await client.refreshToken();
  } else if (error instanceof RateLimitError) {
    // Wait and retry
    await new Promise((r) => setTimeout(r, error.retryAfterMs));
  } else if (error instanceof ValidationError) {
    // Fix input
    console.error('Invalid fields:', error.fields);
  } else if (error instanceof TimeoutError) {
    // Task is still running; just the wait timed out
    console.log('Task still running, check later');
  } else if (error instanceof NotFoundError) {
    console.error(`${error.resource} ${error.resourceId} not found`);
  } else if (error instanceof DevTeamError) {
    // Generic API error
    console.error(`Error ${error.code}: ${error.message}`);
    console.error(`Request ID: ${error.requestId}`);
  }
}

Retry Logic

The SDK implements automatic retries for transient errors:

Retryable: 429, 500, 502, 503, 504, network errors
Not retryable: 400, 401, 403, 404, 409, 422
// Custom retry configuration
const client = new DevTeamClient({
  maxRetries: 5,
  retryBackoff: {
    initialMs: 1000,
    multiplier: 2,
    maxMs: 30000,
  },
});

Always include the requestId from error responses when contacting support. This allows rapid identification of the specific request in server logs.

Next Steps