Create a key
Create one key per project so you can rotate or revoke each independently. From the CLI:--json and read .secret:
- Open the Box dashboard.
- Go to API Keys.
- Create a key.
- Copy the secret immediately. The dashboard shows it only once.
Creating, rotating, and revoking keys requires a browser sign-in session:
box login without a key, or the dashboard. A CLI or API client authenticated with an API key can use Box normally but cannot manage keys.BOX_API_KEY in your runtime environment:
--json on login too. It keeps stdout machine-readable and makes failed auth return the standard JSON error line.
List your keys
Listing is the one key operation available on every surface. Secrets are never returned. Each row includes the id, name, prefix, last four characters, 30-day request total, and how many Boxes and Agents that key created that still exist.See usage for one key
box api-key usage <id> prints the same 30-day request total and live resource count. Add --verbose for the Boxes/Agents split and the created resource list. GET /api-keys/{id}/usage is the matching API.
Usage still works after you revoke the key, as long as you still have the id. Revoking stops the secret. It does not delete Boxes or Agents the key created.
Creating, rotating and revoking keys is CLI and dashboard only. There is no public API endpoint for them, so no SDK method either: a credential that could mint more credentials would defeat the point. Use
box api-key create|rotate|revoke after a browser sign-in, or the API Keys tab.Store keys
Use the secret manager for your platform:
Do not put API keys in:
- Dockerfiles
- Images
- Source code
- Shell history
- Public CI logs
Rotate a key
Rotating a key immediately revokes the old secret, preserves the API key id, and shows a new secret once. Use Rotate only when you can update the deployed secret immediately:- Rotate the key:
box api-key rotate <id>(find ids withbox api-key list), or use the dashboard. - Copy the new secret.
- Update
BOX_API_KEYin your platform secret manager. - Redeploy or restart workers that use the key.
- Create a new key.
- Update the platform secret to the new key.
- Redeploy or restart workers.
- Delete the old key after the new deployment is live.
Delete a key
Deleting a key immediately revokes it. Existing CLI configs or running processes using that key will fail the next Box API request with an auth error. Boxes and Agents that key created stay.box api-key usage <id> still shows their totals.
Delete keys that are unused, leaked, or no longer tied to an active deployment with box api-key revoke <id> or from the dashboard API Keys tab.