API Reference
Errors

Error Handling

The Tenuo Cloud API uses conventional HTTP response codes and returns detailed error information in JSON format.

Error Response Format

All errors follow this format:

{
  "error": {
    "code": "error_code",
    "message": "Human-readable error message",
    "details": {
      "field": "additional context"
    }
  }
}

HTTP Status Codes

StatusDescription
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient scope
404Not Found - Resource doesn't exist
409Conflict - Resource already exists or state conflict
422Unprocessable Entity - Validation error
429Too Many Requests - Rate limited
500Internal Server Error

Error Codes

Authentication Errors

CodeStatusDescription
unauthorized401Missing Authorization header
invalid_api_key401API key is invalid or malformed
expired_api_key401API key has expired
revoked_api_key401API key has been revoked
insufficient_scope403API key lacks required scope

Validation Errors

CodeStatusDescription
invalid_request400Request body is malformed
missing_field400Required field is missing
invalid_field422Field value is invalid
invalid_id_format400ID format is invalid

Resource Errors

CodeStatusDescription
not_found404Resource not found
already_exists409Resource already exists
conflict409Operation conflicts with current state

Key Errors

CodeStatusDescription
key_not_found404Key does not exist
key_revoked409Key is already revoked
key_suspended409Key is suspended
parent_key_required400Issuer/notary keys require a parent
invalid_parent_key400Parent key is invalid or incompatible

Revocation Errors

CodeStatusDescription
revocation_not_found404Revocation does not exist
already_revoked409Warrant is already revoked
srl_expired400SRL has expired and needs regeneration

Rate Limiting

CodeStatusDescription
rate_limited429Too many requests

Rate limit headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1706123456

Handling Errors

Retry Strategy

For transient errors (429, 500, 503), implement exponential backoff:

import time
import requests
 
def request_with_retry(url, headers, max_retries=3):
    for attempt in range(max_retries):
        response = requests.get(url, headers=headers)
        
        if response.status_code == 429:
            # Rate limited - wait and retry
            reset_time = int(response.headers.get('X-RateLimit-Reset', 0))
            wait_time = max(reset_time - time.time(), 1)
            time.sleep(min(wait_time, 60))
            continue
            
        if response.status_code >= 500:
            # Server error - exponential backoff
            time.sleep(2 ** attempt)
            continue
            
        return response
    
    raise Exception("Max retries exceeded")

Getting Help