Twin endpoints sit behind a control-plane proxy. From outside the CLI, you typically need two auth headers — one for the control plane, one the twin sees. Use this guide when you can’t pull inDocumentation Index
Fetch the complete documentation index at: https://docs.archal.ai/llms.txt
Use this file to discover all available pages before exploring further.
@archal/runtime (Lambda, Cloudflare Worker, raw curl, polyglot CI). Normal Node.js scripts should use @archal/runtime — it handles both headers.
The two-header pattern
Authorization— authenticates to the control plane. Token comes fromarchal login(~/.archal/credentials.json) or a long-lived dashboard token. The control plane verifies thesessionIdin the URL belongs to you and the session is live.x-archal-upstream-authorization— what the twin sees asAuthorizationafter the proxy forwards. The proxy strips the originalAuthorization, rewritesx-archal-upstream-authorizationintoAuthorization, and passes the rest through. Twins that enforce bearer-token auth (e.g. github’srequireGitHubBearerToken) check this header.
ghp_test_bootstrap_token.
Omit x-archal-upstream-authorization and the proxy forwards your outer Authorization through to the twin. Current bearer-enforcing twins (github, slack, etc.) accept any non-empty bearer token, so the outer Archal token will usually pass their check — but a future twin could enforce a stricter shape and 401. Always send both headers so behavior stays predictable.
Example (curl)
Given a running twin session:Authorization and the control plane 401s before the request ever reaches the twin. Omit only x-archal-upstream-authorization and the proxy forwards your outer token through — current bearer-enforcing twins accept any non-empty bearer, so you’ll usually get a 200, but a future stricter twin could return a real service-shaped 401 like:
Example (Python urllib)
Example (AWS Lambda / Cloudflare Worker)
Header semantics
Proxy order of operations (seeinfra/api/session/session-worker-proxy.ts — the capture/strip/re-emit lives there; infra/api/routes/session-events.ts just wires the route):
- Validate the outer
Authorization: Bearer <archal-token>against your session. Bad/expired/wrong-user tokens get a 401 or 403 here — the twin never sees them. - Capture
x-archal-upstream-authorizationif present. - Strip sensitive request headers (including
x-archal-upstream-authorization). - Set forwarded
Authorizationto the captured upstream value, or pass through the original outerAuthorizationif no upstream header was supplied. - Forward to the twin.
x-archal-upstream-authorization. Smuggling a real third-party token through the outer Authorization fails at step 1.
See also
- Twin sessions (
archal twin) — how to create, list, and stop twin sessions with the CLI. twins/github/src/auth.ts— reference bearer-token check including thex-archal-upstream-authorizationfallback. Every stateful twin follows the same pattern.infra/api/session/session-worker-proxy.ts— the proxy’s header rewrite code path (proxySessionTwinRequest); the stripped-header list lives ininfra/api/proxy-constants.ts.
