Authentication¶
Every API call needs an API token. A token acts as the user who created it, limited to the features you select when you create it. This page shows how to give a service account the API features, create a token, send it, choose its features, and rotate it.
At a glance
- Header
TempIdentityToken: <token> - Create tokens in Configuration > Services > API Access
- Grant API features in Configuration > Permissions > API Access
- Acts as The user who created the token, with only the features ticked on it
- Expires Three years after creation, unless you refresh it
How a token works¶
- A token belongs to the user who creates it. Every call made with it runs as that user, and the audit trail shows that user.
- A token grants only the API features you select in the wizard. The wizard lists only the features the creating user has.
- The user's permissions still apply at call time. A call succeeds only when the token has the feature and the user still has it. If an administrator removes a permission from the user, every token of that user loses it too.
- The token string is shown once, when you create it. KnowledgeLake cannot show it again.
Use a dedicated service account (a user created for the integration), not a person's account. When a person leaves or changes role, their tokens stop working or change what they can do.
graph TD
A["Administrator"] -->|"grants API features"| U["Service account"]
U -->|"creates, ticks features"| T["API token"]
T -->|"TempIdentityToken header"| K["KnowledgeLake API"]
K -->|"checks token feature and user permission"| R["Action runs as the service account"]
Give the service account the API features¶
An administrator does this once.
- Go to Configuration > Permissions.
- Find the service account.
- In the API Access section, select the API features the integration needs. Also select Configure API Tokens and Add Tokens, so the account can open the token page and create a token.
- Save.
Create a token¶
- Sign in as the service account.
- Go to Configuration > Services > API Access.
- Select Add a Token. The Add an API Access Token wizard opens.
- Name Token: type a name that says what the token is for, for example
ERP export, production. Select Next. - Access: select the features this token needs, and only those. Select Next.
- Secure Token: select Copy Token to Clipboard, then store the string in your secret store (a key vault, an app setting, an environment variable).
- Select Save.
The token page has two tabs: My Tokens and All Tokens (every token in the tenant; needs the See All Tokens permission). Each row shows the token name, the user and the expiration date, with three actions: refresh the expiration, edit, and delete.
Choose the features¶
Each action belongs to one feature. A call to an action whose feature the token does not have returns HTTP 401. Select features by the groups and actions you call.
| Feature in the wizard | Needed for |
|---|---|
| Manage Work Items | Every V1_KWorkItemAPI action |
| Manage Workflows | V1_WorkflowAPI: list workflows, send to workflow, release a hold, global variables |
| Manage Secret Global Variables | V1_WorkflowAPI/SetSecretGlobalVariable, and GetGlobalVariableMetadata on a secret variable. Select it together with Manage Workflows. |
| Query Jobs | V1_JobsAPI/QueryForJobRuns and QueryForJobHistories |
| Manage Jobs | V1_JobsAPI/ResubmitJob |
| Get Bots | V1_AutomationAPI/GetBots, and V1_RPAAPI/QueryForLatestRPATasks |
| Manage Bots | V1_RPAAPI/ResubmitRPATask |
| Read Batches | V1_ProcessingAPI/QueryForWorkItems and QueryForWorkItemHistories, and read actions of the lower-level V1_BatchAPI |
| Run Searches | V1_RepositoryAPI/GetSavedSearches and RunSavedSearch |
| Access Repository | V1_RepositoryAPI content types, fields, behaviors, destinations and sources |
| Download Documents | V1_RepositoryAPI/DownloadDocument |
| Edit Documents | V1_RepositoryAPI/GetMetadata and UpsertDocumentMetadata |
| Recycle Documents | SendDocumentToRecycleBin (V1 and V2) |
| Send Emails | V2_RepositoryAPI/SendEmail |
| Manage Triggers | V1_TriggerAPI |
| Manage Learn Fingerprints | V1_IntuitiveAIAPI, and the legacy V1_LearnAPI |
| View Catalogs | V1_AppsAPI |
| Get Gateways | V1_RepositoryAPI/GetRemoteGateways |
| Write Events | V1_EventsAPI/WriteEvent |
| Lock Batches, Edit Batches, Access Processing | The lower-level V1_BatchAPI and the legacy Processing actions |
Two names that surprise people
- The Intuitive AI API uses the feature named Manage Learn Fingerprints. Select it for
V1_IntuitiveAIAPIeven if you never use Learn. - Creating or changing a secret global variable needs both Manage Workflows and Manage Secret Global Variables. Without the second one, the call fails with
You cannot modify secret property on this global variable because you do not have the relevant permissions.
Send the token¶
Send the token in a request header. Two forms work:
Use the first form unless your tool can set only the Authorization header. Never put the token in the URL or the body.
A browser session wins over the header
If you test from a browser page where you are signed in to KnowledgeLake, the call can run as you, not as the token user. Test from a script, a REST client or a private window.
Rotate a token¶
Rotate a token before it expires, when a person who knew it leaves, or when you think it leaked.
- Create a new token for the same service account, with the same features.
- Put the new string in your secret store.
- Update every consumer: scripts, Azure Function or Lambda app settings, Power Automate connections, and the HTTP Headers of any Call External API step that calls back into KnowledgeLake. A workflow often holds the token in a secret global variable; update that variable.
- Run one call with each consumer and check
Success. - Delete the old token on the API Access page.
To extend a token without changing the string, select the refresh action on its row. The expiration moves to three years from today.
A consumer that still sends the old token after deletion gets HTTP 401. See Rotate an API token without breaking workflows.
When authentication fails¶
HTTP 401 Unauthorized¶
- Message
User Is Unauthorized on endpoint /api/... - Cause The token is wrong, expired or deleted; the token does not have the feature for that action; or the user lost the permission.
- Fix Check the token row on the API Access page and the user's permissions. To add a feature, edit the token and select it.
No error text in your code¶
- Symptom
Success: falseand your code shows no message. - Cause Your code reads a property that does not exist.
- Fix The text is in
MessageKey(HTTP 401 and 422) or inMessages[].MessageKey(HTTP 412). See the Introduction.
Works for one action, not another¶
- Cause Each action has its own feature.
- Fix Compare the action with the table above.
Service account deleted or disabled¶
- Effect Its tokens stop working.
- Fix Create a new service account and new tokens.
Related¶
- Introduction: call shape and the response envelope.
- Jobs, RPA and Monitoring API: the actions behind the Jobs and Bots features.
- Workflow global variables: where to keep a token for a workflow.
- Gotchas