Authorization header for direct REST calls, the FileRouterClient constructor option for the TypeScript SDK, and the npx @file_router/cli login command for the terminal.
Get an API key
Visit filerouter.dev, sign in, and create an API key from your account dashboard. Keep it secret — treat it the same way you would treat a password.Pass the key in REST requests
Every request to the hosted API must include anAuthorization header with your key as a Bearer token.
401 response:
Use the key in the TypeScript SDK
TheFileRouterClient constructor accepts an apiKey option. If you omit it, the client automatically reads the FILEROUTER_API_KEY environment variable.
- Explicit option
- Environment variable (implicit)
index.ts
FileRouterError with code Auth immediately — before you make any network calls.
Log in with the CLI
The CLI uses a browser-based device authorization flow so you never have to copy-paste a key manually. Runlogin once and the CLI saves your key locally for all future commands.
The device authorization session is closed immediately after the CLI creates your API key. FileRouter does not retain your OAuth token.
API key errors
If you receive a
401, check that the FILEROUTER_API_KEY environment variable is set correctly or that the key you created in the dashboard has not been revoked.