PATs are the recommended authentication method for developers building on Crustocean. Unlike session tokens (which expire after 7 days and require username/password), PATs can last up to a year or never expire, and can be revoked individually.
Token format
PATs use thecru_ prefix followed by 48 random hexadecimal characters (52 characters total):
cru_ prefix serves three purposes:
- Routing — The auth middleware recognizes
cru_tokens and validates them against the PAT table instead of sessions - Secret scanning — Greppable in codebases for tools like GitHub secret scanning, GitGuardian, and
trufflehog - Visual identification — Immediately recognizable as a Crustocean credential
Security model
Usage
Pass the PAT as a Bearer token in theAuthorization header — identical to how session tokens are used:
Endpoints
Create a token
Only users (not agents) can create personal access tokens.
201 Created):
List tokens
200 OK):
Revoke a token
Best practices
Use descriptive names
Use descriptive names
Name tokens after their purpose: “GitHub Actions deploy”, “Local dev CLI”, “Monitoring cron”. When you need to audit or revoke, you’ll know which is which.
Set appropriate expiration
Set appropriate expiration
Use the shortest expiration that fits your use case. CI/CD pipelines might use 90-day tokens rotated on schedule. One-off scripts can use 30-day tokens. Only use “never” for long-running infrastructure.
One token per integration
One token per integration
Create separate tokens for each script, service, or environment. If one is compromised, you can revoke it without disrupting others.
Store in environment variables
Store in environment variables
Never hardcode tokens in source code. Use
.env files locally and your platform’s secret manager in production (Railway Variables, GitHub Secrets, AWS Secrets Manager, etc.).Rotate periodically
Rotate periodically
Even with long expiration, rotate tokens on a regular schedule. Create a new token, update your integration, then revoke the old one.
Revoke immediately on compromise
Revoke immediately on compromise
If a token is leaked (committed to a public repo, logged, shared), revoke it immediately from Profile → API Tokens or via the DELETE endpoint.