Skip to main content
BitRobot Connect links the wallet a user has on your subnet to their BitRobot account.

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 https page on your own domain, with no query string or fragment, behind your normal login. Send that URL to the BitRobot team.

How it works

  1. The user presses Connect next to your subnet on their BitRobot profile page. BitRobot redirects the browser to your connect URL with request_id and nonce in the query string.
  2. Your connect page stores request_id and nonce in the user’s server-side session and shows a Connect button.
  3. When the user presses Connect, your backend calls the confirm endpoint with your API key and the user’s wallet address.
  4. Your backend redirects the browser to the return_url from the response. BitRobot completes the connection as the page loads.
A connect request expires 30 minutes after the user presses Connect in BitRobot. The 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:
The page must:
  1. 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.
  2. Store request_id and nonce in the server-side session for the signed-in user.
  3. Show the user’s wallet address and a Connect button that POSTs to your confirm handler.
routes/bitrobot-connect.js
Template: Connect page. If your API is stateless, store the values in a table instead of the session. See Stateless hold.

Step 2 — Confirm the wallet

When the user presses Connect, read request_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:
Full reference: Confirm a wallet connection.

Step 3 — Redirect to BitRobot

Check the response body for auth_code, not the HTTP status:
  • auth_code is present. Clear the session values, check that return_url starts with https:// or http://, and redirect the browser to it. Use a 303 redirect from your handler. For a client-side page, return return_url from your handler and call window.location.replace(url).
  • auth_code is absent. Show an error page with the error message from the response. Template: Error page.
routes/bitrobot-connect.js
Redirect to return_url verbatim, fragment included. Do not log, display, or store auth_code.
Complete implementations in seven languages are in the examples.

Errors

404, 409, 410, and 422 responses have this shape. Other errors carry error only.

Test on staging

  1. 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.
  2. Call the confirm endpoint with a made-up request_id. A 404 request_not_found confirms your key and Subnet ID are valid.
  3. Send the BitRobot team your staging connect URL and wait for them to enable it.
  4. 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.
  5. Send a Subnet Points grant by wallet_address for that wallet. The points appear on the user’s dashboard.
Repeat with a production key, 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.