Skip to main content

Error Handling

General Error Response

When an API request fails, you'll receive a standardized error response object with the following structure:

{
"code": "error_code",
"message": "Human readable error message",
"err": "Detailed error information"
}

HTTP Status Codes

The API uses standard HTTP status codes:

  • 400 Bad Request - Invalid input parameters or validation failure
  • 401 Unauthorized - Missing or invalid authentication
  • 403 Forbidden - Valid authentication but insufficient permissions
  • 404 Not Found - Requested resource doesn't exist
  • 429 Too Many Requests - Rate limit exceeded
  • 500 Internal Server Error - Server-side error

Error Codes Reference

Here's a comprehensive list of error codes you might encounter:

Authentication & Authorization Errors

Error CodeDescription
missing_auth_headerThe Authorization header is missing from the request
missing_api_keyNo API key provided in the Authorization header
invalid_apiThe provided API key is invalid
unauthorizedAuthentication required or failed
forbiddenUser lacks permission for the requested operation
invalid_tokenThe provided token is invalid
invalid_token_dataThe token contains invalid data
invalid_refresh_tokenThe refresh token is invalid

Resource Not Found Errors

Error CodeDescription
api_key_not_foundThe specified API key doesn't exist
user_not_foundThe requested user account was not found
workspace_not_foundThe specified workspace doesn't exist
domain_not_foundThe requested domain was not found
campaign_not_foundThe specified campaign doesn't exist
url_not_foundThe requested URL was not found
file_not_foundThe specified file doesn't exist
tag_not_foundThe requested tag was not found
qr_config_not_foundThe specified QR configuration doesn't exist
plan_not_foundThe requested subscription plan was not found

Validation Errors

Error CodeDescription
invalid_request_bodyThe request body contains invalid data
invalid_campaign_idInvalid campaign identifier provided
invalid_domain_idInvalid domain identifier provided
invalid_url_idInvalid URL identifier provided
invalid_file_idInvalid file identifier provided
invalid_url_hashInvalid URL hash provided
invalid_pageInvalid page number for pagination
invalid_page_sizeInvalid page size for pagination
invalid_time_windowInvalid time window parameter
invalid_domainInvalid domain name provided
invalid_expiration_dateInvalid expiration date format or value

Resource Status Errors

Error CodeDescription
domain_not_activeThe requested domain is currently inactive
user_not_activeThe user account is currently inactive
url_not_activeThe requested URL is currently inactive
expired_invitationThe invitation has expired

Limit Exceeded Errors

Error CodeDescription
max_permanent_urls_reachedReached the maximum allowed permanent URLs
max_agents_reachedReached the maximum allowed agent users
max_custom_domains_reachedReached the maximum allowed custom domains
max_tags_reachedReached the maximum allowed tags
max_urls_reachedReached the maximum allowed URLs
max_campaign_urls_reachedReached the maximum allowed URLs in a campaign
to_many_requestsRate limit exceeded

Feature Requirement Errors

Error CodeDescription
feature_required_password_protectionPassword protection feature required
feature_required_custom_domainCustom domain feature required
feature_required_smart_urlsSmart URLs feature required
feature_required_campaignsCampaigns feature required
feature_required_qr_configsQR configurations feature required
feature_required_user_managementUser management feature required
feature_required_apiAPI access feature required
feature_required_private_statsPrivate statistics feature required
feature_required_pixel_retargetingPixel retargeting feature required
feature_required_url_previewURL preview feature required

Other Errors

Error CodeDescription
internal_errorAn internal server error occurred
user_not_adminOperation requires admin privileges
user_is_ownerOperation cannot be performed on workspace owner
url_validation_failedURL validation check failed
https_neededHTTPS protocol is required for this operation

Error Handling Example

try {
const response = await fetch('https://api.joo.nz/v1/url', {
headers: {
'Authorization': 'YOUR_API_KEY'
}
});

if (!response.ok) {
const error = await response.json();
console.error(`Error: ${error.code} - ${error.message}`);
// Handle error appropriately
}
} catch (err) {
console.error('Request failed:', err);
}

Rate Limiting

The API implements rate limiting to ensure fair usage. When you exceed the rate limit, you'll receive a 429 Too Many Requests status code with the to_many_requests error code. We recommend implementing exponential backoff in your applications when encountering rate limit errors.