Skip to main content

Error Handling

All DaoFlow API errors follow a consistent structure.

Error Response Shape

{
"error": {
"message": "Human-readable error description",
"code": "MACHINE_CODE",
"data": {
"httpStatus": 403,
"requiredScopes": ["deploy:start"],
"grantedScopes": ["deploy:read"]
}
}
}

Error Codes

CodeHTTP StatusDescription
UNAUTHORIZED401No valid token or session
FORBIDDEN403Token lacks required scope
NOT_FOUND404Resource does not exist
BAD_REQUEST400Invalid input parameters
CONFLICT409Duplicate or conflicting operation
INTERNAL_SERVER_ERROR500Unexpected server error

Permission Denied

When a scope is denied, the response includes exactly which scopes were needed and which were granted:

{
"error": {
"message": "Scope denied: deploy:start required",
"code": "FORBIDDEN",
"data": {
"requiredScopes": ["deploy:start"],
"grantedScopes": ["deploy:read", "server:read", "logs:read"]
}
}
}

CLI Exit Codes

The CLI maps API errors to deterministic exit codes:

Exit CodeMeaningAPI Cause
0Success200/201
1General error400/404/500
2Permission denied401/403
3Dry-run completedN/A (local)

Rate Limiting

API requests are rate-limited per token. If exceeded:

{
"error": {
"message": "Rate limit exceeded. Try again in 30 seconds.",
"code": "TOO_MANY_REQUESTS",
"data": {
"retryAfter": 30
}
}
}