Skip to main content

Installation

Go Install

go install github.com/dodopayments/dodopayments-cli/cmd/dodopayments@latest

From Source

git clone https://github.com/dodopayments/dodopayments-cli.git
cd dodopayments-cli
go install ./cmd/dodopayments

Quick Start

Set your API key:
export DODO_PAYMENTS_API_KEY=your_api_key_here
Basic command structure:
dodopayments [resource] [command] [flags]
Create a checkout session:
dodopayments checkout-sessions create \
  --product-cart.product_id prod_123 \
  --product-cart.quantity 1 \
  --return-url https://yourdomain.com/return

Global Flags

FlagDescription
--formatOutput format: auto, json, yaml, pretty, explore
--transformFilter response using gjson syntax
--debugEnable verbose logging
--version, -vDisplay CLI version

Common Commands

Payments

# 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

# 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

# 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

# Create product
dodopayments products create \
  --name "Premium Plan" \
  --price.amount 2999 \
  --price.currency USD

# List products
dodopayments products list

Usage-Based Billing

Ingest Events

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

# Create meter
dodopayments meters create \
  --name "API Requests" \
  --event-name api_request \
  --aggregation count

# List meters
dodopayments meters list

Output Formats

JSON (for scripting)

dodopayments payments list --format json | jq '.data[] | {id, amount}'

Pretty (for reading)

dodopayments payments retrieve pay_123 --format pretty

Interactive Explore

dodopayments payments list --format explore

Transform with gjson

# Extract all payment IDs
dodopayments payments list --transform "data.#.id"

# Filter and extract
dodopayments payments list --transform "data.#(amount>5000)#.id"
Use --format json with jq for powerful data processing in shell scripts.

Scripting Example

#!/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
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
Use dodopayments --help to see all available resources and dodopayments [resource] --help for resource-specific commands.

Resources

Support

Need help with the CLI?