Skip to content

Authentication

The SDK authenticates using bearer tokens. No OAuth, no API keys — just a token string.

import { Client } from "@githosted/sdk";
// Pass a token directly
const client = new Client({ token: "gw_your_token" });
// Or set GITHOSTED_TOKEN in your environment (Node.js only)
// export GITHOSTED_TOKEN=gw_your_token
const client = new Client();
PrefixTypeScopeUse case
gw_WorkspaceAll repos in workspaceApps, agents, admin tools
gr_RepoSpecific repos onlyCI jobs, sandboxes, least-privilege

Both token types work in the same Client constructor. The SDK auto-detects the type from the prefix.

The SDK resolves credentials in this order (first match wins):

  1. Explicit: new Client({ token: "gw_xxx" })
  2. Environment: GITHOSTED_TOKEN env var (Node.js only)

In the browser, always pass the token explicitly — there is no env var fallback.

const client = new Client({
token: "gw_xxx",
baseUrl: "https://api.githosted.dev", // optional, this is the default
});

For local development or self-hosted instances:

const client = new Client({
token: "gw_xxx",
baseUrl: "http://localhost:8080",
});