Overview
When a request to the TeamTrace API can't be completed, the API returns an error response with a status code and a message. This article lists the error codes you may receive, explains what each one means, and shows how to fix and handle them in your application. It also explains two situations that look like errors but are not: an empty result and a network failure.
Before You Begin
- Read How to Authenticate with the TeamTrace API first, because most failed requests are caused by a missing or expired token.
- Check the HTTP status code of the response in your tool or code before you read the response body.
- Keep the exact error message. It tells you which part of your request to fix.
The Error Response Format
An error response is JSON and has three fields:
{
"status": "error",
"message": "Unauthorized",
"code": 401
}| Field | What it shows |
| status | The word error when the request failed. A successful request returns success. |
| message | A short description of what went wrong. |
| code | The error code, for example 401, 400 or 500. |
Error Codes at a Glance
| Code | Message | Meaning | Who needs to act |
| 401 | Unauthorized | The token is missing, wrong or expired. | You |
| 400 | Invalid date format. Use YYYY-MM-DD | The date is not in the required format. | You |
| 400 | Invalid user_id | The user ID is not a valid UUID. | You |
| 400 | Page and limit must be integers ≥ 1 | page or limit is not a whole number of 1 or more. | You |
| 500 | Internal server error | A problem on the TeamTrace side. | Retry, then contact support |
401 Unauthorized
{
"status": "error",
"message": "Unauthorized",
"code": 401
}What it means. The API doesn't accept your authorization token. The token may be missing, wrong or expired.
How to fix it
- Check that the authorization header is in the request, and that its name is spelled exactly.
- Check that the header holds the token you received, with no extra spaces or missing characters.
- Request a new token if the old one has expired. See How to Authenticate with the TeamTrace API.
Handle it in code (Node.js)
if (response.status === 401) {
throw new Error("Auth failed. Check or refresh token.");
}400 Bad Request: Invalid Date
{
"status": "error",
"message": "Invalid date format. Use YYYY-MM-DD",
"code": 400
}What it means. A date in your request isn't in the YYYY-MM-DD format, for example 2026-04-21.
How to fix it. Send the year first, then the month, then the day, each separated by a hyphen. Dates such as 21-04-2026 or 04/21/2026 are not accepted. This applies to every date field, including date, created_start_date, created_end_date, apply_date, from_date and to_date.
Check it before you send
function isValidDate(date) {
return /^\d{4}-\d{2}-\d{2}$/.test(date);
}400 Bad Request: Invalid user_id
{
"status": "error",
"message": "Invalid user_id",
"code": 400
}What it means. The user_id in your request is not a valid UUID.
How to fix it. Send the user's full UUID, for example 123e4567-e89b-12d3-a456-426614174000. A UUID has 36 characters, including hyphens. Get the ID from the user list. See How to Fetch the User List with the TeamTrace API. The Customer Task List request has the same rule for its uuid field.
Check it before you send
function isUUID(id) {
return /^[0-9a-fA-F-]{36}$/.test(id);
}400 Bad Request: Invalid page or limit
{
"status": "error",
"message": "Page and limit must be integers ≥ 1",
"code": 400
}What it means. page or limit is not a whole number of 1 or more.
How to fix it. Send both as whole numbers of 1 or more, for example page=1&limit=10. Values such as 0, -1, 2.5 or text are rejected. Put them in the URL as query parameters, not in the request body.
500 Internal Server Error
{
"status": "error",
"message": "Internal server error",
"code": 500
}What it means. Something went wrong on the TeamTrace side. Your request is not necessarily wrong.
How to fix it
- Wait a moment and send the same request again.
- If it keeps failing, contact TeamTrace support with the endpoint, the time of the request and the response message.
Handle it in code
if (response.status >= 500) {
console.log("Retrying...");
}Errors Without a Specific Code
The Customer List, Customer Task List, User List and Leave List documentation says an error is returned when the authorization fails or a required or invalid value is sent. It doesn't list the exact codes and messages for these endpoints.
| Endpoint | Common cause |
| Customer List | The token is wrong, customer_status is missing or is not ACTIVE or INACTIVE, or limit or page is invalid. |
| Customer Task List | The token is wrong, the uuid is missing or invalid, a date is not in YYYY-MM-DD format, or limit or page is invalid. |
| User List | The token is wrong, or limit, page or user_current_status is invalid. |
| Leave List | The token is wrong, a date is not in YYYY-MM-DD format, or status, limit or page is invalid. |
Situations That Are Not Errors
An empty result
When no records match your request, the API still reports success and returns an empty list. For example, a timesheet request with no data returns this:
{
"status": "success",
"page": 1,
"limit": 10,
"total": 0,
"data": []
}Check the list in your code and show a message such as "No records for this date", instead of treating it as a failure.
if (data.screenshots.length === 0) {
console.log("No screenshots for this date.");
}A timeout or network failure
If your request times out or can't reach the API, you receive no response from TeamTrace at all, so there is no status code or JSON error. Your tool or code reports the failure, for example FetchError: request timed out. Check your internet connection, then retry the request.
async function fetchWithRetry(url, options, retries = 3) {
try {
const res = await fetch(url, options);
return res;
} catch (err) {
if (retries > 0) {
return fetchWithRetry(url, options, retries - 1);
}
throw err;
}
}Tips
- Read the message first. It names the problem, for example the date, the user ID or the pagination values.
- Validate before you send. Check dates, UUIDs, page and limit in your own code to avoid most 400 errors.
- Retry only when it makes sense. Retry 500 errors and network failures. Don't retry 400 or 401 errors until you have fixed the request or the token.
- Refresh the token on 401. Request a new token, then send the failed request again once.
- Log the details. Keep the endpoint, the time and the response message so support can find the problem quickly. Don't log your token or your Client Secret.
- Handle empty results. An empty list is a normal response.
Notes
- The code in the response body matches the HTTP status of the response.
- Every 400 error means the request itself needs a fix. Sending it again unchanged gives the same error.
- An empty list with "status": "success" is not an error.
Troubleshooting
| Problem | What to check |
| Every request returns 401 | Check the authorization header and the token. Request a new token and try again. |
| A request worked earlier and now returns 401 | The token has probably expired. Request a new one. |
| I get 400 on a request with a date | Check that every date is in YYYY-MM-DD format. |
| I get 400 on a request with a user ID | Check that the ID is a full, valid UUID, with no spaces or missing characters. |
| I get 400 with page and limit | Send whole numbers of 1 or more, as query parameters in the URL. |
| The response is empty but there is no error | No records match. Check your filters and the date. |
| I get 500 every time | Retry after a moment. If it continues, contact TeamTrace support with the details of the request. |
| I get no response at all | Check your internet connection and the endpoint URL, then retry. |
| I get an error that isn't listed here | Copy the full response and contact TeamTrace support. [Add: the support contact.] |
Related Articles
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article