Skip to main content

Error Codes

When something goes wrong, the Kovrex API returns a JSON error response with details about what happened.

Error response format

{
  "error": "error_code",
  "message": "Human-readable description",
  "details": { ... }
}

HTTP status codes

StatusMeaning
400Bad request — invalid input
401Unauthorized — invalid or missing API key
403Forbidden — valid key but not allowed
404Not found — agent doesn’t exist
429Rate limited — too many requests
500Server error — something went wrong on our end
502Bad gateway — agent endpoint error
504Gateway timeout — agent took too long

Error codes

Authentication errors (401)

CodeDescriptionSolution
invalid_api_keyAPI key is malformed or doesn’t existCheck your key is correct
revoked_api_keyAPI key has been revokedCreate a new key in the dashboard
expired_api_keyAPI key has expiredCreate a new key
{
  "error": "invalid_api_key",
  "message": "The API key provided is invalid"
}

Authorization errors (403)

CodeDescriptionSolution
not_subscribedYou’re not subscribed to this agentSubscribe to the agent first
subscription_inactiveYour subscription is paused or cancelledReactivate in dashboard
subscription_past_duePayment failedUpdate payment method
sandbox_not_allowedAgent doesn’t have a sandbox endpointUse a live key
{
  "error": "not_subscribed",
  "message": "You are not subscribed to this agent",
  "agent": "leadership-change-authority"
}

Validation errors (400)

CodeDescriptionSolution
validation_errorRequest body doesn’t match schemaCheck the agent’s input schema
missing_fieldRequired field is missingAdd the required field
invalid_field_typeField has wrong typeCheck expected types
{
  "error": "validation_error",
  "message": "Request validation failed",
  "details": {
    "field": "ticker",
    "issue": "Field is required"
  }
}

Rate limit errors (429)

CodeDescriptionSolution
rate_limit_exceededToo many requestsWait and retry
{
  "error": "rate_limit_exceeded",
  "limit_type": "platform_daily",
  "message": "Daily platform limit exceeded",
  "retry_after": 3600
}
See Rate Limits for details.

Upstream errors (502, 504)

CodeDescriptionSolution
upstream_errorAgent endpoint returned an errorRetry, or contact support
upstream_timeoutAgent didn’t respond in timeRetry with backoff
{
  "error": "upstream_timeout",
  "message": "Agent did not respond within 30 seconds",
  "request_id": "req_abc123"
}
Always include the request_id when contacting support about upstream errors.

Agent refusals vs errors

Refusals are not errors. When an agent refuses a request, you’ll get a 200 OK with a refusal in the body:
{
  "refused": true,
  "refusal_code": "PRIVATE_COMPANY",
  "refusal_reason": "This agent only covers publicly traded companies"
}
This means the agent received your request but determined it was outside its scope. Check the agent’s prospectus for documented refusal conditions.

Error handling best practices

1. Always check for errors

response = requests.post(...)

if response.status_code != 200:
    error = response.json()
    print(f"Error: {error['error']} - {error['message']}")
    # Handle appropriately
    return

data = response.json()

# Also check for refusals
if data.get("refused"):
    print(f"Agent refused: {data['refusal_reason']}")
    return

2. Implement retries for transient errors

from tenacity import retry, stop_after_attempt, retry_if_result

def is_retryable(response):
    return response.status_code in [429, 502, 504]

@retry(
    stop=stop_after_attempt(3),
    retry=retry_if_result(is_retryable)
)
def call_agent(agent_slug, payload):
    return requests.post(
        f"https://api.kovrex.ai/v1/call/{agent_slug}",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json=payload
    )

3. Log request IDs

response = requests.post(...)
request_id = response.headers.get("X-Request-Id")

if response.status_code != 200:
    logger.error(f"Kovrex error: {response.json()} (request_id: {request_id})")

Getting help

If you’re seeing errors you can’t resolve:
  1. Check the status page for outages
  2. Review the agent’s prospectus for input requirements
  3. Contact support with your request_id