Skip to content

Introduction

The KnowledgeLake REST API lets your own code do what the apps do: create work items, add files, read and write metadata, start workflows, run saved searches, watch scheduled jobs and RPA tasks, and resubmit what failed. Call it from a script, a service, an Azure Function or AWS Lambda that a workflow calls, or a low-code tool such as Power Automate.

This page gives the conventions every call follows. The other API pages link back here instead of repeating them.

For every endpoint with its request and response, see the API Reference.

At a glance

  • Runs In your own code, anywhere that can reach your tenant over HTTPS
  • Language any. Every action is an HTTP POST with a JSON body
  • Authenticated by One header, TempIdentityToken, with a token made in Configuration > Services > API Access
  • Can reach Work items, documents, workflows, global variables, saved searches, content types, jobs, RPA tasks
  • Best for Integrations, bulk work, monitoring, and endpoints that a workflow calls

How a call works

sequenceDiagram
    participant C as Your code
    participant S as Secret store
    participant K as KnowledgeLake API
    C->>S: Read the API token
    C->>K: POST /api/Group/Action with the TempIdentityToken header and a JSON body
    K->>K: Check the token and the token feature for the action
    alt Token missing or expired, or feature not on the token
        K-->>C: 401 with MessageKey
    else Body does not bind to the action
        K-->>C: 422 with MessageKey
    else Action ran and failed
        K-->>C: 412 with Messages and MessageKey
    else Action succeeded
        K-->>C: 200 with Success, MessageKey and Data
    end
    C->>C: Check Success before you use Data

Your first call

V1_WorkflowAPI/GetAllWorkflows lists the active workflows the token's user can view. It takes an empty body, so it is a good test of a new token. The token needs the Manage Workflows feature. Set the environment variable KnowledgeLakeApiToken first, and replace yourcompany.knowledgelake.io with your tenant host.

first-call.sh
curl -sS -X POST "https://yourcompany.knowledgelake.io/api/V1_WorkflowAPI/GetAllWorkflows" \
  -H "TempIdentityToken: $KnowledgeLakeApiToken" \
  -H "Content-Type: application/json" \
  -d '{}'
