Skip to content

Error Handling

The Tiptree Platform API uses standard HTTP status codes and a consistent error response format to communicate errors. This guide explains how to handle errors when using the API.

All API errors follow a consistent JSON format:

{
"error": {
"code": "error_code",
"message": "A human-readable error message",
"details": {
// Additional error-specific information
}
}
}
  • code: A machine-readable error code that can be used to programmatically handle specific error types
  • message: A human-readable description of the error
  • details: An optional object containing additional information about the error

The API uses the following HTTP status codes:

Status CodeDescription
200 OKThe request was successful
201 CreatedThe resource was successfully created
400 Bad RequestThe request was invalid or malformed
401 UnauthorizedAuthentication is required or failed
403 ForbiddenThe authenticated user doesn’t have permission
404 Not FoundThe requested resource doesn’t exist
409 ConflictThe request conflicts with the current state
422 Unprocessable EntityThe request was well-formed but contains semantic errors
429 Too Many RequestsRate limit exceeded
500 Internal Server ErrorAn unexpected error occurred on the server
503 Service UnavailableThe service is temporarily unavailable
Error CodeDescription
invalid_api_keyThe API key is invalid or has been revoked
expired_api_keyThe API key has expired
missing_api_keyNo API key was provided
invalid_oauth_tokenThe OAuth token is invalid or has been revoked
expired_oauth_tokenThe OAuth token has expired
Error CodeDescription
resource_not_foundThe requested resource doesn’t exist
resource_already_existsA resource with the same identifier already exists
resource_conflictThe request conflicts with the current state of the resource
Error CodeDescription
invalid_requestThe request is malformed or missing required fields
invalid_parameterOne or more parameters have invalid values
missing_parameterA required parameter is missing
Error CodeDescription
rate_limit_exceededYou’ve exceeded the rate limit for this endpoint
{
"error": {
"code": "invalid_api_key",
"message": "The API key provided is invalid or has been revoked"
}
}
{
"error": {
"code": "resource_not_found",
"message": "The agent with ID 'agent_123' was not found"
}
}
{
"error": {
"code": "invalid_parameter",
"message": "One or more parameters have invalid values",
"details": {
"errors": [
{
"field": "name",
"message": "Name must be between 1 and 100 characters"
},
{
"field": "model",
"message": "Model must be one of: gpt-4, gpt-3.5-turbo"
}
]
}
}
}
{
"error": {
"code": "rate_limit_exceeded",
"message": "You've exceeded the rate limit for this endpoint",
"details": {
"rate_limit": {
"limit": 100,
"remaining": 0,
"reset": 1609459200
}
}
}
}

When integrating with the Tiptree Platform API, follow these best practices for error handling:

  1. Check HTTP status codes: Always check the HTTP status code first to determine the general category of the error.

  2. Parse error codes: Use the code field to programmatically handle specific error types.

  3. Display error messages: The message field provides human-readable descriptions that can be displayed to users.

  4. Implement retry logic: For transient errors (e.g., 429, 503), implement exponential backoff retry logic.

  5. Log detailed errors: Log the complete error response for debugging purposes.

If you’re using one of our official client libraries, errors are automatically converted to exceptions:

from tiptree.client import TiptreeClient
from tiptree.exceptions import TiptreeAPIError, ResourceNotFoundError, RateLimitExceededError
client = TiptreeClient(api_key="your-api-key")
try:
agent = client.agents.get("non_existent_agent_id")
except ResourceNotFoundError as e:
print(f"Agent not found: {e.message}")
except RateLimitExceededError as e:
print(f"Rate limit exceeded. Try again after {e.reset_at}")
except TiptreeAPIError as e:
print(f"API error: {e.code} - {e.message}")
import { TiptreeClient } from '@tiptree/client';
import { TiptreeAPIError, ResourceNotFoundError, RateLimitExceededError } from '@tiptree/client';
const client = new TiptreeClient({
apiKey: 'your-api-key'
});
try {
const agent = await client.agents.get('non_existent_agent_id');
} catch (error) {
if (error instanceof ResourceNotFoundError) {
console.log(`Agent not found: ${error.message}`);
} else if (error instanceof RateLimitExceededError) {
console.log(`Rate limit exceeded. Try again after ${error.resetAt}`);
} else if (error instanceof TiptreeAPIError) {
console.log(`API error: ${error.code} - ${error.message}`);
} else {
console.log(`Unexpected error: ${error}`);
}
}

If you’re experiencing authentication errors:

  1. Verify that your API key is correct and hasn’t been revoked
  2. Check that your API key has the necessary permissions
  3. For OAuth tokens, ensure they haven’t expired

If you’re hitting rate limits:

  1. Implement exponential backoff retry logic
  2. Consider batching requests where possible
  3. Cache responses to reduce the number of API calls

For validation errors:

  1. Check the details field for specific validation failures
  2. Validate input data before sending it to the API
  3. Refer to the API reference for parameter requirements