Skip to content

Connect your users' apps

Let each of your app users connect their own Gmail, Drive, Slack or GitHub, so their memory fills itself from what they do there.

Your app users keep their work in other apps: their mail, their files, the channels they talk in, the issues they work on. Let each of them connect those apps, and what the apps deliver fills that app user's memory: the same memory your backend adds to and your agent searches, with your API key and their X-Alexein-User.

The person approves on a page Alexein hosts and signs in to the app there. Your app never sees their password or the app's sign-in.

How it works

  1. Your backend asks for a link for one app user, naming the app and where to come back to.
  2. You send that user's signed-in browser to the link.
  3. They approve on Alexein's page, and sign in to the app.
  4. Their browser comes back to your return_to with status=connected&connection_id=…, or status=error&reason=….
  5. The app's history, the last 90 days unless you ask for less, starts arriving in that app user's memory within a few minutes, and what is new keeps arriving after it. You read it as you read anything else in their memory.

From your backend you can also list an app user's connections, disconnect one, and erase what it delivered. Four webhook events tell you when a connection is made, needs the person again, stops, or goes.

Before you start

  • An API key. Connecting and disconnecting take a read and write key, listing a read key. Keep it on your backend. A personal key is refused with 403: your own apps connect to your own memory under My memory › Connectors.
  • Your organisation's name. The page the person approves on names you by it, as the Console shows it. Give it the name your users know you by.
  • An address to come back to. return_to is a page of your app, over https://. While you develop, http://localhost and http://127.0.0.1, on any port, are taken too.

Connect an app

See what can be connected

connections/providers lists every app that can be connected now, with what each reads. Show your users this list rather than one of your own: it is the one that is true today.

curl https://api.alexein.ai/v2/connections/providers \
  -H "Authorization: Bearer $ALEXEIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
200 OK
{
  "providers": [
    {
      "id": "google-gmail",
      "name": "Gmail",
      "sources": [
        { "id": "messages", "description": "Mail you receive and send, with each message's text and the text of its attachments" }
      ],
      "history": { "default_days": 90, "max_days": 90 }
    }
  ]
}

When a signed-in user presses Connect Gmail in your app, your backend asks for a link for that user with connections/connect:

curl https://api.alexein.ai/v2/connections/connect \
  -H "Authorization: Bearer $ALEXEIN_API_KEY" \
  -H "X-Alexein-User: user_42" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "google-gmail",
    "return_to": "https://app.example.com/settings/apps",
    "history_days": 30
  }'
200 OK
{
  "url": "https://app.alexein.ai/connect/oQ3v…",
  "expires_at": "2026-12-01T14:21:07Z"
}

history_days is how far back to read: 7, 15, 30 or 90. Leave it out for 90.

Send that user's browser to it

Answer the user's request with a redirect to url, such as a 303 See Other. Make the link when the user asks, not ahead of time: it is valid for 15 minutes and can be used once. See Keep the link safe.

Handle the return

The person approves and signs in, and their browser comes back to return_to with these added to its query:

QueryWhen
statusconnected, or error.
connection_idWith connected: the new connection's id.
reasonWith error: why it did not connect, below.
providerAlways: the app, as you asked for it.
reasonWhat happenedWhat to do
deniedThe person cancelled on Alexein's page, or the app refused or they declined on its own.Offer to connect again.
exchange_failedThe app's sign-in did not complete.Let them try again later.
not_configuredThe app cannot be connected just now.Hide it until providers lists it again.
expiredThe link expired, or was already used, before they finished.Make a new link.
limitYour organisation reached its plan's connected app users.Disconnect one, or upgrade.

A person who leaves during the app's sign-in may not come back at all; nothing is connected then. Anyone can open your return_to with any query, so take it as a sign of what happened, not as proof. Before you show the app as connected, list the user's connections from your backend, as below.

What the person sees

Alexein's page names you, by your organisation's name, and the app you want to keep in its memory. It also says:

  • that you "will only read" the app, and what: each source's description, as providers lists them;
  • that it reads the last history_days days, and then what is new as it arrives;
  • "You'll go back to" your return_to's host;
  • that Alexein hasn't checked who runs your app;
  • that you can disconnect the app and erase what it kept at any time.

Continue takes them to the app's own sign-in. Cancel sends them back with reason=denied. A link that has expired or was already used shows only that, with no way back to your app, so a user who comes back to it later should start again from your app.

Read what arrives

What a connected app delivers is in that app user's memory, read with your API key and their X-Alexein-User like anything you added:

  • search answers from it, and its provider field keeps one app's.
  • sources says what each connected app delivered: how many items, and the newest.
  • summary lists the connected apps among its counts.

