If you’re building an application where users log in with their Wassist credentials, you can obtain tokens programmatically through the authentication flow.
For applications where authentication state changes:
Copy
const client = createWassistClient({ baseUrl: 'https://api.wassist.app/api/v1/',});// When user logs inclient.setAuthToken(userToken);// Make authenticated requestsconst agents = await client.agents.list();// When user logs outclient.clearAuthToken();
Server-side: Use environment variables or a secrets manager.
Copy
# .env (never commit this file)WASSIST_TOKEN=your-secret-token
Client-side: Store in memory or secure storage, never in localStorage for sensitive applications.
Token Rotation
Periodically rotate your API keys:
Create a new API key
Update your application to use the new key
Verify everything works
Revoke the old key
Least Privilege
Create separate API keys for different purposes:
Production key (restricted access)
Development key (full access, test data only)
CI/CD key (limited to deployment tasks)
Never Expose Client-Side
API tokens should never be in browser-accessible code:Bad:
Copy
// This exposes your token to anyone viewing sourceconst client = createWassistClient({ baseUrl: 'https://api.wassist.app/api/v1/', authToken: 'sk_live_abc123', // DON'T DO THIS});
Good:
Copy
// Proxy requests through your backendconst response = await fetch('/api/wassist/agents');