Skip to content
TruTecDevelopers
Get an API key

Authentication & API keys

Every call carries a workspace API key. Owners pick what each key can do (read only, read and write, or read, write and delete); keep separate keys for test and production, and rotate them without downtime.

View as Markdown

How keys work#

  • A key belongs to one TruTec workspace and reads or changes that workspace's data. A company with several workspaces can also use one key for all of them: see Companies with several workspaces.
  • Workspace owners create and revoke keys in Settings › API keys.
  • A key is shown once, when you create it. We store only a salted hash, so we can't show it again or recover it. Lost a key? Revoke it and make a new one.
  • Keys start with sk_. The first 11 characters (for example sk_4fQ9xT2b) are the key's public prefix: it's what you see in Settings and what to quote to support.
  • A workspace can have as many active keys as you need. Give each system its own key so you can revoke one without touching the others.
  • Removing someone from the workspace revokes the API keys they created there, and a key whose creator's login is suspended is refused (401, reason: key_owner_suspended). Have an owner who is staying create the replacement. Keys a partner created for its customer workspaces belong to the partner integration and aren't affected.
  • Connecting ChatGPT or Claude by signing in with TruTec creates a key for that assistant, with the access the owner picks: read only, read and change, or read, change and delete (AI assistants and delete). It's listed and revoked like any other key.
  • API access comes with plans that include it. If the plan or billing lapses, calls return 403 or 402 with a message saying why (Errors).

Send the key#

Put the key in the X-API-Key header on every request. The examples read it from a TRUTEC_API_KEY environment variable rather than pasting it into code:

curl https://trutec.ai/api/v1/jobs \
  -H "X-API-Key: $TRUTEC_API_KEY"
import os
import requests

API = "https://trutec.ai/api/v1"
session = requests.Session()
session.headers["X-API-Key"] = os.environ["TRUTEC_API_KEY"]

jobs = session.get(f"{API}/jobs", timeout=30).json()
// Node 18+, server-side only
const API = "https://trutec.ai/api/v1";
const res = await fetch(`${API}/jobs`, {
  headers: { "X-API-Key": process.env.TRUTEC_API_KEY },
});
const jobs = await res.json();

The MCP server also accepts Authorization: Bearer sk_..., because some AI clients can only send that header. The REST endpoints read X-API-Key.

Call from your servers only#

API keys are secrets with access to your company's data. Call the API from your backend, a scheduled job or a serverless function, and keep the key in an environment variable or a secrets manager. Never put a key in browser JavaScript, a mobile app or a public repository. If a key leaks, revoke it in Settings › API keys: revocation takes effect on the next request.

Permissions#

Each key carries a set of permissions, and every endpoint checks them. A call without the permission it needs returns 403 and names what's missing.

Permission Lets the key Default
Read measurements Measure sites, rate pavement condition, and read measurement results, saved takeoffs and imagery On
Read jobs Read customers, sites, jobs, estimates, job costing, events, webhook deliveries and exports On
Write jobs Create and update customers, sites, jobs, contacts, estimates, invoices, job costs, time entries, crews and catalog items; manage webhooks; redeliver and replay events On for read & write keys
Write measurements Save a measurement onto a job as a takeoff, rename takeoffs, mark them done On for read & write keys
Delete records Delete or archive customers, sites, contacts, photos, files, takeoffs and other records (needs the matching write permission too) Off
Partner Manage the workspaces of a software platform's own customers (Partner API) Off, granted by TruTec

When an owner creates a key in Settings › API keys, they pick what it can do, and can change it later from the key's Can list (it takes effect on the key's next call):

