w6w docs

Python reference

Everything the w6w package exports for application code. Import from w6w, except EmbedSessionClient and exchange_token, which live in w6w.server. For a walkthrough, start with the Python page.

Client(...)

ArgumentTypeDefaultWhat it does
base_urlstrW6W_BASE_URLYour API origin, such as https://<your-host>. Must be an absolute http or https URL. A path is kept as given.
tokenstr or a callableW6W_TOKENA token, or a synchronous callable called before every authenticated request, as token() or token(force_refresh=True). Its result is not cached or shared by the client; cache inside your callable.
projectstryour account’s defaultDefault project for documents.*, workflows.list, workflows.create and workflows.update.
refresh_on_unauthorizedboolFalseOn a 401 unauthorized, call the token callable with force_refresh=True and retry once.
on_unauthorizedcallableNoneCalled with the final 401 ApiError, at most once per call.
headersmappingNoneHeaders sent with every request. Can’t override Authorization.
transportcallableurllib.request.urlopenTakes a urllib.request.Request and returns a response. Use it to set a timeout or a proxy.

Client() raises ConfigError if there’s no usable base URL. A missing token is reported on the first call instead.

Client methods

MethodReturnsNotes
me()Metenant, subject, account, role, and versions, which always holds "wrapper" (the client’s version).
run(urn, action=None, payload=None)dictRuns a conn_… action, fn_… Function, ep_… Endpoint or wf_… Workflow. A workflow is queued, not awaited.
request(method, path, query=None, body=None, headers=None)HttpResponse(status, body)Calls any route with the client’s base URL and token.

run results

CheckkindKeys
w6w.is_action_run(r)"action"output (the action’s return value; value holds the same)
w6w.is_function_run(r)"function"output
w6w.is_workflow_run(r)"workflow"runId, status ("queued")

Every result also carries invocationId, startedAt, finishedAt and durationMs when the server records them. Read them with .get().

client.connections

MethodReturns
list()list[ConnectionSummary]: id, appId, displayName, state, lastTestOk, lastTestedAt, tenant, subject, app (inline app name, icons and brand colours; null or absent when unknown), and built_in
get(id)ConnectionSummary. 404 unknown_connection for another account’s id and for a zerocred: built-in row.
delete(id)None. Same ownership rule (another account’s id is 404); not idempotent. The server removes the connection’s trigger subscriptions first.

built_in is True for the synthetic zero-credential row (a zerocred: id, usable with no connection step, not stored, not deletable) and None otherwise, including against an older server. Creating, updating, testing and OAuth-connecting a connection are not in the Python client.

client.workflows

MethodReturnsNotes
list(project=None)list[WorkflowSummary]id, key, name, displayName, status, tags, runCount, updatedAt
run(id, wait=False, variables=None, trigger=None, input=None, allow_unpublished=False)WorkflowRunResultrunId, status, terminal, output, error, stepErrors, steps, httpStatus. id may be the workflow’s key. allow_unpublished=True runs the stored draft (save first; a disabled workflow is still refused) and is sent in the body only when True.
run_version(id, n, wait=False, variables=None, trigger=None, input=None)WorkflowRunResultRuns published version n instead of the live row. No allow_unpublished.
list_versions(id)dictenabled, currentPublishedVersion (None before the first publish), versions (metadata only).
get_version(id, n)dictversionNumber, createdAt, createdBy, isCurrentPublished, definition.
publish(id)dictversion, currentPublishedVersion. Snapshots the stored row, so save first.
revert(id, n)dictkind, callableId, versionNumber. Rewrites the live row; does not publish. A following update with if_unmodified_since needs the fresh updatedAt.
enable(id) / disable(id)NoneA disabled workflow refuses every run, version and draft runs included.
cancel(id)dictid, status (the status at that moment), cancelRequestedAt. id is the run id.
get(id)WorkflowDetailworkflow (the definition), sourceRef, updatedAt
create(definition, project=None)WorkflowSaveResultid, name, scheduled, updatedAt. Assigns a wf_… id if the definition has none.
update(id, definition, project=None, if_unmodified_since=None)WorkflowSaveResultReplaces the whole definition. 409 workflow_stale if if_unmodified_since doesn’t match.
archive(id)dictRequired before delete.
delete(id)None409 workflow_not_archived if it’s still active.

client.functions

