Prerequisites
- Your subnet is registered and you know its Subnet ID.
- An API key for the subnet, kept server-side.
- A connect URL you host: an
httpspage on your own domain, with no query string or fragment, behind your normal login. Send that URL to the BitRobot team.
How it works
- The user presses Connect next to your subnet on their BitRobot profile page. BitRobot redirects the browser to your connect URL with
request_idandnoncein the query string. - Your connect page stores
request_idandnoncein the user’s server-side session and shows a Connect button. - When the user presses Connect, your backend calls the confirm endpoint with your API key and the user’s wallet address.
- Your backend redirects the browser to the
return_urlfrom the response. BitRobot completes the connection as the page loads.
auth_code in the confirm response is single-use and expires 5 minutes after the confirm call.
Step 1 — Build the connect page
BitRobot opens your connect URL like this:- Require login. If the user is signed out, send them through login and back to this URL with the query string intact. See Returning from login.
- Store
request_idandnoncein the server-side session for the signed-in user. - Show the user’s wallet address and a Connect button that POSTs to your confirm handler.
routes/bitrobot-connect.js
Step 2 — Confirm the wallet
When the user presses Connect, readrequest_id and nonce from the session and call the confirm endpoint from your backend:
If you send an
Idempotency-Key header, use a new value on every attempt, including retries.
A successful response returns 200:
Step 3 — Redirect to BitRobot
Check the response body forauth_code, not the HTTP status:
auth_codeis present. Clear the session values, check thatreturn_urlstarts withhttps://orhttp://, and redirect the browser to it. Use a303redirect from your handler. For a client-side page, returnreturn_urlfrom your handler and callwindow.location.replace(url).auth_codeis absent. Show an error page with theerrormessage from the response. Template: Error page.
routes/bitrobot-connect.js
Errors
404, 409, 410, and 422 responses have this shape. Other errors carry error only.
Test on staging
-
Ask the BitRobot team to register your subnet on staging and use the Subnet ID they issue. Create a staging API key and set
BITROBOT_API_BASE=https://api-stage.bitrobot.ai. -
Call the confirm endpoint with a made-up
request_id. A404 request_not_foundconfirms your key and Subnet ID are valid. - Send the BitRobot team your staging connect URL and wait for them to enable it.
-
Sign in at
https://stage.bitrobot.ai, open your profile page, press Connect next to your subnet, then press Connect on your page. The subnet shows Connected. -
Send a Subnet Points grant by
wallet_addressfor that wallet. The points appear on the user’s dashboard.
https://api.bitrobot.ai, and your production connect URL.
Next steps
Examples
Complete implementations in seven languages, the pages you render, and tests worth shipping.
Points system
How Subnet Points are granted and convert to Bolts.