Skip to content
Create a connect session

Create a connect session

Create a hosted flow for a user to authorize an integration or enter its API-key credentials.

POST/api/v1/users/:userId/connect-sessions

Open the returned connectUrl in the user’s browser. When they return, read the connect session and confirm it if its status is awaiting_confirmation.

Request#

TypeScript
const response = await fetch("https://api.smallworld.sh/api/v1/users/customer_123/connect-sessions", {
  method: "POST",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
  "integration": "github",
  "redirectUrl": "https://app.example.com/settings/integrations",
  "requireConfirmation": true
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();

Use your server-side apiKey. Replace the example IDs.

Path parameters#

userIdstringrequired

Your application's user ID, URL-encoded. At most 512 characters, with no surrounding whitespace or null bytes. Encode the IDs . and .. as %2E and %2E%2E: curl sends these as written, but JavaScript's fetch removes them even when encoded.

Request body#

integrationstringrequired

The key from GET /integrations.

redirectUrlstring | null

Optional absolute URL, at most 2048 characters. HTTPS is required; HTTP is allowed only for loopback development. No credentials or fragment.

requireConfirmationboolean

Defaults to false. true holds credentials until your backend confirms the returning signed-in user; requires redirectUrl.

Responses#

A new hosted attempt was created. connectUrl is returned only here; navigate the user's browser to it.

201 response
{
  "id": "01995e58-1000-7000-8000-009ea3dcd8fc",
  "integration": "github",
  "userId": "customer_123",
  "groupId": null,
  "status": "pending",
  "requireConfirmation": true,
  "redirectUrl": "https://app.example.com/settings/integrations",
  "error": null,
  "connection": null,
  "expiresAt": "2026-10-10T12:30:00.000Z",
  "createdAt": "2026-10-10T12:00:00.000Z",
  "updatedAt": "2026-10-10T12:00:00.000Z",
  "completedAt": null,
  "connectUrl": "https://api.example.com/api/integrations/connect/one-time-example-token"
}
More about this endpoint

Public user IDs are identifiers from your application, not Smallworld's internal database IDs. Derive them from your authenticated user on your backend.

An unknown userId is created automatically. A new session cancels earlier pending connection attempts for this user and integration with connect_session_superseded.

The connection belongs to the user. To connect one account that a whole group shares, use POST /groups/:groupId/connect-sessions.

Send the user's browser to connectUrl immediately. Treat the link as sensitive; it is returned only on creation.

The hosted page follows the workspace's current OAuth or API-key setup. Connections apply across the user's sessions in every World that allows the integration.

Redirect query parameters (connectSessionId, status, and possible error) are hints. Read the session from your backend before relying on them.

Sessions expire after 30 minutes by default. Use the returned expiresAt. With requireConfirmation, the session waits at awaiting_confirmation before credentials become active.