first-call.ps1
$r = Invoke-RestMethod -Method Post `
  -Uri "https://yourcompany.knowledgelake.io/api/V1_WorkflowAPI/GetAllWorkflows" `
  -Headers @{ TempIdentityToken = $env:KnowledgeLakeApiToken } `
  -ContentType "application/json" -Body "{}"
if (-not $r.Success) { throw "GetAllWorkflows failed: $($r.MessageKey)" }
$r.Data | Select-Object WorkflowName, WorkflowId, Version
first_call.py
import os
import requests

r = requests.post(
    "https://yourcompany.knowledgelake.io/api/V1_WorkflowAPI/GetAllWorkflows",
    headers={"TempIdentityToken": os.environ["KnowledgeLakeApiToken"]},
    json={},
    timeout=60,
)
env = r.json()
if r.status_code != 200 or not env.get("Success"):
    raise SystemExit(f"HTTP {r.status_code}: {env.get('MessageKey') or env.get('Messages')}")
for w in env["Data"]:
    print(w["WorkflowName"], w["WorkflowId"])
first-call.mjs
const response = await fetch("https://yourcompany.knowledgelake.io/api/V1_WorkflowAPI/GetAllWorkflows", {
  method: "POST",
  headers: { "TempIdentityToken": process.env.KnowledgeLakeApiToken, "Content-Type": "application/json" },
  body: "{}"
});
const env = await response.json();
if (response.status !== 200 || !env.Success) {
  throw new Error("HTTP " + response.status + ": " + (env.MessageKey || JSON.stringify(env.Messages)));
}
for (const w of env.Data) {
  process.stdout.write(w.WorkflowName + "  " + w.WorkflowId + "\n");
}
FirstCall.cs
using KL.APIClient.Api;
using KL.APIClient.Client;

var config = new Configuration { BasePath = "https://yourcompany.knowledgelake.io/api" };
config.AddApiKey("TempIdentityToken", Environment.GetEnvironmentVariable("KnowledgeLakeApiToken"));

var workflows = new V1WorkflowAPIApi(config);
var r = await workflows.V1WorkflowAPIControllerGetAllWorkflowsAsync();
if (!r.Success) throw new Exception("GetAllWorkflows failed: " + r.MessageKey);

foreach (var w in r.Data)
{
    Console.WriteLine(w.WorkflowName + "  " + w.WorkflowId);
}

The C# tab uses the generated client. See Creating a C# client.

You are connected when the call returns HTTP 200 with "Success": true and a Data list of workflows. An empty list means the token works but its user can view no active workflow. HTTP 401 means the token is wrong or does not have Manage Workflows: see Authentication.

The call shape

POST https://{tenant}/api/{Group}/{Action}
Content-Type: application/json
TempIdentityToken: {your API token}
  • Tenant {tenant} is your tenant host name.
  • Group and action {Group} is a controller group such as V1_KWorkItemAPI. {Action} is an action such as GetWorkItem. Write both as the spec writes them.
  • Method Reads are POSTs too. The API groups have no GET routes.
  • Files Actions that take a file (for example V1_KWorkItemAPI/AddDocument) take multipart/form-data instead of JSON. The spec marks them.
  • Casing Property names in a body are case-sensitive. Use the spec casing (WorkItemId, not workItemId).
  • Values Every metadata value is a string, also numbers, dates and booleans: "1250.00", "true".

The controller groups

The version prefix (V1_, V2_) is part of the group name.

Group What it is for
V1_KWorkItemAPI Work item automation. Create work items, add documents, pages and files, read and upsert metadata, read OCR, query state and history. See the KWorkItem API reference.
V1_WorkflowAPI List workflows, send a work item to a workflow, release a hold, read and set global variables (secret variables too).
V1_JobsAPI Query scheduled job runs and job history, and run a job now (resubmit). See Jobs, RPA and Monitoring API.
V1_RPAAPI Query the latest attempt of each RPA task, and rerun a task.
V1_ProcessingAPI Two current monitor queries, QueryForWorkItems and QueryForWorkItemHistories. The other actions in this group are legacy (Process Designer).
V1_RepositoryAPI Destinations, sources, content types and fields, field behaviors, saved searches, and documents at rest in a destination (upload, download, metadata, recycle).
V2_RepositoryAPI Send an email, export the configuration of a destination, list identities with access to a content type, recycle a document.
V1_AppsAPI Catalogs, users, groups and app permissions.
V1_TriggerAPI List, export and import triggers, and set trigger tags.
V1_IntuitiveAIAPI Intuitive AI classes, subclasses, training files and the default Auto Extraction action.
V1_EventsAPI Write an event. See the warning in Events and the Secondary Event Provider before you use it.
V1_AutomationAPI List RPA bots and their status.
V1_BatchAPI The lower-level work item API. Each change needs an explicit lock, commit and unlock. Prefer V1_KWorkItemAPI.
V2_ProcessingAPI, V1_LearnAPI Legacy. Process Designer and Learn fingerprints. Keep existing integrations; do not build new ones.

"Batch" is the older name for a work item. You still see it in some group, action and model names (V1_BatchAPI, BatchId). It means the same thing.

The response envelope

Every JSON response has an envelope. Always check Success. Do not rely on the HTTP status alone.

HTTP 200, success:

{
  "Success": true,
  "MessageKey": null,
  "Data": { "WorkItemId": "3f2b8c1e-0d5a-4c7e-9a43-6b1f2e8d9c10" }
}

Data holds the result. Its shape is in the spec for each action. Some actions return no Data.

HTTP 412, the action ran and failed (a missing work item, a locked work item, a bad id, a rejected file type):

{
  "Success": false,
  "Messages": [
    {
      "Success": false,
      "MessageKey": "UNIQUE ERROR ID: 9b1d0e4a-... An error has occurred while processing the request; please check the associated logs for more information. Root message: 'File extension not allowed: .exe' Exception message: 'File extension not allowed: .exe'"
    }
  ]
}
  • Cause Read Messages[].MessageKey. The text after Root message: is the cause.
  • Error id Keep the UNIQUE ERROR ID. KnowledgeLake Support finds the server log entry with it.
  • Spec status The spec lists this response under status 400. The server sends 412.

Other statuses:

Status Meaning
401 The token is missing, wrong or expired, the token does not have the feature for the action, or its user lost the permission. See Authentication.
422 The body did not bind to the action, for example an id that is not a GUID. Compare the body with the spec.
500 An unexpected server error. Retry once. If it repeats, contact Support with the time, the action and the body (without the token).

The 401 and 422 bodies:

401 and 422 responses
{ "Success": false, "MessageKey": "User Is Unauthorized on endpoint /api/{Group}/{Action}" }
{ "Success": false, "MessageKey": "Bad Request for /api/{Group}/{Action}" }

File downloads return bytes

V1_KWorkItemAPI/GetDocumentFile, V1_KWorkItemAPI/GetPageFile and V1_RepositoryAPI/DownloadDocument return the file bytes, not an envelope. Content-Disposition carries the file name. On failure they return the 412 envelope, so check the status before you save the body.

There is no Message property

The text field is MessageKey. There is no Message property. Code that prints response.Message prints nothing.

Handle every response the same way

  1. Status 200: parse the JSON (or save the file) and check Success. Treat Success: false as a failure.
  2. Status 412: fail with the text of Messages[].MessageKey. For a locked work item, wait and retry with a growing delay.
  3. Status 401: check the token and its features. Do not retry.
  4. Status 422: check the body against the spec. Do not retry.
  5. Log the UNIQUE ERROR ID whenever you see one.

The spec your tenant serves

Each tenant serves its own OpenAPI document. No token is needed:

https://{tenant}/api/OpenAPI/V2_JSON/V2_JSON?domain=https://{tenant}
https://{tenant}/api/OpenAPI/V2_YML/V2_YML?domain=https://{tenant}
https://{tenant}/api/OpenAPI/V3_JSON/V3_JSON?domain=https://{tenant}
  • OpenAPI 2.0 V2_JSON and V2_YML are OpenAPI 2.0 (Swagger). Power Automate and Azure Logic Apps import this version.
  • OpenAPI 3.0 V3_JSON is OpenAPI 3.0.
  • Domain domain sets the host in the document. Pass your tenant URL.

The spec is the final word on every request and response shape. It is large. To find one action, search the file for its path, for example "/V1_JobsAPI/QueryForJobRuns", then read that block and the definitions it references. Tell an AI assistant to do the same: search the spec by action name, never read it whole.

Limits

  • Polling Call V1_KWorkItemAPI/GetWorkState no more often than every 1.5 seconds (1500 ms) per work item. A faster caller can get a cached state.
  • Page sizes The query actions (QueryForJobRuns, QueryForJobHistories, QueryForLatestRPATasks, QueryForWorkItems, QueryForWorkItemHistories) return 20 rows by default and at most 1000 per call.
  • Rate There is no general rate limiter. Keep bulk jobs sequential or at low concurrency. See Update metadata on many work items safely.
  • Request size A proxy or gateway in front of your tenant can refuse a large request with HTTP 413. KnowledgeLake does not publish one number for every tenant. Send files as multipart/form-data, one file per request, and ask Support if a large upload fails.

Examples

Copy this into your assistant

Paste the block below into your AI assistant together with the AI Assistant Primer, then describe what you want to build. It is the same contract as this page, written for a model.

KnowledgeLake REST API context for AI assistants
# KnowledgeLake REST API: context for AI assistants

You write code that calls the KnowledgeLake REST API. Use only the groups, actions and fields in
this block or in spec excerpts the user pastes. If you need an action or field that is not here,
ask the user to search their tenant spec for it and paste the block. Never invent an action name.

## Call shape
- Every action: POST https://{tenant}/api/{Group}/{Action}. Reads are POSTs too.
- Headers: TempIdentityToken: <token> (or Authorization: TempIdentityToken <token>), and
  Content-Type: application/json. File actions use multipart/form-data instead.
- Read the token from an environment variable or secret store (default name
  KnowledgeLakeApiToken). Never put a token in code, a URL, a log or chat.
- Group and action names, and body property names, are case-sensitive. Use the spec casing.
- A token acts as the user who created it, limited to the token features ticked on it. Each action
  needs one feature; a missing feature gives HTTP 401.

## Envelope and statuses
- 200: { "Success": bool, "MessageKey": string|null, "Data": ... }. Always check Success.
- 412: { "Success": false, "Messages": [ { "MessageKey": "UNIQUE ERROR ID: ... Root message: '...'" } ] }.
  The action failed. Report the text after "Root message:". Keep the UNIQUE ERROR ID.
  A locked work item gives 412: retry with a growing delay (2, 4, 8 s), then give up and log.
- 401: MessageKey "User Is Unauthorized on endpoint ...". Token or feature problem. Do not retry.
- 422: MessageKey "Bad Request for ...". The body does not match the action. Do not retry.
- 500: retry once.
- The spec lists failures as 400. The server sends 412. Handle 412.
- There is no "Message" property. The text is MessageKey or Messages[].MessageKey.
- GetDocumentFile, GetPageFile, DownloadDocument return file bytes on success, the 412 envelope
  on failure. Check the status before saving.

## Work items (V1_KWorkItemAPI, token feature "Manage Work Items")
- MetadataValueDTO: { "Bucket": "Index", "Key": "InvoiceTotal", "Value": "18330.34" }.
  Every Value is a string. Buckets: Index (indexed fields), General (working values).
  The API drops writes to the System bucket.
- NewWorkItem { WorkItemName?, Metadata?: MetadataValueDTO[] } -> Data { WorkItemId }.
  Not idempotent: store the id before the next call.
- AddDocument (multipart): WorkItemId, File, FileName?, mimeType?, MetadataParameter? (a JSON
  string of { "Metadata": [MetadataValueDTO] }) -> Data { WorkItemId, DocumentId }.
- GetWorkItem { WorkItemId } -> Data { WorkItemId, Name, Metadata: {bucket: {key: value}},
  Documents: [ { Id, Index, Metadata, Files: [ { Id, FileName, Extension, Type } ], Pages } ] }.
  A document id is "Id" in the API and "DocumentId" in scripts. Missing keys are absent: guard.
- UpsertWorkItemMetadata { WorkItemId, Metadata } and UpsertDocumentMetadata { WorkItemId,
  DocumentId, Metadata }: add or overwrite; keys not sent stay. Idempotent. Routes read
  work item metadata, so write routing values at the work item level.
- GetDocumentFile { WorkItemId, DocumentId, DocumentFileId } -> bytes.
- GetWorkState { WorkItemId } -> Data { WorkItemName, WorkStatus, WorkItem }. WorkStatus:
  Completed, Error, Available, BeingWorked, Hold, Stopped, New. Poll no faster than every 1.5 s.
- QueryWorkState { Skip, Take (> 0), WorkItemName?, WorkStatusFilter?, CurrentWorkflowIdFilter?,
  MetadataKeyFilter?, MetadataValueFilter?, FilterScope? } -> one page. Only work items in
  workflows the user can run.

## Workflows (V1_WorkflowAPI, token feature "Manage Workflows")
- GetAllWorkflows {} -> [ { WorkflowId, WorkflowName, Version, FirstStepId } ].
- SendToWorkflow { WorkflowId, WorkItemId, WorkflowVersion?, WorkflowStep? (needs version) }.
  Add every document first; the workflow starts at once.
- ReleaseHold { WorkItemId }. No hold: 412 "No hold was found for workitem {id}".
- SetGlobalVariable / SetSecretGlobalVariable { Name, Value, Tags?, Type?, SubType? }.
  Secret also needs "Manage Secret Global Variables". The secret flag cannot change after creation.
- GetGlobalVariable { Name } (fails for secret variables); GetGlobalVariableMetadata { Name } ->
  { Name, Tags, Type, IsSecret } or Data null when missing.

## Jobs and RPA
- V1_JobsAPI/QueryForJobRuns ("Query Jobs") { JobDisplayName?, JobID?, JobStatus?, PageIndex?,
  PageSize? (20, max 1000), LastRuntimeOnOrAfter?, OrderBy? (Status, LastRunDate, Id),
  Direction? } -> [ { Status, JobID, JobDisplayName, LastRuntime, NextRuntime } ].
  JobStatus: New, Active, Paused, Stopped, Complete, Manual, Hold, Breakout, Archive, Error, Deleted.
- V1_JobsAPI/QueryForJobHistories ("Query Jobs") { JobStatus?, JobID?, JobDisplayName? (case-
  sensitive here), EntryDateOnOrAfter?, Skip?, Take?, OrderBy?, Direction? } -> [ { JobInstanceID,
  JobDisplayName, JobStatus, EntryDate, EventDescription, ExceptionMessage, ... } ].
- V1_JobsAPI/ResubmitJob ("Manage Jobs") { JobInstanceID } runs the job now. Use JobID from
  QueryForJobRuns.
- V1_RPAAPI/QueryForLatestRPATasks ("Get Bots") { TaskIdentifier? ("12.1"), Status? (Queued,
  Running, Complete, Cancelled, Hold, Error, Unknown), BotName?, Automation?, Process?,
  LastUpdateTimeAfter?, PageIndex?, PageSize?, OrderBy?, Direction? (default Descending) } ->
  [ { TaskIdentifier, Status, Message, BotName, Runstamp, Automation, Process, LastUpdated } ].
  No total count: page until a short page. Unknown BotName or Automation is rejected.
- V1_RPAAPI/ResubmitRPATask ("Manage Bots") { TaskIdentifier, Payload? }.
- V1_ProcessingAPI/QueryForWorkItems and QueryForWorkItemHistories ("Read Batches"): current,
  although the rest of V1_ProcessingAPI is legacy.

## Spec
- Spec: https://{tenant}/api/OpenAPI/V2_JSON/V2_JSON?domain=https://{tenant} (no token).
- To find an action, search the spec for its path, for example "/V1_JobsAPI/ResubmitJob", then
  read that block and the definitions it references. Never read the whole spec.

## Rules
1. One helper does every POST: sends the header, checks status and Success, raises with
   MessageKey or Messages[].MessageKey.
2. Prefer V1_KWorkItemAPI over V1_BatchAPI. Do not use V2_ProcessingAPI or V1_LearnAPI.
3. Bulk work: sequential, short pause between calls, dry run first, log every id, resumable.
4. Upsert fixed values. Never append or increment based on what is there.

## Example (Python, requests)
```python
import os, time, requests
BASE = "https://yourcompany.knowledgelake.io/api"
H = {"TempIdentityToken": os.environ["KnowledgeLakeApiToken"]}

def kl(action, body=None, retries=3):
    wait = 2
    for attempt in range(retries + 1):
        r = requests.post(f"{BASE}/{action}", headers=H, json=body or {}, timeout=120)
        env = r.json() if r.headers.get("content-type", "").startswith("application/json") else {}
        if r.status_code == 200 and env.get("Success"):
            return env.get("Data")
        if r.status_code == 412 and attempt < retries:
            time.sleep(wait); wait *= 2; continue
        msgs = [m.get("MessageKey", "") for m in env.get("Messages", [])] or [env.get("MessageKey", "")]
        raise RuntimeError(f"{action}: HTTP {r.status_code} {'; '.join(msgs)}")

wi = kl("V1_KWorkItemAPI/GetWorkItem", {"WorkItemId": "<work item guid>"})
for d in wi["Documents"]:
    print(d["Id"], (d["Metadata"].get("Index") or {}).get("Vendor", ""))
```

## Output
Produce one runnable script or class, with the helper, the calls, and a short "Test it" list.
Ask the user for the tenant host, workflow names, content type field keys and token features you
need. Do not guess them.