Authentication

How to authenticate your users and call the LiveSwitch API from your own application.

LiveSwitch uses OAuth 2.0 for authentication. Every API request needs a Bearer access token in the Authorization header — this page walks through getting one.

📘

Using these docs

This documentation site automatically creates a token from your logged-in LiveSwitch account, so you can try API calls directly from these pages. That token is for exploring the docs only — never use it in your own application. Follow the steps below to authenticate real users of your app.

What you'll need

A Developer AppContains your client_id, client_secret, and whitelisted callback URL(s). Email [email protected] with subject "Create a developer app" and include your callback URL(s), app name/purpose, and primary developer contact. Mention if you need separate Staging and Production apps.
A LiveSwitch User AccountThe account your app authenticates as. If you don't have one, contact [email protected] or start a free trial. Working on behalf of an existing customer? Ask them to provide you with an account.
An access tokenWhat you get at the end of the flow below — put it in Authorization: Bearer {access_token} on every request.

How the login flow works

  1. Your app sends the user to a LiveSwitch login URL, built from your client_id and callback URL.
  2. The user logs in — seeing your Developer App's name — and authorizes your app.
  3. LiveSwitch redirects back to your callback URL with either a code (Code Exchange) or an access_token (Token Exchange), depending on which flow you use.

Two flows are available:

Code ExchangeToken Exchange
Best forApps with a backendBrowser-only apps (SPAs) with no backend
Needs client_secretYesNo
Refresh without re-loginYes, via refresh_tokenNo — re-redirect through login
SecurityMore secureLess secure

1. Send the user to the login URL

GET https://id.liveswitch.com/authorize
  ?response_type=code
  &client_id={your_client_id}
  &redirect_uri={your_whitelisted_callback}
  &scope=contacts contacts.write conversations conversations.write documents email me offline_access openid organizations profile projects projects.write recordings tags tags.write webhooks webhooks.write
  &audience=https://public-api.production.liveswitch.com/

2. Exchange the returned code for tokens

POST https://id.liveswitch.com/oauth/token
Content-Type: application/json

{
  "grant_type": "authorization_code",
  "code": "...",
  "client_id": "...",
  "client_secret": "...",
  "redirect_uri": "..."
}

Response:

{
  "access_token": "eyJhbGciOi...",
  "refresh_token": "v1.MjM0NTY3...",
  "expires_in": 3600,
  "token_type": "Bearer"
}

access_token goes in the Authorization: Bearer header on every API call. Save the refresh_token somewhere durable — you'll need it in the next step, and you won't get a new one until you use it.

3. Refresh when the access token expires

Don't wait for a request to fail with 401 — track expires_in and refresh a bit before it lapses (or refresh reactively on a 401, then retry the original request once). Call the same token endpoint, with a different grant type:

POST https://id.liveswitch.com/oauth/token
Content-Type: application/json

{
  "grant_type": "refresh_token",
  "refresh_token": "v1.MjM0NTY3...",
  "client_id": "{your_client_id}",
  "client_secret": "{your_client_secret}"
}

The response is the same shape — a fresh access_token and a fresh refresh_token. Overwrite your saved refresh_token with the new one every time — the previous one is invalidated as soon as you use it.

🚧

Callback URLs must be whitelisted

The redirect_uri you pass must exactly match a callback URL registered on your Developer App, or the login will fail. This prevents malicious actors from hijacking tokens. Email [email protected] with your Client ID and the callback URL if you need to add or change one.

Scopes

Request only the scopes your app needs.

ScopeGrants
openid, profile, emailBasic identity info about the logged-in user
offline_accessIssues a refresh_token (Code Exchange only)
organizationsRead the user's organization info
conversations / conversations.writeRead / create & update Conversations (sessions)
projects / projects.writeRead / create & update Projects
contacts / contacts.writeRead / create & update Contacts
recordings, documentsRead recordings, photos, and documents
tags / tags.writeRead / manage tags
webhooks / webhooks.writeRead / manage webhook subscriptions — requires org admin rights
sparks / sparks.write, spark-templatesRead / run Sparky AI reports — see the Sparky AI Reports guide

Where to go next


Questions? Email [email protected] and we'll get back to you right away.


Did this page help you?