Choice Permissions
Read only Read measurements, Read jobs. Every POST, PUT, PATCH and DELETE returns 403 Read-only key, except the few POSTs that only read or measure (measuring a site, crack detection, a measurement's map link, a warranty preview, an export link).
Read and write (default) Read measurements, Read jobs, Write jobs, Write measurements. No deletes.
Read, write and delete Also Delete records.

For reporting, warehouse syncs and anything that only pulls data, Read only is the safer choice: it can see everything and change nothing.

Delete records is off unless the owner picks Read, write and delete. Give it only to a system that needs to delete, archive or merge records.

Each endpoint's page lists the permission it needs.

AI assistants and delete#

When an owner connects ChatGPT or Claude by signing in (AI assistants), the consent screen offers three levels, and the assistant's key gets these permissions:

Level Permissions
Read only Read measurements, Read jobs
Read and change Also Write jobs and Write measurements
Read, change and delete Also Delete records
  • Read, change and delete is never the default. The screen pre-picks Read only or Read and change, whatever scope the assistant asks for, and only a workspace owner can approve any level.
  • It unlocks every delete, remove and merge that needs Delete records, the same as any key with that permission: visits and stops on the schedule (including ones waiting in the queue), people on crews, saved route stops, schedule notes, holds, tasks, photos, files, takeoffs, and whole jobs, customers, sites and contacts (DELETE /v1/jobs/{id}, POST /v1/jobs/{id}/merge, DELETE /v1/client-accounts/{id}, DELETE /v1/locations/{id}, DELETE /v1/contacts/{id} and the customer, site and contact merges).
  • Customers, sites and contacts are archived by default and can be restored; hard=true deletes them for good. Deleting a job takes its takeoffs, estimates, proposals, photos and files with it and can't be undone, and a merge can't be undone. Invoices and payments have no delete in the API at all, only void.
  • Connecting the same assistant again replaces the earlier connection. When the same person connects the same app (by its registered name) to the same workspace, their earlier keys from that app are turned off as the new one is issued, and the consent screen says so first. Keys made in Settings › API keys are never touched. An app that registers without a name is never matched; its older keys show Replaced by a newer connection in Settings › API keys with a one-tap Turn off.
  • Every delete made with any key (a successful DELETE, or a request that used Delete records, such as a merge) is written to TruTec's audit log with the workspace, the key's creator, the key's id and public prefix (never the key), whether it came through the MCP server and which tool, and the record.
  • A key without Delete records gets 403 API key lacks delete permission from the REST API. Over MCP, an assistant on a Read and change connection gets this instead, to pass on to you:
This connection can't delete. Reconnect TruTec in Claude and choose Read, change and delete. Only a workspace owner can choose it.

To change a connection's level, disconnect TruTec in the assistant and connect it again. Each sign-in makes a new key, so revoke the old one in Settings › API keys when you're done.

Companies with several workspaces#

Some companies run several TruTec workspaces: a corporate workspace with one workspace per division or region under it. Each workspace keeps its own customers, jobs, settings and keys. You can work across them in two ways.

One key for all of them. A key made in the corporate (top) workspace can also work in any of its divisions. Send the division's id in the X-TruTec-Workspace header, and that call runs in that division:

curl https://trutec.ai/api/v1/jobs \
  -H "X-API-Key: $TRUTEC_API_KEY" \
  -H "X-TruTec-Workspace: 1291"
  • Leave the header out and the call runs in the key's own workspace.
  • GET /v1/workspace lists the divisions the key can reach under divisions, with each one's id and name.
  • It works in a division only when the person who made the key is an owner there and that division's Who can connect AI assistants and create API keys setting allows them, which is what it takes to make a key in that division. If either stops being true, calls to that division are refused with 403 Workspace not available, and the key keeps working everywhere else.
  • The key's permissions are the same in every division. Writes are made as the key's creator, with their role in that division.
  • Each division's Settings › API keys lists the corporate keys that can work in it. Revoke one in the corporate workspace's Settings.

One key per workspace. Make a key in each workspace instead and send each one to its own workspace. Use this when a division's systems should only ever see that division.

Either way, a key keeps working whichever of your workspaces you have open in TruTec. For AI assistants, see Several workspaces.

Test and production keys#

Keep test traffic away from production data with a sandbox workspace: a separate TruTec workspace with sample customers, sites, jobs and estimates. Its keys can only see sandbox data, so a bug in your test code can't touch your real records. Switching to production means swapping the key, nothing else: the URL and the API are the same. See Sandbox & testing.

Name keys after where they run, for example erp-sync-prod, erp-sync-staging, warehouse-nightly, so the list in Settings tells you what each one is for.

Rotate a key#

Rotation needs no downtime, because a workspace can have more than one active key:

  1. Create a new key in Settings › API keys with the same choice under What can this key do? as the old key.
  2. Deploy it to your system.
  3. Confirm calls succeed with the new key.
  4. Revoke the old key.

Rotate on a schedule that suits your security policy (every 90 days is common), whenever someone with access to the key leaves, and right away if a key may have leaked.

Authentication errors#

Status error What it means
401 Missing API key No X-API-Key header
401 Invalid API key Wrong key, revoked key (including keys revoked when their creator was removed from the workspace), a key whose creator is suspended (reason: key_owner_suspended), or a key whose workspace no longer exists
403 Plan upgrade required The workspace plan doesn't include API access
403 API access disabled API access is turned off for the workspace. Contact support
402 Subscription past due / Subscription inactive Billing needs attention. Access comes back as soon as it's fixed
403 Trial expired / Subscription canceled The workspace has no active subscription
403 Workspace not available X-TruTec-Workspace named a workspace this key can't work in: not one of its divisions, or the key's creator isn't an owner there or isn't allowed to connect AI assistants there
429 API usage limit exceeded This key reached the call cap set on it

Every error body has the same shape:

{
  "error": "Invalid API key",
  "message": "The provided API key is invalid or has been revoked"
}