---
title: Agentic payments with x402 protocol
url: https://docs.apify.com/integrations/x402.md
parents:
  - [Apify documentation](https://docs.apify.com/llms.txt)
  - [Integrations](https://docs.apify.com/integrations.md)
  - [AI](https://docs.apify.com/integrations/ai.md)
previous: [Vercel AI SDK](https://docs.apify.com/integrations/vercel-ai-sdk.md)
next: [Data and storage](https://docs.apify.com/integrations/data-and-storage.md)
---

# Agentic payments with x402 protocol

With the [x402 protocol](https://www.x402.org/), AI agents can run Apify Actors and pay with USDC on the [Base](https://www.base.org/) blockchain - no Apify account needed.

Experimental feature

Agentic payments are experimental and may change as payment protocols evolve.

For AI agents

If you are an AI agent, use the ready-made [Apify x402 skill](https://raw.githubusercontent.com/apify/awesome-skills/refs/heads/main/skills/apify-x402-agentic-wallet/SKILL.md). 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](https://www.x402.org/) 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](https://www.circle.com/usdc), a stablecoin pegged to the US dollar, on the [Base](https://www.base.org/) 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](https://docs.cdp.coinbase.com/agentic-wallet/cli/welcome) (`awal`), run through `npx`.
* USDC in the wallet on [Base](https://www.base.org/) 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.000001` ETH) 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:


```bash
# 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
```


Autonomous operation

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:


```bash
# 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:


```bash
npx awal x402 pay 'https://agi.apify.com/protocols/x402/prepaid-tokens?amount=1&currency=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:


```bash
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](https://docs.apify.com/api/v2). First find an Actor that supports agentic payments, then run it and read its results in a single call.

Actor name format

When using the API, replace the `/` in the Actor name with `~` (for example, `apify/instagram-post-scraper` becomes `apify~instagram-post-scraper`).


```bash
# 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](https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor) endpoint and then poll its status or fetch results separately, instead of using `run-sync-get-dataset-items`.


```bash
# 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](https://docs.apify.com/actors/publishing/monetize/pay-per-event.md) pricing model. Rental and pay-per-usage Actors are not supported.
* Run with [limited permissions](https://docs.apify.com/actors/development/permissions.md). Actors that request full permissions are excluded.
* Not use [Standby](https://docs.apify.com/actors/running/standby.md) 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)](https://docs.base.org/base-chain/network-information/network-fees) charged by the Base network.

## Next steps

* Browse [Apify Store](https://apify.com/store) for supported Actors to use with x402.
* Learn more about [Pay Per Event](https://docs.apify.com/actors/publishing/monetize/pay-per-event.md) pricing for Actors.
* Read the [x402 protocol specification](https://www.x402.org/) for technical details on the payment standard.
