API keys
An API key lets another system (an ERP, a reporting tool, your own application) call Defthand’s Inspections API. A key is not a person: it has only the permissions you choose and reaches only your company’s data. It has no access at all to the customer portal and user management endpoints.
Prerequisites
Section titled “Prerequisites”- The Integrations module must be on in your company. Otherwise API keys does not appear in the menu or in Settings (Module store).
- You need the permission to manage API keys (the Admin role has it). Without it, it says “Managing API keys needs the “Manage API Keys” permission.”
Where: Administration → Configuration → API keys, Settings → API keys, or API keys in the profile menu.
Key list
Section titled “Key list”| Column | Meaning |
|---|---|
| Name | The name you gave the key. |
| Prefix | The first few characters of the key; lets you recognize which key is in use. The full key is never shown again. |
| Permissions | How many permissions it has (“3 permissions”). |
| Expires | End of validity. |
| Last used | When it was last used; Never if it has never been used. |
| Status | Active, Expired or Revoked. |
If there are no keys yet, it says “No API keys yet.”
Creating a key
Section titled “Creating a key”- Press New key. The New API key window opens: “The key is shown only once. The server keeps only its hash.”
- Enter a Name, e.g. “ERP integration”. It cannot be left empty.
- Choose Valid for: 30 days, 90 days (default), 180 days, 365 days or 730 days.
- Under Permissions, choose what the key may do (table below). At least one permission must be chosen.
- Press Create.
The Your key is ready window opens:
- “Copy this key now and keep it somewhere safe. It is not shown again.”
- Take it with Copy (“Key copied”), then press I copied it, close.
- “Send it in requests with this header:
Authorization: ApiKey <key>”
Permissions that can be given
Section titled “Permissions that can be given”| Group | Permission |
|---|---|
| Inspections | View inspections, View all inspections |
| Findings | View findings |
| Corrective actions | View corrective actions, Manage corrective actions (due date, owner), Verify or send back corrective actions |
| Reports | Download reports |
| Analytics and visitor feedback | View analytics and visitor votes |
| Locations | View locations |
Things to watch:
- A key is not a member of any team or location. To read the whole company’s inspections, also choose View all inspections.
- You can give only permissions you have yourself.
- View locations reads all locations on a key; so to give it you must have the permission to manage locations.
- The list contains only the permissions of modules that are on in your company.
Revoking a key
Section titled “Revoking a key”- In the list, press Revoke on the key’s row.
- The “Revoke the key: ERP integration” window says “Every later request with this key is refused. A revocation cannot be undone; create a new key if you need one.” Press Revoke.
It says “Key revoked” and the status becomes Revoked.
Renewing a key
Section titled “Renewing a key”Keys cannot be extended. Before one expires:
- Create a new key with the same permissions.
- Enter the new key in your integration and check that it works (Last used is updated).
- Close the old key with Revoke.
Security tips
Section titled “Security tips”- Create a separate key for each system; if one leaks, you revoke only that one.
- Give a key only the permissions it really needs. Do not give the permission to manage corrective actions to a system that only reads reports.
- Do not put a key in a code repository, an e-mail or a chat.
- Look into any key whose Last used date is unexpected; revoke the ones not in use.
Example: a reporting tool
Section titled “Example: a reporting tool”The quality team wants to pull inspection results into its own reporting tool every night:
- New key → Name: “Nightly report”, Valid for: 365 days.
- Permissions: View inspections, View all inspections, View findings, Download reports.
- Create → Copy → paste the key into the reporting tool’s secret setting → I copied it, close.
For the API’s endpoints, request formats and error codes: Developers.