Fleeexdocs

Connecting users

Link an end user to their Fleeex wallet up front — no chat call, no 402.

getConnection() lets you check whether the configured (app, user) is linked to a Fleeex wallet and funded — without provoking a 402 on a first chat call — and hands back an onboarding link to open.

const { connected, funded, connectUrl } = await client.getConnection();
 
if (!connected || !funded) {
  redirect(connectUrl); // sign in → authorize the app → top up
}

It returns a ConnectionStatus:

FieldMeaning
connectedAn (app, user) → wallet mapping exists.
fundedThe resolved wallet currently holds a positive balance.
connectUrlSigned onboarding link to open (sign in, authorize the app, top up).

Unlike the proxy and getBalance(), getConnection() never raises a 402 — it always returns the status. connectUrl is the same signed onboarding link a 402 would hand back, minted on demand with no chat call and no charge.

Returning the user to your app

Pass a redirectUri to have Fleeex send the user back once they're connected and funded:

const { connected, funded, connectUrl } = await client.getConnection({
  redirectUri: "https://app.example.com/fleeex/return",
});

The redirectUri must exactly match one of your app's registered redirect URIs (managed on your app), or the call fails with a 400 (FleeexApiError). This is a security guard against open redirects.

When to use it

  • Onboarding — connect a user the first time they open an AI feature, instead of waiting for the first call to fail.
  • Gating UI — show a "Connect Fleeex" state when connected/funded is false, without spending anything to find out.