MethodReturnsNotes
run(name, payload=None, allow_unpublished=False)the Function’s outputname is the key or fn_… id. allow_unpublished=True runs the stored draft (body field, only when True).
run_version(id, n, payload=None)the Function’s outputRuns published version n (wire verb invoke). No allow_unpublished.
list_versions(id), get_version(id, n), publish(id), revert(id, n), enable(id), disable(id)as on client.workflowsSame shapes; Functions have no concurrency precondition.
archive(id)dictRequired before delete. Idempotent; one-way.
list()list[FunctionSummary]id, key, displayName, description, updatedAt, valid
get(id)FunctionDetailfunction (the definition), valid
create(definition)SaveResultid, key. Assigns a fn_… id if the definition has none.
update(id, definition)SaveResultReplaces the whole definition.
delete(id)None409 function_not_archived unless the Function was archived first (archive(id)).

client.apps

MethodReturnsNotes
by_ids(ids)list[dict]Catalog summaries for the given app ids. Duplicates collapse; [] returns [] with no request; the client sends chunks of at most 100 ids (sequentially). Unknown ids are absent. Prefer the inline app on a connection when you have one. Raises ConfigError (no request) for a bare string such as "abc"; pass a list.

client.dashboard

MethodReturnsNotes
stats(from_=None, to=None, bucket=None)dictrange, headline, series, recent. Account-scoped: no project is sent. bucket is "day" or "week". Each argument is sent only when given.

client.projects

MethodReturnsNotes
list()list[dict]Active projects, each with isDefault. Read-only. The GET creates the account’s default project if there is none.

client.reliability

MethodReturnsNotes
list(project, app_ids, days=None, limit=None)dictThe reliability board. The server accepts 1 to 10 ids; anything else is 400 invalid_app_filter, raised as ApiError unchanged. No batching helper: splitting and polling are yours.
members(project, days=None)dictappIds: the ids to feed, at most 10 at a time, to list. No status probes.

client.endpoints

MethodReturnsNotes
run(name, payload=None)dictSame shape as client.run(). name is the key or ep_… id.

client.documents

Every method takes an optional project=.

MethodReturns
list()list[Doc]
get(id)Doc: id, key, content, format, description, createdAt, updatedAt
get_by_key(key)Doc
create(key, content, format=None, description=None)Doc
update(id, content=…, format=…, description=…)Doc. Only the arguments you pass are changed.
delete(id)None

client.vars

MethodReturns
list()list[Var]
get(id)Var: id, name, type, value, description, createdAt, updatedAt
get_by_name(name)Var
create(name, type, value, description=None)Var
update(id, type=…, value=…, description=…)Var. Only the arguments you pass are changed.
delete(id)None

client.team

Reading works for any member. The rest need the owner or admin role.

MethodReturns
members()list[TeamMember]: user_id, email, display_name, role, created_at
invite(email=None, role=None)TeamInviteWithLink, including token and redemption_link. Leave out email for an open link.
invites()list[TeamInvite]
revoke_invite(id)None
set_role(user_id, role)TeamMember. role is "member" or "admin".
remove_member(user_id)None

w6w.server.EmbedSessionClient(...)

For backends only. The recommended way to mint a short-lived, account-scoped session for one user: from w6w.server import EmbedSessionClient. Walkthrough: Embed w6w in your product.

ArgumentWhat it is
base_urlYour API origin. Required; no W6W_BASE_URL fallback. Use the final https origin. exchange_token and EmbedSessionClient refuse redirects by default: a 3xx raises ApiError and the Basic client credential is never re-sent. An injected transport is used as given.
client_id, client_secretYour tenant’s credentials. Keep the secret on your backend.
transportOptional. Defaults to a transport that never follows redirects (unlike Client); your own transport decides.
nowOptional clock returning epoch seconds. Defaults to time.time.

create(subject, account_ref) makes one exchange. Both arguments are required and non-blank (ConfigError otherwise, no request sent). subject is sent as given; account_ref is trimmed. It returns a dict with exactly token, expiresIn (seconds), expiresAt (ISO-8601 UTC), subject, tenant, account (the resolved acct_ id) and accountRef.

w6w.server.exchange_token(...)

For backends only. The lower-level call, with an optional account. Trades your tenant’s client credentials for a short-lived token for one user.

ArgumentWhat it is
base_urlYour API origin.
client_id, client_secretYour tenant’s credentials. Keep the secret on your backend.
subjectYour user’s id.
accountOptional. The w6w account the user works in, from your own records.
transportOptional. Defaults to a transport that never follows redirects (unlike Client); your own transport decides.

Returns a dict with token, expiresIn (seconds) and user.

Errors

ClassAttributesRaised when
w6w.ConfigErrormessageThe base URL or token is missing or malformed. No request was sent.
w6w.ApiErrorstatus, code, message, rawA request failed. status is 0 for network_error.

Helpers

ExportWhat it does
w6w.path("/documents/by-key/{key}", key=k)Builds a request path, percent-encoding each value.
w6w.is_terminal_run_status(status)True for succeeded, failed and canceled.
w6w.__version__The installed version.

Where to next