Skip to content

Connector protocol, version 1

How a connector and the portal talk (ADR 0016). The schemas are in packages/connector-protocol (zod); this page describes them for connectors written in any language. With the TypeScript SDK none of this needs writing by hand.

A connector has two links to the portal, both opened by the connector:

  • the data API: HTTPS requests under /v1/connector/… for configuration, metadata, content and reports;
  • the channel: a WebSocket at /v1/connector/channel, over which the portal asks (test, browse, fetch) and tells (configChanged, syncNow).

Every request and the WebSocket upgrade carry Authorization: Bearer ck_<cell>_<secret>, the token shown when the connector was added. The portal’s own connector host signs in with its secret plus X-Connector-Id instead. Answers: 401 unauthorized (unknown token), 401 connector_revoked (shut out; a new token is needed), 403 knowledge_disabled, 429 rate_limited (1,200 requests a minute).

Errors are { "error": "<code>", "message": "…" }.

A connector describes itself when it connects (hello):

{
"id": "acme.wiki",
"name": { "en": "Acme Wiki", "de": "Acme-Wiki" },
"description": { "en": "Pages of the Acme wiki." },
"version": "1.0.0",
"protocol": 1,
"publisher": "Acme",
"contentTypes": ["document"],
"capabilities": { "sync": true, "delta": true, "browse": true, "fetch": true, "query": false, "permissions": false, "notifications": false },
"settings": [
{ "key": "baseUrl", "type": "url", "label": { "en": "Wiki address" }, "required": true },
{ "key": "apiToken", "type": "secret", "label": { "en": "API token" }, "required": true, "scope": "local" }
],
"sourceSettings": [
{ "key": "space", "type": "path", "label": { "en": "Space" }, "required": true, "browse": true }
]
}
  • id: lower case, dots and dashes; a token belongs to one connector kind.
  • Field type: string, secret, url, path, number, boolean, select (with options), list. Optional: help, placeholder, default, required.
  • scope: local fields are set where the connector runs and never sent to the portal (it learns only whether each is set); portal fields are set in the portal’s form (secrets sealed). A connector the portal runs gets every field from the portal.
  • sourceSettings are set in the portal per source; they hold no secrets.
  • label, help: English is required, other languages optional.
  • capabilities: delta (only changes since a cursor), browse, fetch, query (live search), permissions (reports who may read each item), notifications (registers change notifications with its source), people (answers the HR connection with the people of an HR source behind the firewall, such as LDAP or a CSV export; ADR 0063). All but sync are optional and default to false.
type Payload Processed
document { "markdown": "…", "language": "de" }, or the file itself yes
code { "files": [{ "path", "language", "text" }], "readme" } not yet (415)
video { "durationMs", "language", "transcript": [{ "startMs", "endMs", "text" }], "chapters" }, or the file itself yes: the transcript as sent, or the file heard and seen (ADR 0399); without a transcript, only as a file
audio { "durationMs", "metadata": {}, "transcript": […] }, or the file itself yes, as for video

All payloads carry "type" and "version": 1.

Request Body / answer
GET /v1/connector/config { protocol, connector: { id, name, mode, type }, settings, sources: [{ id, name, settings, contentPolicy, syncEvery, paused, syncRequested, lastSyncAt }], limits: { maxFileBytes, maxMarkdownBytes, batchSize, fileTypes } }
GET /v1/connector/sources/:id/state { cursor }: the connector’s cursor, kept sealed
PUT /v1/connector/sources/:id/state { cursor }
GET /v1/connector/sources/:id/documents?after= { documents: [{ externalId, etag }], next }: what the portal holds, 1,000 a page
POST /v1/connector/sources/:id/documents { documents: [DocumentMeta, … up to 500] } → { needContent: [externalId], skipped: [{ externalId, reason }] }
PUT /v1/connector/sources/:id/documents/:externalId/content JSON payload (above), or the file with its own Content-Type (only with contentPolicy: files_allowed and a type in limits.fileTypes) → 200 { result: stored | unchanged | empty } / 202 { result: reading }
POST /v1/connector/sources/:id/documents/delete { externalIds: [… up to 1,000] } → { deleted }
POST /v1/connector/sources/:id/runs { startedAt, finishedAt, status: ok | partial | failed, seen, changed, deleted, failed, errors: [{ externalId?, message }] }
PUT /v1/connector/sources/:id/subscription { id, expiresAt }: the change subscription the connector registered with its source (notifications)
PUT /v1/connector/fetch/:requestId the original asked for over the channel (fetch), at most 25 MB
PUT /v1/connector/people/:requestId the people asked for over the channel (people), at most 20 MB, while the HR run waits
GET /v1/connector/hosted only for the portal’s own connector host, with its secret: which connectors it runs

