Skip to content
Connect an agent

Accounts

Make a connect token for a page

Lets a page in a browser show "connect your accounts" without holding your API key: make the token on your server, hand it to the page, and the page (with <flung-connect> from @flung.dev/connect, or its own calls) can list, connect, reconnect and disconnect accounts until it expires, from the listed origins only.

POST/v1/connect-tokens

TL;DR

QuestionAnswer
What does it do?Make a connect token for a page.
What does it need?An API key or an OAuth access token.
What does it take?A JSON body with the fields below.
What does it return?Status 201 with a body of type ConnectToken.
In the SDK?flung.connectTokens.create()
What can go wrong?401 Missing, unknown, revoked or expired API key; 422 The request failed validation; 429 Too many requests for this credential; wait for retry-after seconds. Every failure has the same error shape.

What it does

Lets a page in a browser show "connect your accounts" without holding your API key: make the token on your server, hand it to the page, and the page (with <flung-connect> from @flung.dev/connect, or its own calls) can list, connect, reconnect and disconnect accounts until it expires, from the listed origins only. Needs a full-access credential.

Example

bash
curl -X POST 'https://api.flung.dev/v1/connect-tokens' \  --header "Authorization: Bearer $FLUNG_API_KEY" \  --header 'Content-Type: application/json' \  --header "Idempotency-Key: $(uuidgen)" \  --data '{  "origins": [    "https://app.example.com"  ],  "platforms": [    "x",    "linkedin",    "bluesky"  ]}'

A successful answer looks like this:

json
{  "token": "flung_ct_eyJ3Ijoid3NfMSJ9.c2ln",  "expiresAt": "2026-11-01T09:00:00.000Z",  "origins": [    "string"  ],  "profileId": "string",  "platforms": [    "x"  ]}

Request body

The body has the type an object, with the fields below.

FieldTypeRequiredDescription
originsstring[]yesThe pages that will use the token, as origins. https only, except http://localhost and http://127.0.0.1 for trying it out.
profileIdstringnoAccounts connected with the token join this profile, and the token sees only that profile's accounts. Omit it for the whole workspace.
platformsPlatform[]noThe platforms the token may connect. Omit it for every platform.
expiresInintegernoSeconds until the token stops working. Default one hour, at most one day. minimum 60; maximum 86400; default 3600.

Responses

StatusMeaningBody
201The token.ConnectToken
401Missing, unknown, revoked or expired API key.Error
422The request failed validation.Error
429Too many requests for this credential; wait for retry-after seconds.Error

Response body

A 201 answer has the type ConnectToken.

FieldTypeRequiredDescription
tokenstringyesHand this to the page (<flung-connect token>). It can only list, connect, reconnect and disconnect accounts.
expiresAtstringyes
originsstring[]yes
profileIdstring | nullyes
platformsarray | nullyes

See also

DocWhy
API referenceEvery endpoint
SchemasEvery request and response type
ErrorsEvery error code and what to do about it