---
name: box-cli
description: Use the official Box CLI for Box command-line operations, reproducible shell automation, CLI authentication or troubleshooting, and bulk Box work. Do not use for generic shell questions, Box strategy, or application code that should use a Box SDK.
title: box-cli
canonical_url: https://skilld.dev/gh/box/skills/box-cli
last_updated: 2026-10-15T05:04:44.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install box/skills/box-cli`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/box-cli`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/box/skills/box-cli) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/box-cli`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/box-cli --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/box-cli --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Box CLI

Use the installed Box CLI to complete and verify Box operations.

## Operating workflow

1. Identify the requested outcome, target, and actor. If the request leaves a risky target, recipient, role, impersonated user, or batch scope ambiguous, ask one focused question before running a command.
2. Confirm the intended CLI environment and acting user before the operation. If the user names an environment, inspect `box configure:environments:select --help` and select that environment before checking identity:

   ```bash
   box users:get me --json --fields id,name,login
   ```

   Include the intended `--as-user <USER_ID>` in the identity check when impersonation is authorized. `users:get me` confirms the acting user, not the environment name. Reuse the same environment and actor controls throughout the operation and its verification; repeat the check after any authorized environment or actor change. Never switch to a more privileged identity merely to bypass an error.
3. Resolve human-readable names to stable Box IDs before mutation. If multiple items match, present the candidates and ask the user to choose.
4. Prefer a dedicated CLI command. Add `--json` for machine-readable output and narrow `--fields` to the data needed for the task.
5. Verify mutations with a read using the same actor. For deletes, check the parent collection or trash as appropriate; a `404` alone can also mean the actor lacks access. For asynchronous operations, report pending status until completion is confirmed.
6. Report the actor, action, relevant object IDs, verification evidence, and any unresolved failure. Include commands when they help the user reproduce the result.

## Common patterns

Record `box --version`. Inspect command help when syntax is unfamiliar, the installed version differs from the verified version below, or a command is rejected. Resolve uncertainty before running a write.

```bash
# Identify the actor
box users:get me --json --fields id,name,login

# Inspect the root folder and a bounded set of children
box folders:get 0 --json --fields id,name
box folders:items 0 --json --fields id,type,name --max-items 20

# Search and preserve parent information for disambiguation
box search "Launch Plan" --json --fields id,type,name,parent --limit 20

# Read an item by ID
box files:get <FILE_ID> --json --fields id,name,parent,owned_by
box folders:get <FOLDER_ID> --json --fields id,name,parent,owned_by

# Create, then verify the returned folder ID
box folders:create <PARENT_FOLDER_ID> "Approved Assets" --json
box folders:get <RETURNED_FOLDER_ID> --json --fields id,name,parent
```

Box uses `0` as the root folder ID. A path or item name is not a stable identifier.

Use `box <topic>:<command> --help` to check flags and argument order in the installed version.

## Setup and authentication

Only enter setup mode when the CLI is absent, authentication fails, or the user asks for it.

```bash
npm install --global @box/cli
box login -d
```

- `box login -d` uses the official Box CLI application for interactive content operations.
- In a headless environment, have the user run `box login -d --code` in their own terminal for the official CLI app, or `box login --platform-app --code` for their custom app. `--code` is a boolean flag: the CLI displays an authorization URL, then prompts for the state and authorization code after the user authorizes in an external browser. Enter those values only at the local CLI prompts.
- Use `box login --platform-app` when the user needs a custom OAuth application or scopes beyond the official CLI application.
- For approved server automation with JWT or Client Credentials Grant, use the current `box configure:environments:add --help` flow and protect the configuration file outside source control.
- Developer tokens are for short local tests. Do not embed tokens, client secrets, private keys, or authorization codes in commands, prompts, logs, fixtures, or repository files.

After setup, verify the identity with `box users:get me`; do not print credential stores or raw environment configuration.

## Risky and destructive work

The request must explicitly authorize the exact scope before:

- deleting or permanently deleting content;
- creating, changing, or removing collaborations or shared links;
- impersonating another user;
- changing enterprise users, groups, retention, or governance settings; or
- running a broad batch that can alter many objects.

If that authorization is absent, show the actor, target IDs, proposed role or change, and batch size, then ask for confirmation. Do not rely on CLI prompts because some destructive commands do not prompt.

Run dependent writes serially. Serialize processes sharing an OAuth environment to avoid overlapping token refreshes or environment changes. Verify using returned IDs.

## Bulk operations and recovery

Use CSV or JSON input through `--bulk-file-path` only when the specific command supports that flag. Check the command's help and official bulk examples for supported columns and nested values. Before executing a batch:

1. Validate input columns against the command's arguments and flags. Row values override command-line values, including `as-user`; inspect actor and target overrides before execution.
2. Validate a small representative subset when the operation is reversible and the user has authorized it.
3. Keep a reconciliation record separate from the CLI input, with source-row number or key, intended target ID, actor, and outcome. Do not add tracking columns the command does not support.
4. Capture output and per-row error diagnostics. Bulk execution can continue after row failures and finish without a nonzero exit status; reconcile each row before reporting success.

For partial failures:

- Treat successful rows as committed until verification proves otherwise.
- Retry `429` responses only after the indicated delay.
- Retry timeouts or `5xx` responses only when the operation is idempotent or a read proves the mutation did not occur.
- Do not retry `401`, `403`, or ambiguous writes unchanged. Correct identity, permission, or state first.
- Retry only the verified-safe failed subset, then reconcile every source row against Box.

Never restart an entire partially successful mutation batch merely because some rows failed.

## REST fallback

When no dedicated command exists, prefer `box request` because it reuses the selected CLI identity:

```bash
box request /folders/0/items --query "limit=5" --json
```

Inspect `box request --help` before a write. Use explicit method, body, and query values, then verify the resulting Box object through a read. Raw `curl` with a bearer token is outside the normal workflow and should be used only when the user supplies an approved secure authentication mechanism.

## Current public sources

Use these sources when installed help is insufficient:

- [Box CLI repository and installation](https://github.com/box/boxcli)
- [Box CLI authentication](https://github.com/box/boxcli/blob/main/docs/authentication.md)
- [Box CLI command documentation](https://github.com/box/boxcli/tree/main/docs)
- [Box Developer CLI guides](https://developer.box.com/guides/cli/)

Examples and authentication flags checked on 2026-10-13 against the public Box CLI source and docs at commit `97e4351cb5e4a2077f37090bb5aca0ae2fe7020f` (package version `4.10.1`).