Each new item a connected app brings in counts as 1 event against your plan, like an item you add. Past your plan's events for the month, new items are dropped, not kept for later. See Plan limits.

List an app user's connections

connections lists the apps one app user has connected and has not disconnected:

curl https://api.alexein.ai/v2/connections \
  -H "Authorization: Bearer $ALEXEIN_API_KEY" \
  -H "X-Alexein-User: user_42" \
  -H "Content-Type: application/json" \
  -d '{}'
200 OK
{
  "connections": [
    {
      "id": "6f1c2d9e-4b7a-4e3f-9a51-0c8d2e7b4f13",
      "provider": "google-gmail",
      "status": "active",
      "account_label": "alice@example.com",
      "connected_at": "2026-12-01T14:08:32Z",
      "last_sync_at": "2026-12-01T14:19:05Z",
      "error": null
    }
  ]
}
statusMeans
activeReading. If one of its sources stopped after repeated failures, error says which, and the others go on.
needs_reauthThe app refused access, such as when the person revoked it in their account. Nothing is read until they connect again.

To connect again, make a new link for the same app user and app, and the person signs in to the same account.

Disconnect

connections/disconnect stops reading the app, and with "forget": true also erases what that connection delivered from the app user's memory:

curl https://api.alexein.ai/v2/connections/disconnect \
  -H "Authorization: Bearer $ALEXEIN_API_KEY" \
  -H "X-Alexein-User: user_42" \
  -H "Content-Type: application/json" \
  -d '{"id": "6f1c2d9e-4b7a-4e3f-9a51-0c8d2e7b4f13", "forget": true}'
200 OK
{
  "id": "6f1c2d9e-4b7a-4e3f-9a51-0c8d2e7b4f13",
  "status": "revoked",
  "forgotten": true
}

Without forget, memory keeps what the app already delivered. Nothing more is read, and what is there stays in the app user's memory until you forget it or delete the user. With forget, forgotten: true means the erasure of what that connection delivered has been asked for and is queued: it is not done when the answer comes, and it completes once erasure by connection is available. Items you added yourself are not touched.

Erasing an app user

users/delete disconnects every app the user connected before it erases their memory, and so does Delete app user in the console. If their apps cannot all be disconnected in time, it answers 503 and erases nothing. Sending the same request again is safe: retry after Retry-After, with backoff, and a retry is quick. Deleting a project disconnects every app its app users connected.

Webhook events

A webhook endpoint of the project hears these, with the app user in the event's end_user:

EventSent when
connection.connectedThe person connected an app, or connected it again.
connection.needs_reauthThe app refused access: the person must connect it again.
connection.errorOne of the connection's sources stopped after repeated failures.
connection.disconnectedIt was disconnected: by your request, by an erasure of the app user, or by deleting the project.
  • The link is a one-time credential for that one app user. Whoever opens it first can connect their own app into that app user's memory. It is valid for 15 minutes and used once. Send it only to that user's signed-in browser, as the redirect above does. Never send it by email, chat or text message, never put it in a shared channel, a log or an analytics event, and never make one for anyone but the user who is signed in.
  • The person finishes in the browser where they pressed Continue. If the app's sign-in page is opened anywhere else, such as from a forwarded sign-in link, it ends with "This connect link was opened in another browser. Start again from the app you came from." and nothing is connected.
  • return_to is shown to the person. The page names its host, so make it your own domain. It must be https://; http://localhost and http://127.0.0.1 are taken for development only.
  • Confirm a return from your backend. The query on return_to is not proof: list the connections.
  • Your key and the header pick the memory. No body field can name another app user, project or organisation, and a connection that is not this app user's answers 404.

Limits

Connected app users per plan

Your organisation's plan sets how many of its app users may have apps connected at once, across all its projects:

PlanConnected app users, per organisation
Free3
Starter25
Pro250
Scale1,000
EnterpriseCustom

An app user counts once, however many apps they connect, and an app user who already has one may connect more. At the limit, connect for a new app user answers 402, and a link made before the limit was reached brings the person back with reason=limit. Disconnecting every app of an app user frees their place.

A link keeps the limit it was made with for its 15 minutes, even if the plan changes meanwhile. After a downgrade, app users already connected keep their connections, and their apps go on being read: only new app users are refused at the new limit. See Limits.

What the apps allow

  • Google. Gmail, Google Drive and Google's other apps can be connected.
  • Slack. Outside Slack's Marketplace, Slack lets an app read one channel's history a minute in each workspace, so the history of a workspace with many channels is slow to arrive.
  • Jira and Confluence cannot be connected.
  • History is at most 90 days back: history_days is 7, 15, 30 or 90.
  • Read-only. A connection reads. Nothing acts in the person's apps: no message is sent, no file changed.
  • Disconnecting keeps what memory has, unless you ask for forget.