> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moderationapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Content moderation with the CLI

> Learn how to moderate content from your terminal, scripts and CI with the Moderation API CLI

***

<Snippet file="prerequisites.mdx" />

***

## 1. Install the CLI

```bash macOS / Linux theme={"theme":"nord"}
curl -fsSL https://raw.githubusercontent.com/moderation-api/cli/main/scripts/install.sh | bash
```

```powershell Windows theme={"theme":"nord"}
iwr -useb https://raw.githubusercontent.com/moderation-api/cli/main/scripts/install.ps1 | iex
```

```bash Go theme={"theme":"nord"}
go install github.com/moderation-api/cli/cmd/modapi@latest
```

> [!NOTE]
>
> You can also download a binary for your platform from the [releases page](https://github.com/moderation-api/cli/releases).

## 2. Set your API key

Grab the API key from your [project](https://dash.moderationapi.com) and set it in the `MODAPI_SECRET_KEY` environment variable:

```bash theme={"theme":"nord"}
export MODAPI_SECRET_KEY="your-project-key"
```

> [!TIP]
>
> On your own computer, you can run `modapi configure` instead. It stores the key in your operating system's keychain.

## 3. Submit content

Use `modapi content submit` to moderate text, images, video, audio, or objects with several fields. Only `--content` is required.

```bash Text moderation theme={"theme":"nord"}
modapi content submit \
  --content '{"type":"text","text":"Hello world!"}' \
  --content-id message-123 \
  --author-id user-123 \
  --conversation-id room-456 \
  --metadata '{"customField":"value"}'
```

```bash Image moderation theme={"theme":"nord"}
modapi content submit \
  --content '{"type":"image","url":"https://example.com/image.jpg"}' \
  --content-id image-456 \
  --author-id user-123
```

```bash Object moderation theme={"theme":"nord"}
modapi content submit \
  --content '{"type":"object","data":{"title":{"type":"text","text":"Post title"},"body":{"type":"text","text":"Post content"},"thumbnail":{"type":"image","url":"https://example.com/thumb.jpg"}}}' \
  --content-id post-789 \
  --author-id user-123
```

## 4. Use the result

Use `--jq` to read one field of the result. For example, get the recommended action (`allow`, `review` or `reject`). Add `--raw-output` to print the value as plain text:

```bash theme={"theme":"nord"}
action=$(modapi content submit \
  --content '{"type":"text","text":"Hello world!"}' \
  --jq '.recommendation.action' --raw-output)

if [ "$action" = "reject" ]; then
  echo "Content rejected"
fi
```

For the full result as JSON, use `--output-format json`.

## 5. Preview a request

Add `--dry-run` to any command to see the request it would send. The CLI does not send the request, so it does not use your quota:

```bash theme={"theme":"nord"}
modapi content submit --content '{"type":"text","text":"Hello world!"}' --dry-run
```

## 6. Explore other commands

The CLI has a command for each API endpoint. Some examples:

```bash theme={"theme":"nord"}
# List authors
modapi authors list

# Get every page of moderation actions as JSON, one item per line
modapi actions list --all --output-format json

# Get the webhook signing secret
modapi webhook-secret retrieve

# Show all commands, or the flags of one command
modapi --help
modapi content submit --help
```

If a command fails, it exits with a code that is not `0`: `1` for API errors, `2` for usage errors and `3` for authentication errors.

### Organization key

Commands for projects and channels (`modapi projects` and `modapi channels`) use the [management API](/api-reference/management-api) and need an organization key. To run them while `MODAPI_SECRET_KEY` holds your project key, pass the organization key with `--secret-key`:

```bash theme={"theme":"nord"}
modapi projects list --secret-key "$MODAPI_ORGANIZATION_KEY"
```

An organization key can also run the other commands for a project: name it with `--project-id`.

```bash theme={"theme":"nord"}
modapi authors list --secret-key "$MODAPI_ORGANIZATION_KEY" --project-id "$PROJECT_ID"
```

***

<Snippet file="dry-run.mdx" />

***

<Snippet file="review-flagged.mdx" />

***

<Snippet file="all-done.mdx" />
