> ## Documentation Index
> Fetch the complete documentation index at: https://dodopayments-mintlify-external-integration-datafast-autosen.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Command-line interface for interacting with the Dodo Payments API from your terminal

## Installation

### Go Install

```bash theme={null}
go install github.com/dodopayments/dodopayments-cli/cmd/dodopayments@latest
```

### From Source

```bash theme={null}
git clone https://github.com/dodopayments/dodopayments-cli.git
cd dodopayments-cli
go install ./cmd/dodopayments
```

## Quick Start

Set your API key:

```bash theme={null}
export DODO_PAYMENTS_API_KEY=your_api_key_here
```

Basic command structure:

```bash theme={null}
dodopayments [resource] [command] [flags]
```

Create a checkout session:

```bash theme={null}
dodopayments checkout-sessions create \
  --product-cart.product_id prod_123 \
  --product-cart.quantity 1 \
  --return-url https://yourdomain.com/return
```

## Global Flags

| Flag              | Description                                                |
| ----------------- | ---------------------------------------------------------- |
| `--format`        | Output format: `auto`, `json`, `yaml`, `pretty`, `explore` |
| `--transform`     | Filter response using gjson syntax                         |
| `--debug`         | Enable verbose logging                                     |
| `--version`, `-v` | Display CLI version                                        |

## Common Commands

### Payments

```bash theme={null}
# List payments
dodopayments payments list --limit 20 --format json

# Retrieve payment
dodopayments payments retrieve pay_123

# Get line items
dodopayments payments line-items pay_123
```

### Customers

```bash theme={null}
# Create customer
dodopayments customers create \
  --email customer@example.com \
  --name "John Doe"

# List customers
dodopayments customers list

# Update customer
dodopayments customers update cus_123 --name "Jane Doe"
```

### Subscriptions

```bash theme={null}
# Create subscription
dodopayments subscriptions create \
  --customer-id cus_123 \
  --product-id prod_456

# List subscriptions
dodopayments subscriptions list

# Get usage history
dodopayments subscriptions usage-history sub_123
```

### Products

```bash theme={null}
# Create product
dodopayments products create \
  --name "Premium Plan" \
  --price.amount 2999 \
  --price.currency USD

# List products
dodopayments products list
```

## Usage-Based Billing

### Ingest Events

```bash theme={null}
dodopayments usage-events ingest \
  --events.event_id api_call_12345 \
  --events.customer_id cus_abc123 \
  --events.event_name api_request \
  --events.timestamp 2024-01-15T10:30:00Z \
  --events.metadata.endpoint /api/v1/users
```

### Manage Meters

```bash theme={null}
# Create meter
dodopayments meters create \
  --name "API Requests" \
  --event-name api_request \
  --aggregation count

# List meters
dodopayments meters list
```

## Output Formats

### JSON (for scripting)

```bash theme={null}
dodopayments payments list --format json | jq '.data[] | {id, amount}'
```

### Pretty (for reading)

```bash theme={null}
dodopayments payments retrieve pay_123 --format pretty
```

### Interactive Explore

```bash theme={null}
dodopayments payments list --format explore
```

### Transform with gjson

```bash theme={null}
# Extract all payment IDs
dodopayments payments list --transform "data.#.id"

# Filter and extract
dodopayments payments list --transform "data.#(amount>5000)#.id"
```

<Tip>
  Use `--format json` with `jq` for powerful data processing in shell scripts.
</Tip>

## Scripting Example

```bash theme={null}
#!/bin/bash

# Export all payments to CSV
dodopayments payments list --format json | \
  jq -r '.data[] | [.id, .amount, .currency, .status] | @csv' > payments.csv

# Create customers from file
while IFS=',' read -r email name; do
  dodopayments customers create \
    --email "$email" \
    --name "$name" \
    --format json
done < customers.csv
```

## Shell Completion

Enable auto-completion:

```bash theme={null}
# Bash
eval "$(dodopayments completion bash)"

# Zsh
eval "$(dodopayments completion zsh)"

# Fish
dodopayments completion fish | source
```

## Available Resources

The CLI provides commands for 24 resource categories:

* `checkout-sessions` - Checkout session management
* `payments` - Payment operations
* `subscriptions` - Recurring billing
* `customers` - Customer accounts
* `products` - Product catalog
* `licenses` - Software licensing
* `refunds` - Payment refunds
* `disputes` - Payment disputes
* `webhooks` - Event webhooks
* `meters` - Usage meters
* `usage-events` - Usage tracking
* `discounts` - Discount codes
* `payouts` - Seller payouts
* `brands` - Multi-brand management
* Plus 10 additional resources

<Info>
  Use `dodopayments --help` to see all available resources and `dodopayments [resource] --help` for resource-specific commands.
</Info>

## Resources

<CardGroup cols={2}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/dodopayments/dodopayments-cli">
    View source code and releases
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/introduction">
    Complete API documentation
  </Card>
</CardGroup>

## Support

Need help with the CLI?

* **Discord**: Join our [community server](https://discord.gg/bYqAp4ayYh)
* **Email**: Contact us at [support@dodopayments.com](mailto:support@dodopayments.com)
* **GitHub**: Open an issue on the [repository](https://github.com/dodopayments/dodopayments-cli)
