Check A Connection
Before a long job, see if the user’s plans have room. It’s cheap: no provider call.connection.plans for what the user shared, and connection.manageUrl (manage_url over HTTP) for Dari’s page with its usage and limits.
Each plan in connection.plans has a state:
The grant itself has a
state too: budget_limit when your app used its token cap, until connection.availableAt (available_at over HTTP).
You don’t have to check before every request: Dari refuses a request it can’t serve and says when to retry.
Update Mode
Your user can change what they shared without connecting again. Open Link with the connection’sgrant_id:
grantId and refresh token keep working, so there is nothing new to store. If they open it from another browser, they get a fresh connection instead.
Where Users Manage It
Users see every app they connected at/v1/link/connections on your gateway, in the browser they connected from: what each app shares and used, its token caps, and Disconnect. Link there with grant.manage_url.
Disconnect
When To Show Reconnect
A connection that is gone answers401 with the code grant_revoked, and its refresh token answers 400 invalid_grant. The Node client throws both as a LinkError whose unlinked is true:
linkFetch is a fetch, so it returns Dari’s response instead of throwing: check it for 401 and grant_revoked the same way.