Skip to main content

Documentation Index

Fetch the complete documentation index at: https://s2.dev/docs/llms.txt

Use this file to discover all available pages before exploring further.

Access tokens control what a client can do. Each token has a scope that restricts which basins and streams it can access, and what operations it can perform. See the access tokens guide for the full specification, including operation groups, granular permissions, and auto-prefixing for multi-tenant setups.
// List tokens (returns metadata, not the secret)
const tokens = await client.accessTokens.list();

// Issue a token scoped to streams under "users/1234/"
const { accessToken: issuedToken } = await client.accessTokens.issue({
	id: "user-1234-rw-token",
	scope: {
		basins: { prefix: "" }, // all basins
		streams: { prefix: "users/1234/" },
		opGroups: { stream: { read: true, write: true } },
	},
	expiresAt: new Date("2027-01-01"),
});

// Revoke a token
await client.accessTokens.revoke({ id: "user-1234-rw-token" });