Agent API Integration Guide
Schemas and Try it: use the API Reference (agent) for request/response fields. This page is an Integration Guide (auth modes, sessions, async delivery, widget embed, errors).
Related: SSO Integration Guide · MCP Integration Guide · API Reference Integration Guide
Call the Lincoln Cannon LLC agent over HTTP from your own backend. You need an API key enabled for agent access and a way to identify which agent to run: either an allowed origin, or an agent id (UUID) in the JSON body or X-Agent-Key header, supplied by your integration provider.
Browser widget: Partner embeds use POST /agent/chat with a user Bearer token only—not x-api-key. Server backends should use /request or /stream (below). Customer sites (including staging hosts whose names contain dev) call the production Agent API and OAuth hosts unless your integration contact says otherwise.
Try your agent (test page): Open https://test.lincolncannon.co/agency/ on a trusted device only. Paste your agent key (UUID) and API key, then use the chat widget (sign in when prompted). The widget sends x-api-key and Bearer on POST /agent/stream. Usage is billed to the account tied to your API key; you can only chat with agents you own or that were granted to your organization. Prefer a limited integration key; treat the paste field as exceptional (not a production pattern); rotate the key if it may have been exposed. Do not put API keys in public HTML—keep keys on your server for product embeds.
Routes
| Route | Response | Use when |
|---|---|---|
POST /agent/request | JSON (200) or 202 job accept | Server backends; sync JSON, or async poll/webhook for longer turns |
GET /agent/request/jobs/{jobId} | JSON | Poll status/result after async POST /agent/request |
POST /agent/stream | SSE (streaming events) | Server backends that need streaming tokens |
POST /agent/chat | SSE (streaming events) | Browser embeds with user Bearer only (no API key) |
GET /agent/transcript | JSON | Browser embeds: the signed-in caller's thread (no API key, no client session id) |
POST /agent/{chat,request,stream}/files, POST …/files/{fileId}/complete, DELETE …/files/{fileId} | JSON | Upload a file for a prompt (organization sessions only; see Attaching files) |
Base URL: https://api.lincolncannon.co/agent/. If your integration contact gives you a non-production API base, use that instead.
Shared headers (/request and /stream)
| Header | Required | Notes |
|---|---|---|
Content-Type | Yes | application/json |
x-api-key | Yes | API key issued for your integration. Missing or wrong key → 403. |
Origin | One of Origin, body agentKey, or X-Agent-Key | The origin of the client (e.g. https://yoursite.com). Must be approved for your agent when sent. Your integration provider registers domains you own before attaching them as allowed websites on an agent. Omit when you send agentKey in the JSON body or X-Agent-Key header instead. |
X-Agent-Key | One of Origin, body agentKey, or X-Agent-Key | Agent UUID. Use when Origin is omitted and you prefer a header over body agentKey. Body agentKey wins when both body and header are present. |
Authorization | No | Optional Bearer ID token from single sign-on (see Customer SSO below). When present and valid, the turn uses that user's identity and that person's thread with the agent. When invalid or expired, the request returns 401 — the service does not fall back to API-key-only scope. When omitted, key-only rules apply (below). |
JSON body (/request and /stream)
| Field | Required | Notes |
|---|---|---|
text | Yes | The user's message for this turn. |
agentKey | One of Origin, body agentKey, or X-Agent-Key | The agent's id (UUID). Required when Origin and X-Agent-Key are omitted. May be omitted when Origin is registered for a single agent. |
sessionId | No | Ignored. The server assigns the thread. See Session continuity below. |
context | No | Optional static context for the turn. |
pageContext | No | Optional page context string (narrative from the chat widget). |
delivery | No | sync (default), poll, or webhook. See Async delivery below. |
files | No | Uploaded files to attach to this turn: [{ "fileId": "<uuid>", "libraryId": "<optional>" }]. Organization sessions only, and only with delivery: "sync" on /request. See Attaching files. |
async | No | Deprecated alias: true maps to delivery: "poll". Do not combine with delivery: "webhook". |
webhookUrl | When delivery is webhook | HTTPS callback URL for the signed result POST. |
webhookSecret | No | Optional HMAC secret (≥ 16 characters). If omitted for webhook delivery, the server generates one and returns it once in the 202 body. |
Optional header Idempotency-Key (max 128 characters) on async accept: same key + same API key + same text within 24 hours returns the existing jobId. Same key with different text returns 409.
Session continuity
The server assigns the thread on /request, /stream, and /chat. A sessionId in the request is ignored.
- API key only: one thread for that integration.
- Bearer: one thread for that signed-in person with that agent.
Each successful response includes sessionId in the JSON body (/request) or the SSE done event (/stream and /chat). That value is the id the server assigned.
POST /agent/request
POST https://api.lincolncannon.co/agent/request
Sync successful response (delivery: "sync" or omitted)
JSON 200. On success you should receive at least:
text— the agent's replysessionId— the server-assigned thread id
Exact fields may grow over time; ignore unknown keys.
Prefer sync only for short turns. On the production API domain, a silent buffered response can be cut after about 30 seconds. If sync runs longer than about 25 seconds, the API returns 503 with:
{
"error": {
"code": "USE_ASYNC",
"message": "Sync POST /agent/request exceeded the EDGE-safe time budget. Retry with delivery \"poll\" or \"webhook\", or use POST /agent/stream."
}
}
Retry with async delivery or use POST /agent/stream. Partial tool side effects may already have occurred before that time limit — prefer choosing async up front when the turn may be long.
Async delivery (poll / webhook)
When you need a final JSON result without holding the HTTP connection open (or when the turn may take longer than ~25 seconds), set delivery: "poll" or delivery: "webhook". The accept path returns 202 immediately; work runs in the background for up to about 15 minutes.
202 body includes at least:
jobId— e.g.job-<uuid>status—queueddelivery—pollorwebhookpollUrl— path such as/agent/request/jobs/job-…(prefix withhttps://api.lincolncannon.co)expiresAt— ISO time; results are retained about 24 hourswebhookSecret— only when the server generated it for webhook delivery
Poll with GET https://api.lincolncannon.co/agent/request/jobs/{jobId} using the same x-api-key (and optional Bearer) as POST /request. In-flight statuses: queued, running. Terminal statuses: succeeded, failed. On success, result matches the sync JSON shape (text, sessionId, etc.). Unknown, expired, or unauthorized jobs return 404.
Webhook delivery POSTs a signed JSON body to your webhookUrl with headers X-LCLLC-Timestamp (unix seconds) and X-LCLLC-Signature: sha256=<hex> over timestamp + "." + rawBody. Verify the signature with your webhookSecret. Reject replays older than about 5 minutes. The platform retries failed deliveries a few times with backoff; a delivery failure does not change job status from succeeded — poll and check webhookStatus. There is no cancel API; a queued or running job runs until completion or worker timeout.
At most 10 queued or running async jobs per API key; excess accepts return 429.
Recommendation:
- Prefer
/streamwhen your client can consume SSE. - Use
delivery: "poll"or"webhook"when you need one final JSON object and the turn may exceed ~25 seconds. - Keep sync
/requestfor short turns only.
Examples
Origin-based sync: POST https://api.lincolncannon.co/agent/request with Content-Type: application/json, x-api-key, Origin, and body { "text": "Hello" } (when your origin maps to one agent).
Agent-key in body: same URL and headers except no Origin or X-Agent-Key, body { "agentKey": "<uuid>", "text": "Hello" }.
Agent-key in header: same URL with x-api-key and X-Agent-Key: <uuid>, body { "text": "Hello" }.
Async poll: body { "agentKey": "<uuid>", "text": "Long task…", "delivery": "poll" } → 202 → poll GET /agent/request/jobs/{jobId}.
POST /agent/stream
POST https://api.lincolncannon.co/agent/stream
Same authentication, body fields (except async delivery fields), and session rules as sync /request. Response is Server-Sent Events: token deltas, optional trace lines, and a done event with sessionId and canonical text.
Use /stream when your backend needs streaming; use sync /request for a short single JSON payload; use async /request when you need a final JSON document without a long-lived connection.
Reading the signed-in thread
GET /agent/transcript is for the browser widget (Bearer + allowlisted Origin). Do not send Content-Type. The server chooses the session from that Bearer identity — the same assignment as POST /agent/chat. Do not send a session id; a query sessionId is ignored. Optional query agentKey selects the agent the same way chat does.
The JSON body is messages (the stored thread; tool results are placeholders) and sessionId (the server-assigned id).
API keys are rejected. Key-only /request / /stream integrations do not use this route.
When the caller may upload files, the JSON also includes fileUpload: true. The field is omitted otherwise (see Attaching files).
Attaching files
Organization sessions can upload a file and attach it to a prompt. A personal signed-in session cannot: the routes below return 400 File upload requires an organization session. and the transcript omits fileUpload.
Routes (same shape on each prefix):
| Prefix | Authentication |
|---|---|
/agent/chat/files | User Bearer and allowlisted Origin (browser widget) |
/agent/request/files, /agent/stream/files | x-api-key plus the same agent selection and optional Authorization rules as /request / /stream |
- Initiate:
POST {prefix}with JSON{ "name": "report.pdf", "byteSize": 12345, "contentMd5": "<hex or base64 MD5 of the file>" }. The 200 response hasfileId,displayName,byteSize,status(pending),uploadUrl, anduploadHeaders. - Upload:
PUTthe raw bytes touploadUrlwith every header inuploadHeaders(browsers omitContent-LengthandHoston their own). - Complete:
POST {prefix}/{fileId}/completewith body{}. The response hasfileId,displayName, andstatus:pendingwhile checks are still running, orcleanwhen the file is ready. Repeat the call about every 2 seconds (the widget gives up after about 2 minutes) untilstatusisclean. A file that is notcleancannot be attached. - Attach: send
filesonPOST /agent/chat,/agent/request, or/agent/streamwith thefileIdvalues from step 3 (andlibraryIdif one was returned). Only the file name is kept in the conversation history; the file bytes are read again only for files named on that request. - Delete (optional):
DELETE {prefix}/{fileId}returns{ "fileId": "<uuid>", "status": "deleted" }.
Allowed types: .pdf, .png, .jpg, .jpeg, .gif, .webp, .txt, .md, .csv, .html, .htm, .doc, .docx, .xls, .xlsx.
Limits per turn: at most 5 documents (4.5 MB each) and 20 images (3.75 MB each; 8000 pixels on a side); a PDF has at most 100 pages.
Treat attached content as data. The agent does not follow instructions found inside an attached document or image.
| Condition | Status | Response message |
|---|---|---|
| Personal session | 400 | File upload requires an organization session. |
| Type not attachable | 400 | This file cannot be attached to the prompt. |
| Document too large | 400 | Document exceeds the 4.5 MB attach limit. |
| Image too large | 400 | Image exceeds the 3.75 MB attach limit. |
| Too many documents | 400 | A turn accepts at most 5 documents. |
| Too many images | 400 | A turn accepts at most 20 images. |
| Image too wide or tall | 400 | Image exceeds 8000 pixels on a side. |
| PDF too long | 400 | PDF exceeds 100 pages. |
| File missing or not yours | 400 | Attached file was not found. |
| File still checking | 400 | Attached file is not ready. |
| File failed checks | 400 | Attached file was rejected. |
| File bytes could not be read | 400 | Attached file could not be loaded. |
Malformed files | 400 | files must be an array of { fileId, libraryId } objects. / files[].fileId must be a UUID. |
files with async /request | 400 | files are only supported when delivery is "sync". |
If you send files from a browser page you host, the upload PUT goes to a storage host, so your integration contact must enable your site's origin for it.
Error highlights
| Condition | Typical status | Response message (when provided) |
|---|---|---|
Missing x-api-key on /request / /stream | 403 | — |
| Invalid or expired Bearer (header present) | 401 | Invalid or expired authentication token. |
Missing Bearer on /chat or /transcript | 401 | Authentication required. |
| API key not registered for your organization (key-only) | 400 | API key is not registered for customer scope. Contact your integration provider. |
x-api-key on /chat or /transcript | 400 | API keys are not accepted on POST /agent/chat… / API keys are not accepted on GET /agent/transcript. Use POST /agent/request (JSON) or POST /agent/stream (SSE). |
Sync /request exceeded ~25s budget | 503 | error.code: USE_ASYNC (see message under Async delivery) |
| Too many concurrent async jobs for the API key | 429 | Too many concurrent async request jobs for this API key. |
Idempotency key reused with different text | 409 | Idempotency-Key conflict with a different request body. |
Unknown / expired / unauthorized jobId on poll | 404 | Job not found. |
Customer SSO (Bearer from your IdP)
Use single sign-on when you need per-user memory or user-bound features (such as contacts) on /request / /stream, or when embedding the chat widget for already signed-in users on /chat. Users authenticate on your IdP; your backend obtains Lincoln Cannon LLC ID tokens and sends them as Bearer on agent calls. The server assigns that person's thread. A client sessionId is ignored.
OAuth (authorize, PKCE, token exchange, refresh): SSO Integration Guide.
When to use Bearer vs API key only
| Mode | Headers | Memory / session |
|---|---|---|
| SSO (recommended for signed-in users) | x-api-key + Authorization: Bearer <id_token> | Per-user memory for the token user. The server assigns that person's thread. |
| API key only (incl. backend jobs with no user browser) | x-api-key only | Shared integration scope. A client sessionId is ignored. |
Browser embed (/chat) | Authorization: Bearer <id_token> only + allowlisted Origin | Same per-user thread as SSO on /request. A client sessionId is ignored. |
Obtain tokens when the user opens your agent feature (typical) or during your own login (optional). Day-to-day agent calls use Bearer; refresh the id_token server-side per SSO Integration Guide §4.4.
Calling /request or /stream with SSO
POST https://api.lincolncannon.co/agent/request
Content-Type: application/json
x-api-key: <your-api-key>
Authorization: Bearer <id_token>
X-Agent-Key: <agent-uuid>
{
"text": "Hello"
}
| Header / field | Notes |
|---|---|
x-api-key | Required — same as key-only integrations |
Authorization: Bearer | ID token from SSO Integration Guide §4 |
Origin, X-Agent-Key, or body agentKey | Same rules as Shared headers above |
sessionId | Ignored. The server assigns the thread. |
| Invalid / expired Bearer | 401 — no fallback to API-key-only scope |
Streaming: same headers and body on POST /agent/stream.
Refresh tokens stay on your server — never in browser calls to the agent API.
Optional browser embed (POST /agent/chat)
Use /chat when you embed the Lincoln Cannon LLC cloud chat widget on your site for users who already have a Lincoln Cannon LLC ID token from SSO. Prefer /request / /stream for server backends.
| Header / field | Notes |
|---|---|
Authorization: Bearer <id_token> | Required — same ID token as SSO on /request (SSO Integration Guide §4) |
Origin | Required and must be registered for the agent by your integration provider |
x-api-key | Do not send — present API key → 400 (use /request or /stream on the server instead) |
Body text | Required user message |
Body sessionId | Ignored. The server assigns the caller's thread. |
Body context / pageContext | Optional turn context |
| Response | SSE (streaming), similar idea to /stream, different auth |
Do not put API keys in public HTML. The test page (https://test.lincolncannon.co/agency/) is a trusted-device smoke path that uses /stream + API key; product embeds on customer sites must stay keyless /chat.
Widget branding (ChatWidgetConfig)
Load the production widget script (https://cloud.lincolncannon.co/lib/assistant.min.js) and set window.ChatWidgetConfig before the script runs. Customer sites (including staging hosts whose names contain dev) use the production Agent API and OAuth hosts by default — do not set apiEnvironment to dev on customer embeds.
| Property | Default | Notes |
|---|---|---|
title | Assistant | Display name in the open chat header (and in the launcher bubble unless hidden) |
context | Greeting for new conversations | Initial assistant message |
retext | Greeting for returning conversations | Shown when the user returns |
primaryColor / primaryHoverColor | Blue defaults | Hex brand colors for the launcher and controls |
description | — | Optional about-panel copy. A simple <a href> (https or a same-site path beginning with /) renders as a link; other HTML is shown as text. The about panel always ends with {title} is powered by Lincoln Cannon LLC (link to the Custom AI Assistants page) and a Custom AI Assistants Terms of Use sentence (both links open in a new tab) |
hideBubbleTitle | false | When true, the launcher shows only the icon; the header title is unchanged |
bubblePosition | bottom-right | bottom-right, bottom-left, middle-left, or middle-right |
includePageContext | true | Include page URL/title on the first message for that URL |
identityProvider | — | Hosted UI: identity_provider value from your integration package so authorize lands on your IdP. Pair with cognitoClientId set to the SSO client_id from that same package |
cognitoClientId | Default Hosted UI client from your package | For identityProvider embeds, set to the SSO client_id your integration contact supplies. The widget posts this on POST /user/sign-in-state so token exchange uses the same client. That client must allow https://api.lincolncannon.co/user/callback as a callback URL |
getIdToken | — | Preferred SPA/BFF: async () => ({ idToken, expiresIn? }) (or expiresAt ms). Return { status: "unauthorized" } when the user must log in |
authTokenUrl | — | Cookie (or headered) BFF: GET URL returning JSON idToken / id_token (+ expiresIn / expires_in / expiresAt) |
authTokenHeaders | — | Optional headers for authTokenUrl (e.g. Authorization) |
authTokenCredentials | include | Fetch credentials for authTokenUrl: include, same-origin, or omit |
authLoginUrl | — | BFF: redirect when token fetch is unauthorized (widget appends returnUrl) |
beforeAuthLogin | — | Optional sync/async host veto before authLoginUrl navigate: **`() => boolean |
authLogoutUrl | — | Optional BFF Disconnect navigate (widget appends returnUrl). Shows Disconnect when set |
onDisconnect | — | Optional async/sync hook after local ID token clear on Disconnect. Shows Disconnect when set |
signInOnOpen | false | When true, open may redirect to login / Hosted UI if unsigned; BFF always silently probes on open (see below) |
onIdTokenExpired | — | Legacy refresh hook after inject; prefer getIdToken (used for Connect and refresh) |
Launcher placement: bottom-left mirrors the default bottom-right insets. middle-left / middle-right sit flush on that edge; a labeled bubble rotates 90° (no rotation when hideBubbleTitle is true). While the chat panel is open, the launcher is hidden. The panel docks to the matching bottom corner: bottom positions stay there, and middle positions move there from the side edge.
You may update branding at runtime with ChatWidgetAPI.updateConfig({ … }). Useful API methods: setIdToken, clearIdToken, signIn, signOut, isSignedIn, open, close.
Content Security Policy
If your pages send a Content-Security-Policy header, allow the hosts below. These are the production hosts. When your integration contact gives you non-production hosts, allow https://cloud-dev.lincolncannon.co, https://api-dev.lincolncannon.co, and https://user-dev.lincolncannon.co on the same directives. The directives and hosts listed here are minimum requirements for the widget to work — they are not advice to loosen CSP for unrelated scripts, styles, or origins on your site.
| Directive | Allow | Why |
|---|---|---|
script-src | https://cloud.lincolncannon.co | Widget script (assistant.min.js) and the markdown and HTML sanitizer libraries loaded from that host |
worker-src | https://cloud.lincolncannon.co | Streaming worker (assistant.worker.min.js). If you omit worker-src, it inherits script-src. If you set worker-src, include this host |
connect-src | https://api.lincolncannon.co, https://s3.us-east-1.amazonaws.com, https://*.s3.us-east-1.amazonaws.com, and https://*.s3.amazonaws.com | POST /agent/chat, GET /agent/transcript, chat-file initiate/complete/delete, POST /user/sign-in-state, and POST /user/refresh. Presigned chat-file PUTs go to S3 (path-style or virtual-hosted). Also allow your BFF origin when authTokenUrl or getIdToken calls a host other than the page |
form-action | https://api.lincolncannon.co and https://user.lincolncannon.co | Sign out and Hosted UI Disconnect submit a form to POST https://api.lincolncannon.co/user/logout. That response redirects the browser to https://user.lincolncannon.co/logout. Chrome checks every hop, and the console still names the logout URL when a later hop is blocked. Allow both hosts. form-action 'self' blocks Sign out |
style-src | 'unsafe-inline' | The widget injects a <style> element and sets inline style attributes. A style-src that does not allow inline styles drops the widget layout. If you split style-src-elem and style-src-attr, allow inline styles on both |
Sign in navigates the browser to https://user.lincolncannon.co, then to your identity provider when identityProvider is set. If you set navigate-to, include https://user.lincolncannon.co and your identity provider. BFF authLogoutUrl is also a navigation, so allow that URL on navigate-to when you set the directive.
Assistant replies may include images. img-src must allow those image URLs or the pictures do not load.
Widget SSO modes (Hosted UI vs BFF)
| Knob | Role |
|---|---|
identityProvider | Default no-BFF path — Hosted UI federates to your IdP. Pair with cognitoClientId = the SSO client_id from your integration package |
getIdToken | Preferred SPA / Bearer BFF — your page calls your API with whatever auth it already has |
authTokenUrl (+ optional headers / credentials) | Cookie (or headered) BFF GET — refresh stays on your server |
signInOnOpen | Opt-in redirect on open — when true, opening may send the user to authLoginUrl / Hosted UI if unsigned. BFF embeds always silently try getIdToken / authTokenUrl on open (no redirect unless this is true) |
Precedence: getIdToken → authTokenUrl → identityProvider. Omit all three for open-then–Sign in with the default Hosted UI (social chooser).
Customer SSO chrome (getIdToken, authTokenUrl, and/or identityProvider) uses Connect / Connecting … and Disconnect / Disconnecting …. Default Hosted UI (no those knobs) keeps Sign in / Sign out.
| Setup | Bubble open (signed out) | Auth action | Sign-out in widget |
|---|---|---|---|
identityProvider only | Open panel | Connect → Hosted UI → your IdP | Disconnect → ends the Lincoln Cannon LLC Hosted UI session (same cognitoClientId as authorize) |
identityProvider + signInOnOpen: true | Auto Hosted UI → your IdP | Same (Connect copy) | Same Hosted UI Disconnect |
getIdToken (+ authLoginUrl) | Silent getIdToken (Connecting…); unauthorized → Connect (no redirect) | Connect may redirect to authLoginUrl | Hidden unless you wire onDisconnect / authLogoutUrl (Disconnect) |
getIdToken + signInOnOpen: true | Silent getIdToken; unauthorized → authLoginUrl | Same | Same Disconnect rule |
authTokenUrl only | Silent GET authTokenUrl; 401 → Connect (no redirect) | Connect may redirect to authLoginUrl | Same Disconnect rule |
authTokenUrl + signInOnOpen: true | Silent fetch; 401 → authLoginUrl | Same | Same Disconnect rule |
Silent BFF probe (expected unauthorized): On bubble open with getIdToken / authTokenUrl, the widget always tries a token fetch (no authLoginUrl redirect unless signInOnOpen: true). When the browser has no app/BFF session yet, treat that as normal — not an error:
- Prefer
{ status: "unauthorized" }fromgetIdToken(or HTTP 401 onauthTokenUrl, which the widget maps the same way). - Do not throw or
console.errorfor that case; the UI shows Connect. - Cold page load with the panel closed does not probe. Probe runs when the user opens the chat (and once after return from
authLoginUrl).
After authLoginUrl return: The widget runs one token fetch on remount at returnUrl. Success signs the chat in. If still unauthorized, Connect stays visible and the widget does not redirect to authLoginUrl again. If the script loads before getIdToken / authTokenUrl is set, resume runs once after ChatWidgetAPI.updateConfig supplies a BFF provider.
Before authLoginUrl redirect (beforeAuthLogin): Optional hook before the widget navigates to authLoginUrl (Connect click, or signInOnOpen: true after an unauthorized token fetch). Return true (or omit the hook) to proceed; return false or throw/reject to cancel. Silent open probes that only show Connect do not call the hook.
Embed tips: Clear dirty-form beforeunload blockers before resolving beforeAuthLogin with true. Stack host confirm modals above the widget (root z-index: 9999; while the hook runs the widget lowers to 1200). Always resolve the hook when the dialog closes.
Disconnect: identityProvider Hosted UI always shows header Disconnect and ends the Lincoln Cannon LLC Hosted UI session the widget created (POST /user/logout with the same cognitoClientId as authorize). BFF/inject sessions do not use that Hosted UI logout; wire onDisconnect and/or authLogoutUrl to show Disconnect. BFF flow: clear the local Lincoln Cannon LLC id_token → reset the transcript to the signed-out welcome (Connect prompt) → call onDisconnect (if set) → navigate to authLogoutUrl with returnUrl (if set; widget stays closed on return). Without those knobs on a BFF/inject embed, end the app/BFF session in your product UI and call ChatWidgetAPI.clearIdToken() (same local UI reset; does not invoke onDisconnect).
window.ChatWidgetConfig = {
// …getIdToken / authLoginUrl…
authLogoutUrl: "https://app.example.com/logout", // optional navigate
async onDisconnect() {
// optional: clear your app cookie / revoke BFF session
},
};
// Host-driven clear without Disconnect chrome:
// ChatWidgetAPI.clearIdToken();
SPA + Bearer BFF (recommended when the app already has a JWT):
window.ChatWidgetConfig = {
// …branding…
authLoginUrl: "https://app.example.com/login",
signInOnOpen: false, // silent getIdToken on open; Connect only if login is required
// Optional: veto Connect → authLoginUrl when the host has unsaved work
async beforeAuthLogin() {
return window.confirm("Leave this page to connect? Unsaved changes may be lost.");
},
async getIdToken() {
const res = await fetch("https://app.example.com/api/lcllc/token", {
headers: { Authorization: "Bearer " + appAccessToken },
});
if (res.status === 401) return { status: "unauthorized" }; // expected when unsigned
if (!res.ok) throw new Error("token fetch failed");
return res.json(); // { idToken, expiresIn? } or { idToken, expiresAt } (ms)
},
};
Never put a Lincoln Cannon LLC refresh_token in the page. Prefer getIdToken / authTokenUrl over identityProvider when refresh must stay server-side.
Cookie BFF token URL: same-origin or CORS with credentials (default authTokenCredentials: "include"). Optional authTokenHeaders. Response examples: { "idToken": "…", "expiresIn": 1800 } or { "idToken": "…", "expiresAt": 1735689600000 }. On expiry / Agent 401, the widget calls getIdToken when set; else onIdTokenExpired if set; else re-fetches authTokenUrl.
Manual inject (advanced): idToken / ChatWidgetAPI.setIdToken / onIdTokenExpired — same hide Hosted UI sign-out rule when no refresh token is stored (wire onDisconnect / authLogoutUrl for Disconnect, or call ChatWidgetAPI.clearIdToken()). Prefer the built-in authLoginUrl resume path for Connect → login → return.
Keep the refresh_token on your server/BFF only — never in widget config, page JS, or browser storage. Hosted UI embeds may store refresh in the browser; prefer BFF when you can.
ID token claims used by the agent
Your IdP must supply the claims required in SSO Integration Guide §5. The agent uses:
| Claim | Use |
|---|---|
sub | Per-user memory and conversation ownership |
email, email_verified | User-bound features (e.g. contacts, outbound email) — verified email required where applicable |
name, given_name, family_name, picture | Personalization in agent responses |
SSO error handling
| Situation | Action |
|---|---|
| Agent 401 with Bearer present | Refresh id_token (SSO Integration Guide §4.4); if refresh fails, rerun OAuth (SSO Integration Guide §4.2–4.3) |
| OAuth or first-login failures | Contact your integration contact; do not call the agent without a valid token |
| API key not registered (400) | Contact your integration provider |
Environments
Production Agent API: https://api.lincolncannon.co/agent/
Production OAuth (SSO): https://user.lincolncannon.co
Use matching values from your integration package for API key, OAuth, and callbacks. If your contact provides non-production hosts, use those instead — do not point public customer embeds at development hosts unless they say so.
Agent-to-agent messaging (configured peers)
When your organization configures bidirectional peer relationships between agents, an agent can message another agent during a turn (for example to hand off work). This is not a separate public HTTP endpoint you call directly — it happens inside agent runs that your integration already triggers via /request, /stream, or scheduled runs.
Your integration provider configures peers and enables the relevant tools. Typical capabilities include free-text peer messages and structured handoffs with context and a clear ask.
Cross-organization peers: Agents owned by different organizations may peer when both agents have external peering enabled and both list each other. Either side may offer first; messaging stays blocked until the handshake is mutual. Same-organization peers do not require the external-peering setting. If external peering is later turned off on either agent, cross-organization sends fail closed until both enable it again.
Success response semantics
When a peer send succeeds, the tool result includes at least:
| Field | Meaning |
|---|---|
ok | true when the message is accepted for asynchronous delivery to the peer agent — not when the peer has finished processing or replied |
message_id | Correlation id for the outbound message (use in logs and support tickets) |
session_id | Sender-side session context associated with that handoff |
sent_at | ISO timestamp when the message was accepted |
Treat ok: true as “queued for the peer agent,” not “peer replied.” Your integration provider may enable waiting for a reply in the same turn, or a one-hop auto-reply from the peer, when configured.
Failure responses
When a peer send is denied, ok is false and the result includes a code and human-readable message. Common codes include RATE_LIMITED, INVALID_RECIPIENT, GATE_FAILED, and SEND_FAILED. Exact strings may evolve; treat unknown fields as optional.
Repository-defined agents (manifest sync)
Your integration provider may enable version-controlled agent definitions for your organization: prompts and config live in a repository you own, and a sync step applies them to production. Your contact supplies the apply instructions (tooling and layout).
| Topic | Behavior |
|---|---|
| Enablement | Your Lincoln Cannon LLC integration contact must enable repository agent sync for your organization before sync succeeds |
| API | POST https://api.lincolncannon.co/agent/agency/sync — production only (not a development API host) |
| Auth | Bearer ID token for your organization’s owner account, or for an additional mailbox your integration contact configures. Do not send x-api-key on this route — API keys are for /request / /stream only |
| New agents | Include a new agent UUID in your definition, then sync. Sync creates the agent for your organization when that UUID is not already in use. Sync also creates a curated knowledge source and a curated assets library named after the agent |
| Existing agents | If your organization already owns the agent, first sync claims it in place (no delete). You cannot adopt agents owned by another organization |
| Knowledge sources | Each active definition must include knowledgeSources: an array of { "name": "<source name>" } for every knowledge source that agent may use (usually including the agent’s own name). [] means none. After sync, associations for that agent cannot be changed with the Knowledge PUT APIs — update the definition and sync again |
| Asset libraries | Each active definition must include assetLibraries: an array of { "name": "<library name>" } for every media library that agent may use (usually including the agent’s own name). [] means none. After sync, associations for that agent cannot be changed with the Assets PUT APIs — update the definition and sync again. See Assets API Integration Guide |
| Management UI | Synced agents appear as managed; fields owned by the definition are read-only there. Integrations (OAuth connect), memories, and knowledge sync remain available as your provider configures them |
| Peers | Peer lists may reference other agents you own that are also definition-managed. Cross-organization peers use the peer agent’s UUID and require external peering enabled on both agents; both organizations must list each other before messaging works |
Contact your integration provider for apply tooling and CI patterns. Do not put owner credentials in public HTML.
Support
For API keys, agent ids, allowed origins (domains must be registered to your account before they can be attached to an agent), SSO enablement, or repository agent sync, contact your Lincoln Cannon LLC integration provider. For OAuth token issues, see SSO Integration Guide §9. For first-time SSO IdP onboarding deliverables, see SSO Integration Guide §2.