Error Handling and Troubleshooting
This guide explains how Terminal49’s API reports errors and provides strategies for troubleshooting and handling them effectively in your applications.Understanding Error Responses
Terminal49’s API follows the JSON:API specification for error responses. When an error occurs, the API returns:- An appropriate HTTP status code
- A JSON response with detailed error information
Error Object Properties
Each error object in theerrors array includes:
The HTTP status code for this particular error (as a string).
A short, human-readable summary of the problem.
A human-readable explanation with specific details about the error.
Information about the source of the error:
pointer: A JSON Pointer to the specific field that caused the error (e.g., “/data/attributes/scac”)
A machine-readable error code that can be used for programmatic handling (not always present).
Common HTTP Status Codes
| Status Code | Meaning | Typical Causes |
|---|---|---|
| 400 Bad Request | The request was malformed or invalid | Invalid JSON, missing required fields |
| 401 Unauthorized | Authentication failed | Invalid or missing API key |
| 403 Forbidden | Permission denied | Your API key doesn’t have access to the requested resource |
| 404 Not Found | Resource not found | The requested ID doesn’t exist |
| 422 Unprocessable Entity | Validation errors | Input validation failed |
| 429 Too Many Requests | Rate limit exceeded | You’ve made too many requests in a short period |
| 500, 502, 503 | Server errors | Problem on Terminal49’s side |
Common Error Types and Solutions
Authentication Errors (401)
Authentication Errors (401)
Example:Solutions:
- Check that you’re including the
Authorizationheader with the correct format:Token YOUR_API_KEY - Verify your API key is active in the Developer Settings
- Make sure the API key hasn’t been disabled
Validation Errors (422)
Validation Errors (422)
Example:Solutions:
- Check the
pointerfield to identify which attribute caused the error - Review the
detailmessage for specific information about the validation failure - For duplicate tracking requests, check if the shipment is already being tracked
- Verify SCAC codes against the supported carriers list
Resource Not Found (404)
Resource Not Found (404)
Example:Solutions:
- Verify the ID you’re using exists and is correctly formatted
- Check if the resource might have been deleted
- Confirm you’re using the correct endpoint for the resource type
Rate Limiting (429)
Rate Limiting (429)
Example:Solutions:
- Implement retry logic with exponential backoff
- Spread requests over a longer period
- Contact Terminal49 support if you need a higher rate limit for your use case
Common Error Scenarios
Duplicate Tracking Requests
Error:- Look up the existing tracking request using the
GET /tracking_requestsendpoint with appropriate filters - Use the ID of the existing request to fetch its current status
- If needed, you can update the existing tracking request rather than creating a new one
Unsupported Carrier
Error:- Reference the Carrier Data Matrix for a list of supported carriers
- Double-check the SCAC code format (usually 4 uppercase letters)
- If you need support for a specific carrier, contact Terminal49
Implementing Effective Error Handling
JavaScript Example
Retry Strategy
When dealing with rate limiting or transient errors, implementing a retry strategy with exponential backoff is essential:Best Practices for Error Handling
-
Always check for error responses
- Parse the response body to look for the
errorsarray - Handle both HTTP errors and JSON:API formatted errors
- Parse the response body to look for the
-
Log detailed error information
- Include the status code, error title, error detail, and any source information
- Add context from your application (e.g., what operation was being attempted)
-
Implement appropriate retry logic
- Use exponential backoff for rate limiting (429) errors
- Don’t retry for validation (422) or authentication (401) errors
-
Present user-friendly error messages
- Translate technical API errors to understandable messages for end-users
- Provide actionable guidance when possible
-
Monitor error rates
- Set up alerts for unusual error patterns
- Keep track of error frequency to identify potential issues with your integration
Getting Help
If you encounter persistent errors that you can’t resolve:- Check the API Documentation for endpoint-specific requirements
- Ensure you’re using the latest version of the API
- Contact Terminal49 support at support@terminal49.com with:
- The full error response (with headers if possible)
- A description of what you were trying to do
- Any relevant request IDs or resource IDs
Next Steps
- Learn about Authentication to avoid auth-related errors
- Explore the JSON:API Guide to better understand API responses
- Read about Webhooks for asynchronous event handling