Skip to main content
Early Access - The Dcycle CLI is currently available for enterprise customers. Contact us to learn more about access.

Examples & Workflows

Learn how to automate sustainability data management with practical, production-ready examples.

Quick Start

Get up and running in under a minute:
# 1. Login
dc auth login

# 2. List your organizations
dc org list

# 3. Set active organization
dc org set <your-org-id>

# 4. Explore your data
dc facility list
dc vehicle list

Automation-Ready Features

The CLI is designed for automation and AI agent integration:

Structured Output

All commands support machine-readable output:
# JSON for programmatic processing
dc vehicle list --format json

# CSV for spreadsheet tools
dc facility list --format csv

# Pipe to jq for processing
dc vehicle list --format json | jq '.[] | {plate, fuel}'

Non-Interactive Mode

Skip confirmation prompts in automated pipelines:
# Delete without confirmation
dc vehicle delete $VEHICLE_ID --yes

# Upload without prompts
dc logistics upload data.csv --type requests --yes

Environment-Based Authentication

No credentials in scripts—use environment variables:
export DCYCLE_API_KEY=your_api_key
export DCYCLE_ORG_ID=your_org_id

# Commands use environment automatically
dc vehicle list

Common Patterns

Export and Process with jq

# Count vehicles by fuel type
dc vehicle list --format json | jq 'group_by(.fuel) | map({fuel: .[0].fuel, count: length})'

# List facility names
dc facility list --format json | jq '.[].name'

# Find high-emission vehicles
dc vehicle list --format json | jq '.[] | select(.emissions_tco2e > 50)'

Bulk Operations

# Generate template
dc vehicle upload --template > vehicles.csv

# Edit CSV with your data, then upload
dc vehicle upload vehicles.csv --yes

# Verify upload
dc vehicle list

Error Handling with Retry

upload_with_retry() {
    local file=$1
    local max_attempts=3

    for attempt in $(seq 1 $max_attempts); do
        echo "Attempt $attempt: Uploading $file..."
        if dc logistics upload "$file" --type requests --yes; then
            echo "✓ Success"
            return 0
        fi
        sleep 30
    done
    return 1
}

Troubleshooting

Check Authentication

dc auth status

Verify Organization Context

dc org list
dc org set <correct-org-id>

Debug API Calls

dc --verbose vehicle list

More Resources