Skip to main content

Overview

This guide walks you through setting up ActumX and making your first x402 payment-protected API request. You’ll create an agent with a Solana wallet, generate an API key, and execute the complete x402 payment flow.
ActumX enables AI agents to autonomously pay for API access using the x402 protocol - a standardized way to handle HTTP 402 (Payment Required) responses.

Prerequisites

  • A modern browser or HTTP client (curl, Postman, etc.)
  • Basic understanding of REST APIs
  • 5 minutes of your time

Quick Start Steps

1

Create Account and Login

First, create an ActumX account and authenticate to receive a session cookie.

Sign Up

cURL

Sign In

After registration, sign in to receive your session cookie:
cURL
Visit dashboard.actumx.app to create your account through the web interface. Then proceed to creating an agent via API or dashboard.
Response:
The session cookie is HTTP-only and automatically included in subsequent requests when using -b cookies.txt with curl.
2

Create Your First Agent

Create an agent with a Solana wallet. The system automatically generates a keypair and returns the private key (shown only once).
cURL
Response:
Critical: Save the privateKey immediately! It cannot be retrieved after this response. Store it securely in an environment variable or secrets manager.

Understanding Agent Creation

Behind the scenes (from api/src/modules/agents/service.ts:46-59):
  1. A new Solana keypair is generated using @solana/web3.js
  2. The public key is converted to base58 format
  3. The private key is base64-encoded for storage
  4. A unique ID with prefix agent_ is assigned
  5. The agent is stored in PostgreSQL

Fund Your Agent on Devnet (Optional)

To test with actual Solana transactions, fund your agent with devnet SOL:
cURL
Response:
3

Generate an API Key

API keys are used for programmatic access and MCP (Model Context Protocol) integration. They authenticate your requests without requiring session cookies.
cURL
Response:
Save the apiKey value immediately! Like private keys, API keys are only shown once and cannot be retrieved later.

API Key Security

From api/src/modules/api-keys/service.ts:39-49:
  • Keys are cryptographically hashed before storage
  • Only the first 14 characters (key prefix) are visible after creation
  • Keys can be revoked but not deleted (soft delete pattern)
  • Last usage timestamp is tracked automatically

List Your API Keys

cURL
Response:
4

Top Up Your Account Balance

Before making paid API requests, add credits to your account. ActumX uses a credit-based billing system where amounts are stored in cents.
cURL
Request:
  • amountCents: Amount to add in cents (1000 = $10.00)
  • method: Payment method (e.g., “stripe”, “crypto”)
Response:

Check Your Balance

cURL
Response:
5

Make Your First Paid API Request

Now you’re ready to experience the x402 payment flow! This demonstrates how clients can automatically discover pricing, settle payments, and retry requests.

Step 4.1: Initial Request (Receive 402)

Make a request to a protected endpoint without payment proof:
cURL
Response (402 Payment Required):
The 402 response includes all information needed to settle the payment: the payment ID, price, and settlement endpoint. This is the core of the x402 protocol.

Step 4.2: Settle the Payment

Use the paymentId from the 402 response to settle the payment:
cURL
Response:
Behind the scenes (from api/src/modules/x402/service.ts:250-335):
  1. Verify the payment transaction exists
  2. Check sufficient balance (25 cents required)
  3. Create a debit entry in the credit ledger
  4. Update transaction status to “settled”
  5. Generate and return a receipt ID

Step 4.3: Retry with Payment Proof

Now retry the original request with payment headers:
cURL
Response (200 Success):
Congratulations! You’ve completed your first x402 payment flow. Your API request was fulfilled and the payment transaction was marked as “completed”.

Understanding the x402 Payment Flow

The three-phase payment flow is designed for automation and machine-readability:

Payment States

From api/src/modules/x402/service.ts:

Key Implementation Details

Cost Configuration (api/src/config/constants.ts:7-9):
Credit Ledger System:
  • All amounts stored as integers in cents (no floating-point errors)
  • Double-entry ledger: credits (top-ups) and debits (usage)
  • Balance computed as SUM(credits) - SUM(debits)
  • Transactional consistency via PostgreSQL

Common Issues and Solutions

Problem: You’re getting a 402 response when accessing /v1/protected/quote.This is expected behavior! The 402 response contains payment details. Follow these steps:
  1. Extract the paymentId from the x402 object in the response
  2. Call POST /v1/x402/settle with the payment ID
  3. Get the receiptId from the settlement response
  4. Retry your original request with headers:
    • x-payment-id: <paymentId>
    • x-payment-proof: <receiptId>
Error Response:
Solutions:
  • Top up your account via POST /v1/billing/top-up
  • Check your balance with GET /v1/billing/summary
  • Ensure you’re adding enough credits (25 cents minimum per request)
Error Response:
Solutions:
  • Verify your API key is included in the x-api-key header
  • Ensure the API key hasn’t been revoked (check via GET /v1/api-keys)
  • Make sure you copied the complete API key (starts with actumx_live_ or actumx_test_)
  • Generate a new API key if the old one is lost
Error Response:
Solutions:
  • Payment IDs expire after 10 minutes - make a new request to get a fresh payment ID
  • Verify you’re using the correct paymentId from the 402 response
  • Ensure you’re authenticated with the same API key that received the payment challenge
Error Response:
Solutions:
  • Verify the x-payment-id and x-payment-proof headers match the values from settlement
  • Ensure you’ve called /v1/x402/settle before retrying with proof
  • Check that the receipt hasn’t been used already (payments can only be consumed once)
Error: “failed to fund agent on devnet”Solutions:
  • Solana devnet faucet has rate limits - wait a few minutes and retry
  • Request smaller amounts (0.5 SOL instead of 1-2 SOL)
  • Check Solana Status for devnet availability
  • Use alternative devnet faucets if needed

Next Steps

System Architecture

Understand how ActumX components interact and the technology stack

x402 Protocol Deep Dive

Learn the full x402 specification and advanced payment flows

Creating Agents Guide

Advanced agent management, wallet security, and Solana integration

API Reference

Complete API documentation with all endpoints and parameters

What You’ve Learned

Account Management: Created an account and authenticated with session cookies
Agent Creation: Generated a Solana wallet agent with public/private keypair
API Key Generation: Created a hashed, secure API key for programmatic access
Credit System: Topped up account balance using the credit ledger system
x402 Payment Flow: Completed a full 3-phase payment cycle (challenge → settle → consume)
You’re now ready to build applications that leverage ActumX’s x402 protocol for autonomous API payments!