Agentic payments with x402 protocol
With the x402 protocol, AI agents can run Apify Actors and pay with USDC on the Base blockchain - no Apify account needed.
Agentic payments are experimental and may change as payment protocols evolve.
If you are an AI agent, use the ready-made Apify x402 skill. It walks you through wallet setup, payment, and running Actors end to end. The steps below describe the same flow for manual use.
What is x402
The x402 protocol is an open standard for on-chain payments over HTTP. It is blockchain-agnostic and supports any EVM-compatible chain and Solana, with stablecoins as the primary payment method. The Apify integration uses USDC, a stablecoin pegged to the US dollar, on the Base blockchain.
When a server requires payment, it responds with HTTP 402 and tells the client what payment formats it accepts. Your wallet signs a USDC transfer off-chain (locally, without touching the blockchain) and the server settles (finalizes) the payment on-chain (on the blockchain). With Apify, you make a single payment upfront to receive a prepaid token, then use that token to run as many Actors as your balance allows.
Prerequisites
- The Coinbase Agentic Wallet (
awal), run throughnpx. - USDC in the wallet on Base mainnet to pay for Actor runs ($1 minimum required). The funds live in the wallet itself, not in a Coinbase exchange account, and can come from any source that sends USDC on Base.
- A small amount of ETH in the wallet on Base (about
0.000001ETH) to cover gas (network cost) for the one-time deployment of your wallet. - An email address to authenticate the wallet. For an agent to run autonomously, it must be able to read the inbox to retrieve the verification code.
No Apify account is required.
Set up your wallet
Authenticate the Coinbase Agentic Wallet with your email. The wallet sends a verification code that you confirm in a second command:
# Log in with your email
npx -y awal auth login <email>
# Confirm the verification code sent to your email
npx awal auth verify <code>
# Check that you are authenticated
npx awal status
The verification code arrives by email. An agent running without a human in the loop needs programmatic access to that inbox to read the code and pass it to awal auth verify. Use an inbox the agent can access, such as a dedicated mailbox or an email API.
Fund your wallet
Display your wallet address and balances, then fund the address with USDC and ETH on Base:
# Show your wallet address
npx awal address
# Show balances on Base
npx awal balance --chain base --json
Both USDC and ETH must be present. ETH covers the gas for deploying your wallet on its first payment.
Buy a prepaid token
Pay for a prepaid token from the Apify agentic endpoint. The wallet signs the payment and returns a token tied to a prepaid balance:
npx awal x402 pay 'https://agi.apify.com/protocols/x402/prepaid-tokens?amount=1¤cy=usd' \
--max-amount 1000000 --json
The returned token acts as an API token for the duration of its balance. Treat it like a secret - do not print or persist it where others can read it.
Check the remaining balance on a token at any time:
curl -s "https://agi.apify.com/prepaid-tokens/balance" \
-H "Authorization: Bearer $TOKEN"
Run an Actor
Use the prepaid token as a bearer token against the Apify API. First find an Actor that supports agentic payments, then run it and read its results in a single call.
When using the API, replace the / in the Actor name with ~ (for example, apify/instagram-post-scraper becomes apify~instagram-post-scraper).
# Discover Actors in the store
curl -s "https://api.apify.com/v2/store"
# Narrow the results with a search term
curl -s "https://api.apify.com/v2/store?search=instagram&limit=5"
# Run an Actor and get its dataset items in one call
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"username": ["natgeo"], "resultsLimit": 3}' \
"https://api.apify.com/v2/actors/apify~instagram-post-scraper/run-sync-get-dataset-items"
# → JSON array with the scraped Instagram posts
To review what an Actor does and which input it accepts, fetch its Markdown documentation at https://apify.com/<username>/<actor-name>.md.
Access the run and its storages
The prepaid token authenticates every call that draws from its balance. You can start a run asynchronously with the Run Actor endpoint and then poll its status or fetch results separately, instead of using run-sync-get-dataset-items.
# Get run status
curl -s \
-H "Authorization: Bearer $TOKEN" \
"https://api.apify.com/v2/actor-runs/<runId>"
# Fetch dataset items for the run
curl -s \
-H "Authorization: Bearer $TOKEN" \
"https://api.apify.com/v2/datasets/<datasetId>/items"
Supported Actors
Not all Actors in Apify Store can be run using agentic payments. To be eligible, an Actor must:
- Use the pay per event pricing model. Rental and pay-per-usage Actors are not supported.
- Run with limited permissions. Actors that request full permissions are excluded.
- Not use Standby mode for now. Standby support is coming later.
Token pricing and limits
- Minimum transaction: $1 in USDC.
- The token balance is an absolute spending cap. Every Actor run draws from it until the balance is exhausted.
- The token expires 14 days after purchase. Any unused balance is non-refundable.
- Deploying your wallet on its first payment costs a small gas fee (network cost) charged by the Base network.
Next steps
- Browse Apify Store for supported Actors to use with x402.
- Learn more about Pay Per Event pricing for Actors.
- Read the x402 protocol specification for technical details on the payment standard.