Quickstart

Go from zero to a verified payment in about five minutes. Pick your language below โ€” it applies to every snippet.

  1. 1. Get an API key

    Create a free account and generate a key in the Admin Portal. See Get API Key for the full walkthrough. Keys look like sk_live_โ€ฆ โ€” store it as an environment variable:

    export BILLMYAGENT_API_KEY=sk_live_your_key_here

  2. 2. Make your first authenticated request

    Confirm your key works by calling the health endpoint.

    Make your first authenticated request

    Hit the health endpoint with your API key to confirm everything is wired up.

    Shell
    curl https://api.billmyagent.ai/api/v1/health \  -H "X-API-Key: $BILLMYAGENT_API_KEY"
  3. 3. Create a payment

    Create a one-off payment. Amounts use the smallest unit of the currency (wei for ETH).

    Create a payment

    Create a one-off payment. Amounts are in the smallest unit of the currency (wei for ETH).

    Shell
    curl -X POST https://api.billmyagent.ai/api/v1/payments \  -H "Content-Type: application/json" \  -H "X-API-Key: $BILLMYAGENT_API_KEY" \  -d '{    "amount": "1000000000000000000",    "currency": "ETH",    "network": "ethereum",    "scheme": "exact"  }'
  4. 4. Let the SDK handle 402 for you

    When an endpoint requires payment it returns 402 Payment Required. With a wallet adapter configured, the SDK signs and retries automatically โ€” no manual payload juggling.

    Handle HTTP 402 automatically

    With a wallet adapter configured, the SDK detects 402 responses, signs the payment, and retries the request for you.

    Not available in CURL โ€” showing JS.

    JavaScript
    import { PaymentClient, MetaMaskAdapter } from '@billmyagent/payments-core';
    const client = new PaymentClient({  apiKey: process.env.BILLMYAGENT_API_KEY,  walletAdapter: new MetaMaskAdapter(),  autoHandle402: true,});
    // If the endpoint returns 402, the SDK://   1. parses the payment instructions//   2. prompts the wallet to sign//   3. submits + waits for verification//   4. retries the original requesttry {  const result = await client.getPayment('payment-id');} catch (error) {  console.error('Request failed:', error);}

Next steps