Skip to content

Connect

A one-time link for one app user to connect one of their apps, so what it delivers fills their memory.

POST/v2/connections/connectTry it in the Playground
Auth
read and write key (project)
Cost
free; limited by your plan's connected app users

Makes a link for the app user named in X-Alexein-User to connect one app. Send that user's signed-in browser to url. They approve on Alexein's page, sign in to the app, and come back to return_to. From then on, what the app delivers arrives in their memory: its history first, then what is new. See Connect your users' apps.

The link is a one-time credential for that one app user: it is valid for 15 minutes and can be used once. Send it only to that user's signed-in browser, as a redirect, never by email or into a shared channel.

Headers

Authorizationstringrequired

Bearer ax_…, an API key. The key must read and write.

X-Alexein-Userstringrequired

The app user whose app is connected, and whose memory it fills. See App users.

X-Request-Idstring

Your id for this request, echoed on the response.

Body

providerstringrequired

The app to connect: an id from providers, such as google-gmail.

return_tostringrequired

Where the person's browser comes back to. https://, or for development http://localhost or http://127.0.0.1, on any port. The page they approve on shows its host, so use your own domain.

history_daysinteger

How far back to read: 7, 15, 30 or 90. Default 90.

No other field is taken: a body that names an app user, a project or an organisation is a 422.

Response

urlstring

The link. Send the app user's browser to it.

expires_atstring

When the link stops working, 15 minutes after it was made, in ISO 8601.

The return

statusstring

Added to return_to's query: connected or error.

connection_idstring

With connected: the new connection's id, as connections lists it.

reasonstring

With error: denied (the person cancelled or declined, or the app refused them), exchange_failed (the app's sign-in did not complete), not_configured (the app cannot be connected just now), expired (the link expired or was already used) or limit (your plan's connected app users were reached).

providerstring

The app, as you asked for it.

The return is not proof that the app connected: anyone can open return_to with any query. Confirm it with connections from your backend.

Errors

400bad request

X-Alexein-User is missing or not a usable id.

401unauthorized

The bearer is not a key this service issued.

402payment required

Your organisation has as many app users with connected apps as its plan allows. The body has detail, such as This plan connects apps for at most 25 app users. Disconnect one, or upgrade.; error: "quota_exceeded"; limit: "connections"; included, the plan's figure; and upgrade, where an Owner changes the plan. An app user who already has a connected app can still connect more. See Limits.

403forbidden

This API key only reads: ...; a personal key, whose own apps connect under My memory › Connectors; or the organisation has been closed in the console.

422invalid

An unknown field, a return_to that is not https:// (or http://localhost or http://127.0.0.1), a history_days other than 7, 15, 30 or 90, or a provider that cannot be connected, such as jira cannot be connected.

429too many requests

Past your organisation's rate limits. Retry after Retry-After seconds. See Limits.

503unavailable

Connecting apps cannot be reached just now. Retry after Retry-After seconds.

Request
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"
}
Back at return_to
https://app.example.com/settings/apps?status=connected&connection_id=6f1c2d9e-4b7a-4e3f-9a51-0c8d2e7b4f13&provider=google-gmail
https://app.example.com/settings/apps?status=error&reason=denied&provider=google-gmail