Nevermined — Agentic Access (x402)

Autonomous agents can purchase a Baselayer API key and run real KYB
business searches, paying per request via
Nevermined x402 card delegation. No Baselayer
account or human signup required — payment is identity.

This page is the agent-facing integration guide. It covers (1) the
one-time Nevermined payment setup and (2) the Baselayer endpoints you
can buy and call.

Environment

  • Baselayer agentic API base URL: https://api.staging.baselayer.com
  • Nevermined environment: Production · Live (https://api.live.nevermined.app)
    — payments move real money. Nevermined API keys for this network
    start with live.
  • Payment scheme: nvm:card-delegation (credit/debit card via
    Stripe delegation)
  • Payment plan: Baselayer Startup — $10.00 per 100 credits
    (plan details)
  • Agent listing: Baselayer Business Search Agent

One-time payment setup (Nevermined side)

All payments go through Nevermined's x402 flow. Never call Stripe or
any other payment API directly.

A human is needed exactly twice — to create your Nevermined API key and
to enroll a card. Everything after that is programmatic and reusable.

  1. Get a Nevermined API key. A human signs in once at
    https://nevermined.app and creates an API key for the live
    environment (starts with live). For a fully agentic handoff, use
    the embedded login flow: host a callback on 127.0.0.1 and send your
    human to
    https://nevermined.app/auth/cli?callback_url=http://127.0.0.1:<port>/callback
    — the key is delivered to your callback. Store it and send it as
    Authorization: Bearer <api-key> on every Nevermined call.
  2. Enroll a card (one-time, needs a human). Either directly in the
    Nevermined app (Payment Methods → Enroll card), or via the embedded
    flow: mint a session with
    POST https://api.live.nevermined.app/api/v1/embed/session
    ({"returnUrl": "http://127.0.0.1:<port>/callback"}), then send your
    human to
    https://embed.nevermined.app/cards/setup?sessionToken=<token>&returnUrl=...&state=<random>&provider=stripe.
  3. Create a spending delegation (programmatic):
    POST https://api.live.nevermined.app/api/v1/delegation/create with
    {"provider": "stripe", "providerPaymentMethodId": "<pm_...>", "spendingLimitCents": 10000, "durationSecs": 604800, "currency": "usd"}. A delegation authorizes spending within a budget
    and time window — reuse it until spent or expired.
  4. Mint an x402 access token (programmatic, repeatable):
    POST https://api.live.nevermined.app/api/v1/x402/permissions with
    {"accepted": {"scheme": "nvm:card-delegation", "network": "stripe", "planId": "<plan id above>"}, "delegationConfig": {"delegationId": "<your delegation>"}} → returns accessToken.

You do not call settle yourself for Baselayer — our endpoints
verify and settle server-side on every request. Your card is charged
per request through your delegation; the settlement receipt comes back
base64-encoded in the payment-response response header.

Buying and using Baselayer access

Both endpoints require the x402 token in the payment-signature
header. Calling them without it returns HTTP 402 with a base64
payment-required challenge header describing the plan — decode it to
discover everything you need programmatically.

1. Purchase an API key — POST /alpha/api_keys

POST https://api.staging.baselayer.com/alpha/api_keys
Content-Type: application/json
payment-signature: <x402 access token>

{"name": "my-agent", "default_request_mode": "sync"}

Response 201:

{
  "id": "…",
  "name": "my-agent",
  "key": "prod_…",
  "default_request_mode": "sync"
}

Store key — it is a real Baselayer production API key.

2. Run a business search — POST /alpha/searches

Send both your x402 token (pays for the request) and your purchased key
(identifies you):

POST https://api.staging.baselayer.com/alpha/searches
Content-Type: application/json
payment-signature: <x402 access token>
X-API-Key: prod_…
Prefer: wait=120

{"name": "Howard Concrete Pumping Co Inc",
 "address": "2327 Hill Church Houston Rd, Canonsburg PA 15317"}

Response 201 (synchronous — full results in-line): SOS registrations,
officers, watchlist screening, and match verdicts such as
"business_name_match": "EXACT". Optional request fields include
officer_names, website, phone_number, email, and tin — see
the Search API reference for
the complete schema.

Python example

import httpx
from payments_py import Payments
from payments_py.common.types import PaymentOptions
from payments_py.x402.types import DelegationConfig, X402TokenOptions

PLAN_ID = "64016128970723825062202451177754352720194073054658343333156009220723821177122"
AGENT_ID = "60798063874007247008401413456869371418449913824213519077458224260713519377086"
BASE = "https://api.staging.baselayer.com"

payments = Payments.get_instance(
    PaymentOptions(nvm_api_key="live:…", environment="live")
)
card = payments.delegation.list_payment_methods(provider="stripe")[0]
delegation = payments.delegation.create_delegation(...)  # step 3 above
token = payments.x402.get_x402_access_token(
    PLAN_ID,
    AGENT_ID,
    token_options=X402TokenOptions(
        scheme="nvm:card-delegation",
        delegation_config=DelegationConfig(delegation_id=delegation.delegation_id),
    ),
)["accessToken"]

key = httpx.post(
    f"{BASE}/alpha/api_keys",
    json={"name": "my-agent", "default_request_mode": "sync"},
    headers={"payment-signature": token},
).json()["key"]

results = httpx.post(
    f"{BASE}/alpha/searches",
    json={"name": "Acme Corp", "address": "1 Main St, Dover, DE"},
    headers={"payment-signature": token, "X-API-Key": key, "Prefer": "wait=120"},
    timeout=180,
).json()

Errors

  • 402 + payment-required header — missing, invalid, or exhausted
    payment token. Decode the header, (re)mint a token, retry.
  • 404 within /alpha — only the two endpoints above are served.
  • You are only charged for successful (2xx) requests.

Reference


Did this page help you?