Get an API key from an AI agent

An AI agent with no Soldgraph key can ask for one. Its user approves once in the browser, and the agent collects the key without a dashboard visit.

No key yet? Ask for one. Start a request, show your user a link and a code, and collect the key once they approve. On that page they sign in or create a free account (100 free requests, no credit card required). It works like gh auth login.

#1. Start a request

Start
curl -X POST https://api.soldgraph.com/v1/agent/keys \  -H "Content-Type: application/json" \  -d '{"client": "Claude Code"}'

No key is needed. client is your tool's name, shown on the approve page. It's optional, up to 40 characters.

Response
{  "device_code": "kP3x…",  "user_code": "BCDF-GHJK",  "verification_url": "https://soldgraph.com/connect",  "verification_url_complete": "https://soldgraph.com/connect?code=BCDF-GHJK",  "expires_in": 900,  "interval": 5,  "message": "Ask your user to open https://soldgraph.com/connect?code=BCDF-GHJK and approve. Then POST {\"device_code\": \"...\"} to https://api.soldgraph.com/v1/agent/keys/claim every 5 seconds until status is \"approved\". Never show the user the device_code."}

Tell them something like:

Open https://soldgraph.com/connect?code=BCDF-GHJK and approve the request. The page should show the code BCDF-GHJK.

Keep device_code to yourself: it's the secret that collects the key. Don't show it, log it or put it in a URL.

#3. Claim the key

Every interval seconds, until the status changes:

Claim
curl -X POST https://api.soldgraph.com/v1/agent/keys/claim \  -H "Content-Type: application/json" \  -d '{"device_code": "DEVICE_CODE"}'
statusWhat to do
pendingYour user hasn't approved yet. Wait interval seconds and claim again.
approvedDone. The answer has api_key, shown this once, plus key_name and prefix.
deniedYour user cancelled. Stop.
expiredThe 15 minutes ran out. Start a new request if your user still wants a key.
claimedThe key was already collected. It's never shown twice.
Approved
{ "status": "approved", "api_key": "sg_…", "key_name": "Agent · Claude Code · Dec 1", "prefix": "sg_AbCdEfGh…" }

Every answer also has a message saying what to do next.

#Errors

Statuserror.codeWhat to do
429slow_downYou claimed faster than interval. Wait Retry-After seconds, then carry on.
404agent_key_not_foundThe device_code is wrong. Start a new request.
403agent_key_refusedThe account can't have a key, e.g. it was suspended after approving. Tell your user; error.message says why.
429agent_key_limitToo many new requests from this network today. Ask your user to make a key at API keys.
503agent_keys_unavailableAgent keys are switched off. Ask your user to make a key at API keys.

#4. Save the key

Save it as SOLDGRAPH_KEY in your user's environment or secrets manager, and send it as Authorization: Bearer $SOLDGRAPH_KEY. Never put it in browser code, a prompt or a repository. Then follow the quickstart.

It's an ordinary key on your user's account. It's listed on API keys as Agent · <client> · <date>, uses the account's plan and can be revoked anytime.

#Limits

  • 50 new requests a day per IP address (per /64 for IPv6).
  • A request lasts 15 minutes. The key is shown once.
  • Approving needs an account that can create keys: a confirmed email address that isn't a temporary inbox.

Overviews: eBay sold listings API · findCompletedItems alternative · Poshmark sold listings API · Mercari sold listings API · Pokémon card price API · Sports card price API · Depop listings API · Vinted listings API · Whatnot listings API · Sold comps API for reseller apps · Sold comps for AI agents · Facebook Marketplace API · OfferUp API · TCGplayer API alternative