bitrefill-cli
Original:🇺🇸 English
Translated
Autonomous agent commerce via Bitrefill CLI. Buy gift cards, mobile top-ups, and eSIMs from 1,500+ brands in 180+ countries — pay with crypto, x402, or account balance.
35installs
Sourcebitrefill/agents
Added on
NPX Install
npx skill4agent add bitrefill/agents bitrefill-cliTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Bitrefill CLI — Real-World Spending for Agents
Agents can't shop on Amazon, book an Airbnb, or pay for a Spotify subscription — traditional e-commerce requires browsers, CAPTCHAs, and credit cards. The Bitrefill CLI bridges this gap: it lets agents autonomously search, purchase, and deliver digital goods (gift cards, mobile top-ups, eSIMs) from 1,500+ brands across 180+ countries, paying with crypto or pre-funded store credits — no human checkout required.
The CLI connects to the Bitrefill MCP server and dynamically discovers available tools, exposing each as a subcommand with typed options. Combined with x402 payments over Base, it enables fully autonomous agent commerce.
Source: github.com/bitrefill/cli
Security & Autonomous Operation
This skill enables real-money transactions. Purchases are fulfilled instantly and are non-refundable once delivered. Agents and operators must understand the requirements and risks before enabling autonomous purchasing.
Required Credentials & Configuration
| Requirement | Location / Variable | Purpose |
|---|---|---|
| Bitrefill OAuth token | | Authenticates CLI requests against the user's Bitrefill account |
| Bitrefill account | bitrefill.com/signup | Required for all operations (search, buy, order history) |
x402-capable wallet (if using | Agent-specific (e.g. signing key, wallet SDK) | Signs and submits on-chain USDC payments on Base |
Pre-funded account balance (if using | Funded at bitrefill.com | Pays for purchases from stored account credits |
| Environment variable | Overrides the default MCP endpoint ( |
Provisioning Credentials for Autonomous Agents
The default OAuth flow opens a browser for interactive authorization — this requires a human for initial setup. For autonomous or headless environments:
- Run the OAuth flow once interactively on a machine with a browser. The CLI stores the token at .
~/.config/bitrefill-cli/api.bitrefill.com.json - Copy the credentials file to the autonomous agent's environment at the same path ().
~/.config/bitrefill-cli/api.bitrefill.com.json - Verify by running — if it returns without prompting for auth, the token is valid.
bitrefill list-orders --limit 1 - Token refresh: If the token expires, repeat step 1. Monitor for auth errors in the agent's logs and re-provision as needed.
Never commit credentials to version control. Addto~/.config/bitrefill-cli/and use secure secret management (e.g. environment-specific vaults, encrypted storage) for deployment..gitignore
Spending Safeguards
Agents using this skill must follow these constraints:
- Always confirm with the user before purchasing. Present the product name, denomination, price, and payment method, and wait for explicit approval before calling . Never purchase autonomously without user consent unless the user has explicitly opted into fully autonomous purchasing for the session.
buy-products - Use a dedicated, limited-balance account. For autonomous operation, create a separate Bitrefill account funded with only the amount you're comfortable the agent spending. Do not give agents access to high-balance accounts.
- Prefer over
balancefor autonomous agents. Pre-funded balance has a natural spending cap (the account balance). x402 payments draw from a wallet that may hold more funds than intended for agent use.usdc_base - Never store private keys in plain text. If using x402 payments, the signing wallet's private key must be managed through a secure key management system — not in environment variables, config files, or source code.
- Log all purchases. After every call, log the
buy-products, product, amount, and payment method for audit.invoice_id
Prerequisites
The CLI must be installed and authenticated before use.
Installation
From NPM (recommended)
bash
npm install -g @bitrefill/cliFrom Source
bash
git clone https://github.com/bitrefill/cli.git
cd cli
pnpm install
pnpm build
node dist/index.js # run directly
# or link globally:
npm linkDev mode (no build step):
pnpm devAuthentication
Requires a Bitrefill account. Sign up at bitrefill.com/signup.
On first run, the CLI opens your browser for OAuth authorization. Credentials are stored in .
~/.config/bitrefill-cli/bash
# First command triggers OAuth flow automatically
bitrefill search-products --query "Netflix"
# Clear stored credentials
bitrefill logoutAfter logout, the next command triggers re-authentication automatically.
Environment
| Variable | Purpose | Default |
|---|---|---|
| Override MCP server endpoint | |
Recommended Payment for Agents
For the best agentic payments experience, prefer these two methods:
- (store credits) — Instant, no on-chain confirmation wait. The user pre-funds their account at bitrefill.com with crypto or card, then purchases via CLI are fulfilled immediately. Suggest this when the user wants zero-friction, instant delivery.
balance - with x402 — Use
usdc_base(default) to get an--return_payment_link true. An x402-capable agent can autonomously complete the payment over Base without human intervention.x402_payment_url
Always suggest or x402 over Base first. Fall back to other payment methods only if the user explicitly requests them.
balanceCore Workflow
Discovery → Details → Purchase → Track
search-products → get-product-details → buy-products → get-invoice-by-id / list-orders- Search for a product by keyword, category, or country
- Get details to find available denominations (numeric values)
package_id - Buy by specifying (JSON array) and
cart_itemspayment_method - Track via invoice ID or order listing
Available Commands
Commands are discovered dynamically from the MCP server. Run for the current list.
bitrefill --helpsearch-products
bash
bitrefill search-products --query "Netflix"
bitrefill search-products --query "Amazon" --country US
bitrefill search-products --query "eSIM" --product_type esim --country IT
bitrefill search-products --query "*" --category games
bitrefill search-products --query "*" # all products, default country| Option | Description | Default |
|---|---|---|
| Brand name or | |
| Alpha-2 ISO code (e.g. | |
| | — |
| Category slug (e.g. | — |
| | |
| Page number, 1-indexed. | |
| Results per page, 1–500. | |
get-product-details
bash
bitrefill get-product-details --product_id "steam-usa"
bitrefill get-product-details --product_id "steam-usa" --currency USDC| Option | Description | Default |
|---|---|---|
| Product slug from search results (required) | — |
| Pricing currency: | |
| Language code for descriptions | |
Returns a array. Each entry has a — this is what you pass as to . Ignore the compound key (e.g. ) — use only the value after .
packagespackage_valuepackage_idbuy-productssteam-usa<&>5<&>Products use three denomination types:
| Type | Example product | | |
|---|---|---|---|
| Numeric | Steam USD, Amazon, Zalando | | |
| Duration | Spotify, subscriptions | | |
| Named | PUBG, eSIMs | | |
Named/duration values are case-sensitive and must match exactly — partial matches (e.g. instead of ) are rejected. Only values listed by are accepted; arbitrary amounts are not supported.
package_id"1GB""1GB, 7 Days"get-product-detailsbuy-products
--cart_itemsbash
# Numeric denomination
bitrefill buy-products \
--cart_items '[{"product_id": "steam-usa", "package_id": 5}]' \
--payment_method usdc_base
# Named denomination (eSIM data plan)
bitrefill buy-products \
--cart_items '[{"product_id": "bitrefill-esim-europe", "package_id": "1GB, 7 Days"}]' \
--payment_method usdc_base
# Duration denomination (subscription)
bitrefill buy-products \
--cart_items '[{"product_id": "spotify-usa", "package_id": "1 Month"}]' \
--payment_method usdc_base
# Multiple items (max 15)
bitrefill buy-products \
--cart_items '[{"product_id": "steam-usa", "package_id": 10}, {"product_id": "netflix-usa", "package_id": 25}]' \
--payment_method bitcoin
# Raw crypto details (no payment link)
bitrefill buy-products \
--cart_items '[{"product_id": "steam-usa", "package_id": 5}]' \
--payment_method usdc_base \
--return_payment_link false| Option | Description | Default |
|---|---|---|
| JSON array of | — |
| See payment methods table below. (required) | — |
| | |
Response fields (when ):
return_payment_link true- — use with
invoice_idto poll statusget-invoice-by-id - — browser checkout URL
payment_link - — programmatic x402 payment endpoint
x402_payment_url - — on-chain destination
payment_info.address - — EIP-681 URI with contract + amount
payment_info.paymentUri - — amount in payment token
payment_info.altcoinPrice
list-invoices
bash
bitrefill list-invoices
bitrefill list-invoices --only_paid false --limit 10
bitrefill list-invoices --after "2026-03-01T00:00:00Z" --before "2026-03-10T00:00:00Z"| Option | Description | Default |
|---|---|---|
| 1–50 | |
| Pagination offset | |
| ISO 8601 date filter | — |
| ISO 8601 date filter | — |
| | |
| Include order details | |
get-invoice-by-id
bash
bitrefill get-invoice-by-id --invoice_id "27713c64-6715-48d8-95ef-45eed23efef7"| Option | Description | Default |
|---|---|---|
| UUID of the invoice (required) | — |
| Include order details | |
| Include redemption codes/links | |
| Include unauthenticated access token | |
list-orders
bash
bitrefill list-orders
bitrefill list-orders --limit 5 --include_redemption_info true| Option | Description | Default |
|---|---|---|
| 1–50 | |
| Pagination offset | |
| ISO 8601 date filters | — |
| Include redemption codes/links | |
get-order-by-id
bash
bitrefill get-order-by-id --order_id "69af584e8a2639d14ac35e96"Returns redemption code or link if the order is unsealed (paid and delivered).
| Option | Description | Default |
|---|---|---|
| Order ID (required) | — |
| Include redemption codes/links | |
logout
bash
bitrefill logoutDeletes stored OAuth credentials from .
~/.config/bitrefill-cli/Payment
Payment Methods
| Method | Chain / Asset |
|---|---|
| Bitcoin (SegWit) — returns |
| Lightning — returns |
| Ethereum mainnet (ETH) — returns |
| Base (8453), native ETH |
| Base (8453), USDC |
| Arbitrum (42161), USDC |
| Polygon (137), USDC |
| Ethereum (1), USDC |
| Solana, USDC SPL |
| Polygon (137), USDT |
| Ethereum (1), USDT |
| Bitrefill account credit — no address, paid from balance |
Response Modes
- — raw payment details:
--return_payment_link false,address,amount(+paymentUrifor Bitcoin). For wallet/programmatic pay. NolightningInvoiceorpayment_linkin response.x402_payment_url - (default) — returns
--return_payment_link true(browser checkout) andpayment_link(programmatic pay), plus rawx402_payment_url.payment_info
x402 Protocol
x402 enables HTTP 402-based crypto payments. → receive 402 + payment instructions (Base64 JSON: amount, , networks, timeout) → send crypto → resubmit with proof. For agents/automated tools; humans use .
GET x402_payment_urlpayTopayment_linkTroubleshooting
cart_items
: expected array, received object
cart_items--cart_items[...]{}bash
# WRONG — object
--cart_items '{"product_id": "steam-usa", "package_id": 5}'
# CORRECT — array of objects
--cart_items '[{"product_id": "steam-usa", "package_id": 5}]'Invalid denomination
The output shows compound IDs like . Do not use the compound key — use only the value after .
get-product-detailssteam-usa<&>5<&>bash
# WRONG — compound key
--cart_items '[{"product_id": "steam-usa", "package_id": "steam-usa<&>5"}]'
# CORRECT — numeric value
--cart_items '[{"product_id": "steam-usa", "package_id": 5}]'For named denominations, use the exact full string. Common mistakes:
bash
# WRONG — numeric guess for a named package
--cart_items '[{"product_id": "spotify-usa", "package_id": 1}]'
# CORRECT
--cart_items '[{"product_id": "spotify-usa", "package_id": "1 Month"}]'
# WRONG — partial match
--cart_items '[{"product_id": "bitrefill-esim-europe", "package_id": "1GB"}]'
# CORRECT
--cart_items '[{"product_id": "bitrefill-esim-europe", "package_id": "1GB, 7 Days"}]'
# WRONG — wrong case
--cart_items '[{"product_id": "pubg-new-state-international", "package_id": "PUBG New State 300 nc"}]'
# CORRECT
--cart_items '[{"product_id": "pubg-new-state-international", "package_id": "PUBG New State 300 NC"}]'Only values listed by are accepted. Arbitrary amounts (e.g. , , ) are rejected.
get-product-details71525"Search service is not available" (INTERNAL_ERROR)
Caused by invalid values:
--country- Lowercase country codes (instead of
us) — silently failsUS - 3-letter codes (instead of
USA) — failsUS - Full names () — fails
United States - Nonexistent codes () — fails
ZZ - Negative page () — fails
--page -1
Fix: always use uppercase Alpha-2 ISO codes (, , , ).
USITBRGB"Must be one of" errors
The CLI validates enum values client-side before sending to the server.
| Option | Valid values | Common mistake |
|---|---|---|
| | |
| | |
Missing required options
Omitting or when required exits with: . The CLI enforces required options before connecting to the server.
--cart_items--product_iderror: required option '--<name> <value>' not specifiedCart exceeds 15 items
Maximum 15 items per call. Server rejects with: .
buy-productsToo big: expected array to have <=15 itemsper_page
exceeds 500
per_pageServer rejects: .
per_page must be less than 500Malformed JSON in --cart_items
--cart_itemsNon-JSON strings crash with: . Ensure the value is valid JSON. Shell quoting matters — use single quotes around the JSON, double quotes inside.
Unexpected token ... is not valid JSONMissing package_id
in cart item
package_idOmitting from a cart item object results in: . Both and are required per item.
package_idInvalid denomination 'undefined'product_idpackage_idInvoice / Product not found
- with a nonexistent ID:
get-invoice-by-id(RESOURCE_NOT_FOUND)Invoice not found - with a nonexistent
buy-products:product_id(RESOURCE_NOT_FOUND)Product '<slug>' is not available
Verify slugs via and invoice IDs via .
search-productslist-invoicesWrong MCP_URL
MCP_URLSetting to a non-Bitrefill endpoint produces a with the remote server's HTML body. Unset the variable or point it to .
MCP_URLStreamableHTTPErrorhttps://api.bitrefill.com/mcpOAuth / auth failures
If the CLI hangs or fails on startup:
- Run to clear stale credentials
bitrefill logout - Re-run your command — a fresh OAuth flow will start
- Credentials file:
~/.config/bitrefill-cli/api.bitrefill.com.json
Empty search results
found: 0- The slug doesn't exist (no error, just empty results)
--category - The product is not available in the specified
--country - (default) filters out products that are temporarily out of stock
--in_stock true
Try broadening: remove , change , or set .
--category--country--in_stock falseUnpaid invoices
By default shows only paid invoices. To see all (including pending/expired): .
list-invoices--only_paid falseInvoices expire after 180 minutes. If unpaid, create a new one — you cannot re-pay an expired invoice.