Skip to content

Authentication

KUKAN API supports two authentication methods.

Browser access uses Better Auth session cookies (prefixed with __Secure- over HTTPS). After login, they are sent automatically with fetch.

const res = await fetch('/api/v1/users/me', {
credentials: 'include',
})

Use API tokens for programmatic access.

Create tokens from the dashboard API tokens page, or via the API:

Terminal window
curl -X POST https://your-kukan-site/api/v1/api-tokens \
-H "Content-Type: application/json" \
-H "Cookie: <session-cookie>" \
-d '{"name":"my-script","expiresInDays":90}'

Response:

{
"id": "tok_...",
"token": "kukan_xxxxxxxx...",
"name": "my-script",
"expiresAt": "2026-07-13T00:00:00.000Z"
}

Send the token in the Authorization: Bearer header.

Terminal window
curl https://your-kukan-site/api/v1/users/me \
-H "Authorization: Bearer kukan_xxxxxxxx..."
Terminal window
# List
curl https://your-kukan-site/api/v1/api-tokens \
-H "Authorization: Bearer <token>"
# Revoke
curl -X DELETE https://your-kukan-site/api/v1/api-tokens/tok_... \
-H "Authorization: Bearer <token>"
LevelDescription
Public (no auth)Search, view public datasets
AuthenticatedOwn profile, private datasets in member orgs
Organization member / editor / adminCreate, edit, manage organization data
Category member / editor / adminAdd, manage datasets in categories
System administrator (sysadmin)Manage all users, organizations, jobs
HTTPMeaning
401Not authenticated (login or token required)
403Insufficient permissions
404Resource not found
409Conflict (e.g., duplicate resource)
422Validation error