Skip to content

Authentication

Tusky supports two authentication methods: API keys for programmatic access and Clerk JWTs for browser-based sessions.

API keys are the primary way to authenticate with the Tusky API. They are prefixed with tdp_ for easy identification.

Create keys from the dashboard or via the API:

const key = await tusky.apiKeys.create({
name: 'CI/CD Pipeline',
scopes: ['files:write'],
expiresInDays: 90,
});
// Save this — the full key is only shown once
console.log(key.key); // "tdp_abc123..."

Pass the key in the Authorization header:

Terminal window
Authorization: Bearer tdp_your_key_here
PropertyDescription
PrefixAll keys start with tdp_
StorageServer stores only SHA-256(key)
ExpiryOptional — keys can have an expiration date
ScopesOptional — restrict what the key can do
RevocationImmediate — sets revoked_at timestamp

Browser-based clients authenticate via Clerk JWTs. The JWT is passed in the same Authorization header:

Terminal window
Authorization: Bearer eyJhbGciOiJS...

This method is used by the Tusky web app and is not typically needed for API integrations.

When running locally with TUSKY_ENV=development, the API accepts simplified auth:

HeaderDescription
X-Dev-User-IdAuthenticate as a specific user by database ID
X-Dev-Clerk-IdAuthenticate as a specific user by Clerk ID
(no header)Falls back to the first user in the database

Authentication failures return a 401 status:

{
"error": "Unauthorized"
}

Using a revoked or expired key also returns 401.