Delegated access in the TypeScript and Python SDKs
The SDK agent helpers for code that acts for one person: credentials, reads and reports, waits, recovery and report downloads. Agent access is off by default.
This guide is for developers whose agent, app or script acts for a Crossblade workspace member. Agent access is off by default and has not been turned on for hosted Crossblade workspaces.
Status
Agent access is off by default. It has not been turned on for hosted Crossblade workspaces, no named agent or app is supported yet, and it has only been tried on local test setups. Crossblade has no web address of its own yet, so this guide writes https://<your Crossblade address>. The SDKs and the local MCP server are shared as source packages; they are not on npm or PyPI yet.
Credentials
| Credential | TypeScript | Python |
|---|---|---|
| Project key, for automation | apiKey | api_key |
| OAuth access token | accessToken, optional refreshAccessToken | access_token, optional refresh_access_token |
| Personal token | personalToken | personal_token |
- Pass exactly one. The option you use decides the credential type; the SDK never guesses from the token.
- The SDK never reads a delegated token from an environment variable. Load it from your own secret store.
- Delegated credentials need an
https:base URL, except onlocalhost,127.0.0.1and[::1].
Example
const ledger = new Crossblade({ baseURL: process.env.CROSSBLADE_BASE_URL, personalToken: loadFromYourSecretStore() });
const companyId = "end_usr_123"; // every call names its company explicitly
const me = await ledger.agent.me({ companyId });
const started = await ledger.agent.reads.start({ companyId, operation: "qbd.customers.list", query: { limit: 25 } });
const waited = await ledger.agent.reads.waitForResult(started.envelope.task!.id, {
companyId, operation: "qbd.customers.list", query: { limit: 25 }, deadlineMs: 60_000,
});
if (waited.status === "pending") {
// Nothing was cancelled. Keep started.envelope.task.id (and started.replayKey) and ask again later.
}
Python has the same helpers in snake_case on Crossblade and AsyncCrossblade, with reads.continue_ for the next page and deadline_seconds for waits.
Helpers
- One helper per route:
me,capabilities.listandcapabilities.describe,companies.list,reads.start,reads.resultandreads.continue,tasks.listandtasks.get,help.search,navigation.resolve,reports.export, andartifacts.retrieveandartifacts.download. - Documents come back as the server sent them. An unknown version or kind throws
INVALID_RESPONSEinstead of looking like success. - A client with a project key gets
DELEGATED_CREDENTIAL_REQUIREDfromclient.agentwithout sending a request.
Waits and recovery
- Each request waits at most 25 seconds.
tasks.waitandreads.waitForResultneed a deadline from 1 second to 15 minutes, and return pending at the deadline. Neither cancels work the server accepted. - Settled is not success:
failed,unknown_outcomeandauthorization_revokedare settled too. reads.startreturns thereplayKeyit used, and its errors carry it too, except a failed token refresh. Keep the key you sent. After a timeout or a lost connection, start again with the samereplayKeyto get the same task.- A single helper call is never retried automatically, except that an OAuth client with a refresh callback refreshes once after a
401and repeats that one request.tasks.waitandreads.waitForResultpoll repeatedly, and on a429they wait forRetry-After(60 seconds if absent) before polling again, or return pending if that passes the deadline.
Report downloads
artifacts.downloadsends the token only to your configured address, refuses redirects, reads at most 16 MiB within 60 seconds, and returns the bytes only when their SHA-256 matches the server's.- It never writes a file. The suggested file name is only information.
Errors
Errors are AgentAPIError, a CrossbladeError, with code, status, requestId, retryable, recoveryAction, retryAfterSeconds, replayKey and taskId where they apply. Tokens never appear in errors.
Still stuck?
Contact [email protected]. Send:
- The
X-Request-Idresponse header, or therequestIdin the error. - The route or tool you called, and roughly when.
- The error
codeand message.
Never send an access token, personal token, API key or setup link. Nobody needs them to help you.