DocumentMeta: { externalId, contentType (default document), path, title, link, mime, size, modifiedAt, etag, restricted, access }. etag changes whenever the content does; restricted says the item has permissions of its own in the source (null: unknown). External ids in URLs are URL-encoded.

Permissions (permissions, ADR 0020): access says who may read the item: anyone among readers, cleared for each of its labels.

{ "readers": [{ "kind": "group", "system": "entra", "id": "6f1c…", "name": "HR" },
{ "kind": "user", "system": "email", "id": "ana@contoso.com" },
{ "kind": "everyone", "system": "org", "id": "org" }],
"labels": [{ "system": "purview", "id": "a1b2…", "name": "Confidential – HR" }] }
  • kind: user, group or everyone (the organisation, or anyone with a link). system says where the id comes from, so the portal can match it with the people it knows: email (an address), domain, entra (object ids), ad (Windows SIDs), google (group addresses), sharepoint (site groups), confluence (group names), or a connector’s own (lower case, digits, _). email on a principal is matched as email too.
  • Up to 500 readers and 20 labels. Administrators decide which labels restrict reading; the others are shown only.
  • Left out: the portal keeps what it has; null: unknown (only the source’s audience applies, and an item with restricted: true waits for review).
  • Groups the portal can’t place itself (site groups, Confluence groups) are given to teams by administrators.

A sync: read the cursor; report metadata in batches; send content for what needContent names; report deletions (without delta: what GET …/documents lists and the source no longer has); save the new cursor; send the run report. Syncs are due every syncEvery seconds after lastSyncAt, or when syncRequested is true.

Change notifications (notifications, ADR 0019): when the portal is reachable from the internet, each source in the configuration has notify: { url, clientState, subscription }. Register a subscription with the source that sends its notices to url with clientState (Microsoft Graph: POST /subscriptions), report it with PUT …/subscription, and renew it before it ends (the SDK does when less than 48 hours are left). The portal answers the source’s validation handshake (validationToken), checks clientState on every notice, and asks for a sync (syncNow) at most once a minute. Without notify, scheduled syncs go on.

Open wss://<api>/v1/connector/channel with the same Authorization header and send within 10 seconds:

{ "op": "hello", "protocol": 1, "manifest": { … }, "host": "files01", "local": { "apiToken": true } }

The portal answers { "op": "welcome", "connectorId": "…", "protocol": 1 }. Then:

  • Keep-alive: send { "op": "ping" } every 25 seconds (the portal answers pong; silent channels close after 75 seconds).
  • State: { "op": "status", "sources": [{ "id", "state": "idle" | "syncing" | "error", "message"? }] } when it changes.
  • Notices from the portal: { "op": "notify", "event": "configChanged" } (read the configuration again), { "op": "notify", "event": "syncNow", "sourceId" }.
  • Requests from the portal: { "op": "request", "id", "method", "params" }, answered within 20 seconds with { "op": "result", "id", "ok": true, "result" } or { "op": "result", "id", "ok": false, "error": { "code", "message" } }:
Method Params Result
test { settings } (typed in the portal’s form, merged with the stored ones) { account }: what it reached
browse { sourceSettings, field, path } (path null for the top) { path, entries: [{ name, path, kind: folder | file | container, hasChildren }] }
fetch { sourceId, externalId, requestId } upload the original to PUT /v1/connector/fetch/:requestId, then { uploaded: true }
query { sourceId, q, limit } (limit 1–50, default 20) { hits: [{ externalId, title, path, link, snippet, modifiedAt }] }: what the source holds now, searched with the connector’s own access (the portal offers it to administrators only)
people { requestId } upload { people: [ConnectorPerson, … up to 100,000] } as JSON to PUT /v1/connector/people/:requestId, then { uploaded: true, count }. For connectors with people (ADR 0063); the portal waits up to three minutes

Error codes: settings_invalid, source_unreachable, source_denied, path_outside_root, not_supported, source_not_found, too_large, internal, ….

Close codes after which reconnecting is pointless until the setup changes: 4401 revoked, 4426 protocol not supported, 4422 invalid message or manifest, 4409 the token belongs to another connector kind. On other closes, reconnect with backoff; 4408 means the portal heard nothing for three ping intervals (75 seconds).