API Token Authentication
API tokens are the recommended method for programmatic access to the Zipline API. Tokens are user-specific and can be found in your user dashboard.Getting Your Token
- Log in to your Zipline instance
- Navigate to your user settings or dashboard
- Copy your API token
Using Your Token
Include your token in theAuthorization header of every API request:
Token Format
Tokens are encrypted using the server’s secret key. The token structure is:- Encrypted with AES-256-GCM
- Contains a timestamp and the actual token
- Validated on each request
Session-Based Authentication
Session authentication is used for web browser access and is managed automatically by the Zipline web interface.How Sessions Work
- User logs in via
/api/auth/login - Server creates an encrypted session cookie
- Session is stored in the database
- Cookie is sent with each subsequent request
Session Configuration
From the source code (src/server/session.ts:9-17):- Cookie Name:
zipline_session - Duration: 14 days
- Storage: Encrypted using iron-session
- Security: httpOnly, sameSite protection
Session Data Structure
Login Flow
Standard Login
Two-Factor Authentication (TOTP)
If TOTP is enabled for the user, the initial login returns:OAuth Authentication
Zipline supports OAuth authentication with multiple providers:- Discord:
/api/auth/oauth/discord - GitHub:
/api/auth/oauth/github - Google:
/api/auth/oauth/google - OpenID Connect:
/api/auth/oauth/oidc
OAuth Flow
- Redirect user to OAuth provider’s authorization URL
- User authorizes the application
- Provider redirects back to Zipline with authorization code
- Zipline exchanges code for access token
- Session is created for the user
Anonymous Uploads
Zipline supports anonymous uploads to public folders when configured:X-Zipline-Folderheader is present- Uploading to
/api/uploador/api/upload/partial - No authorization header or session cookie is provided
- The folder allows uploads from anonymous users
Authentication Middleware
The authentication middleware checks for credentials in this order:- Authorization header - API token
- Session cookie - Existing session
- Anonymous upload - If folder-based upload
Security Best Practices
Use HTTPS in production
Use HTTPS in production
Always use HTTPS for your Zipline instance to prevent token interception. Configure
ZIPLINE_CORE_RETURN_HTTPS_URLS=true in your environment.Rotate tokens periodically
Rotate tokens periodically
Regenerate your API token if you suspect it has been compromised. Update all applications using the old token.
Store tokens securely
Store tokens securely
Use environment variables or secure secret management systems to store tokens. Never hardcode them in your source code.
Use token-based auth for automation
Use token-based auth for automation
For scripts, CI/CD, and automation, always use API tokens instead of sessions. Sessions are designed for browser-based access.
Enable rate limiting
Enable rate limiting
Configure rate limiting in your Zipline instance to protect against brute force attacks and abuse.
Error Responses
Authentication failures return specific error codes:| Status Code | Error | Description |
|---|---|---|
| 401 | no token | No Authorization header provided |
| 401 | could not decrypt token | Invalid or corrupted token |
| 401 | invalid token | Token format is invalid |
| 401 | invalid authorization token | Token does not match any user |
| 401 | not logged in | No valid session found |
| 401 | invalid login session | Session is invalid or expired |
| 403 | forbidden | Access denied (insufficient permissions) |
Next Steps
Upload Files
Learn how to upload files with your token
Rate Limits
Understand API rate limiting