win.sh API reference
Browser-approved API tokens, local CLI authentication, and hosted connector snapshots for the open-source loop harness.
npm install -g @win.sh/win
win auth login
win snapshot fetch bug-autofix- Base URL
https://win.sh- API prefix
/v1- Token prefix
win_live_- Format
application/json
Core concepts
Small API, stable local contract
The public API exists to connect local loop harnesses to hosted win.sh. The hosted app stores connector credentials, creates scoped tokens, and returns business snapshots that local agents can safely use during a run.
/v1.Settings endpoints use /api/settings because they require a signed-in browser session.
Authentication
Use bearer tokens for machine requests
API tokens are shown once at creation time. win.sh stores token hashes, tracks usage metadata, and rejects expired or revoked tokens.
AuthorizationHeaderSend Bearer win_live_... with every machine request.
snapshots:readScopeRequired for hosted connector snapshot reads.
loops:read / loops:runReserved scopesStored for local harness contracts. Hosted write endpoints are not public yet.
Browser approval
Connect the terminal without pasting tokens
The CLI starts a localhost callback, opens the approval page, and waits for a browser redirect. The CLI must verify the returned state before storing the token.
/settings/api-tokens/cliOpen a signed-in browser approval flow for a local CLI token.
clientstringHuman-readable client name, usually win-loops.
redirect_uriURLLocal HTTP callback on 127.0.0.1, localhost, or ::1.
statestringRandom value generated by the CLI and checked after redirect.
Token management
Create, list, and revoke API tokens
Token management endpoints require a signed-in browser session. API bearer tokens cannot create, list, or revoke other API tokens.
/api/settings/api-tokensList the current user's tokens. Revoked tokens are included for auditability.
/api/settings/api-tokensCreate a scoped token. The raw token is returned once in the response body.
/api/settings/api-tokens/{id}Revoke a token owned by the current user.
namestringDisplay name shown in Settings.
scopesstring[]Allowed values include loops:read, loops:run, and snapshots:read.
expiresInDaysnumberDefaults to 90 and is bounded from 1 to 365 days.
Connector snapshots
Fetch hosted business signals before a local run
Local loops can request a hosted connector snapshot before handing work to Codex, Claude Code, or another runtime. This endpoint requires an API token with snapshots:read.
/v1/loops/{loop}/connector-snapshotReturn the latest connector snapshot available for a loop and workspace.
loopPath parameterLoop id such as bug-autofix, seo-growth, or feedback-to-fix.
AuthorizationHeaderBearer token with snapshots:read.
Errors
Standard HTTP status codes
Errors use standard HTTP status codes and a compact JSON response. Treat 401 as an auth refresh problem and 403 as a scope or permission problem.
Missing, invalid, expired, or revoked authentication.
The current auth method or token scope cannot access the endpoint.
The requested resource does not exist or does not belong to the user.
Security
Token handling rules
- Only token hashes are stored server-side.
- Raw token values are shown once and cannot be retrieved later.
- Token management requires a signed-in browser session.
- The CLI approval route only accepts local HTTP callbacks.
- Local CLIs must verify the returned OAuth-style
state. - Use short-lived, scoped tokens for local harnesses and CI.