Overview
The TeamTrace API gives your application access to information about your customers, users, leave, screenshots and timesheets. This data is sensitive, so the way your application handles credentials and responses matters as much as the way TeamTrace protects its servers. This article lists practical habits that keep your integration, and your data, safe.
Before You Begin
- You should already know how to get a token. See How to Authenticate with the TeamTrace API and Understanding x-client-id and x-client-secret in the TeamTrace API.
- Decide who in your team builds and runs the integration. The fewer people who handle the credentials, the safer they are.
The Short List
| Do | Don't |
| Keep your Client Secret and token in a secrets manager or environment variable. | Put them in source code, front-end code, screenshots or chat messages. |
| Call the API from your server. | Call it from a browser or mobile app where users can read your credentials. |
| Send credentials and the token in headers. | Put them in the URL or in a request body. |
| Use HTTPS for every request. | Send any request over plain HTTP. |
| Validate every value before you send it. | Pass unchecked user input straight into a request. |
| Request only the data you need. | Download and keep everything "just in case". |
1. Protect Your Credentials
Your Client ID, Client Secret and authorization token are the keys to your data. Anyone who has them can act as your application.
- Store them securely. Use an environment variable or a secrets manager, and keep them out of your source code and out of version control.
- Keep them off the front end. Code that runs in a browser or a mobile app can be read by anyone, so make API calls from your own server.
- Never share them in public places. That includes public repositories, chat messages, emails, support tickets and screenshots.
- Use placeholders in examples. Write YOUR_CLIENT_SECRET and YOUR_TOKEN in documentation and tickets.
Read credentials from the environment (Node.js)
const clientId = process.env.TEAMTRACE_CLIENT_ID; const clientSecret = process.env.TEAMTRACE_CLIENT_SECRET;
2. Send Requests Safely
- Use headers for secrets. The Client ID and Client Secret go in x-client-id and x-client-secret. The token goes in authorization. URLs can end up in logs, browser history and reports, so keep secrets out of them.
- Always use HTTPS. All TeamTrace API endpoints start with https://api-info.teamtrace.app. Don't change this to plain HTTP.
- Use the right method. Customer List and User List use GET. The other endpoints use POST, with a JSON body and the Content-Type: application/json header.
3. Handle Tokens Carefully
- Reuse a token until it expires. Don't request a new token for every call.
- Refresh on 401. If the API returns 401 Unauthorized, request a new token and retry the request once.
- Don't log tokens. Keep tokens and secrets out of your application logs and error reports.
- Keep tokens in memory when you can. If you must store a token, store it as securely as you store the Client Secret.
4. Validate What You Send
The API rejects values in the wrong format with a 400 error. Checking values in your own code first avoids failed requests, and stops bad input from user-facing forms from reaching the API.
- Dates must be in YYYY-MM-DD format.
- User and customer IDs must be valid UUIDs.
- page and limit must be whole numbers of 1 or more.
- customer_status must be ACTIVE or INACTIVE.
function isValidDate(date) {
return /^\d{4}-\d{2}-\d{2}$/.test(date);
}
function isUUID(id) {
return /^[0-9a-fA-F-]{36}$/.test(id);
}5. Handle Errors Without Leaking Information
- Handle every error code. See TeamTrace API Error Codes for 401, 400 and 500.
- Retry only when it helps. Retry 500 errors and network failures a few times. Don't retry 400 or 401 errors until you have fixed the request or the token.
- Show users a simple message. Don't pass the raw API response, headers or request details to your own users.
- Treat an empty list as normal. It means no records match, not that something failed.
6. Protect the Data You Receive
API responses can include names, work hours, leave records and screenshot details of real people. Once the data leaves TeamTrace, you are responsible for it.
- Ask only for what you need. Use filters such as date, user_id and customer_status, and use page and limit instead of downloading everything.
- Store it securely. Keep saved data encrypted, and limit who can open it.
- Keep it only as long as you need it. Delete data you no longer use.
- Respect privacy rules. Follow the laws and company policies that apply to employee data. See How to Control Access to Employee Data in TeamTrace.
7. Keep Watch Over Time
- Use one set of credentials per application. This makes it easy to tell which application made a request, and to replace one set without affecting the others.
- Limit who can see the credentials. Share them only with the people who build or run the integration, and remove access when someone leaves the team.
- Monitor your own logs. Watch for sudden spikes in requests or repeated 401 errors, which can mean a leaked credential or a faulty script.
- Test with sample data first. Check a new integration on a small request before you run it on everything.
- Review regularly. Check which applications still need access, and replace credentials that may have been seen by too many people.
What to Do If Your Credentials Are Exposed
- Act straight away. Assume anyone who saw the credentials can use them.
- Replace the credentials. [Add: how to regenerate or revoke the Client ID and Client Secret.]
- Update your application with the new values, and remove the old ones from code, logs and messages.
- Check for misuse. Look at your own logs for requests you don't recognise, and check the User Activities page in TeamTrace for unexpected changes. See How to View the Audit Trail (User Activities) in TeamTrace.
- Tell TeamTrace support if you think data was accessed. Email support@teamtrace.app
Tips
- Treat the Client Secret like a password. If you wouldn't paste a password there, don't paste the secret there.
- Scan your code for secrets before you publish or share it.
- Build the checks once. Put date, UUID and pagination validation in one shared function that every request uses.
- Write down who owns the integration, so someone is responsible for its credentials.
Notes
- Several of the practices above come from the way the TeamTrace API works: credentials in headers, a token on every protected endpoint, and strict validation of dates, UUIDs and page values.
- The other practices are general good habits for any API.
- TeamTrace's own platform security is described separately. See TeamTrace Security and VAPT Overview.
Troubleshooting
| Problem | What to check |
| I committed my Client Secret to a repository | Treat it as exposed. Replace the credentials, and remove the secret from the code and from the repository history. |
| I see many 401 errors in my logs | The token may have expired, or someone may be using wrong or old credentials. Check your own code first, then check for misuse. |
| I see requests I don't recognise | Replace the credentials straight away, and contact TeamTrace support. |
| I get 400 errors from user input | Validate dates, UUIDs, page and limit in your code before you send the request. |
| A teammate who knew the credentials has left | Replace the credentials, and update your application. |
| I need to test without using real data | [Add: whether there is a test or sandbox environment for the API.] |
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