SwiftGoma.SwiftGoma

Search endpoints

Jump to any API endpoint by name, method, or path

Guide

Authentication

The SwiftGoma API uses short-lived access tokens paired with longer-lived refresh tokens. Accounts can sign in with a password, a one-time email code, a passkey, or Google — and can optionally add TOTP-based two-factor authentication on top of any of them. Every endpoint mentioned on this page lives under https://api.swiftgoma.com/api/v1/auth.

Access and refresh tokens

A successful sign-in produces two tokens. The access token is short-lived and sent with every authenticated request. The refresh token lives much longer and is only used to obtain a new access token via POST /refresh-token once the access token expires. Neither token is ever returned in a way your client needs to parse manually on web — see below.

Web vs. mobile sessions

Browser and mobile clients receive their tokens differently, and every login and session endpoint behaves accordingly based on one header:

// Web (browser)
// Access & refresh tokens are set as httpOnly cookies automatically.
// Just send credentials on every request:
fetch(url, { credentials: "include" });

// Mobile
// Send this header on every request, and manage the tokens yourself:
fetch(url, { headers: { "x-client-type": "mobile" } });

Why the difference?

Browsers can store httpOnly cookies safely and send them automatically, which also protects the tokens from being read by client-side JavaScript. Mobile apps have no cookie jar shared with a browser, so they receive the tokens directly in the response body and are responsible for storing them securely (e.g. Keychain / Keystore).

Ways to sign in

All four methods converge on the same result — a session for web, or a token pair for mobile — and all four can be intercepted by a two-factor challenge if the account has TOTP enabled.

MethodStarts withFinishes with
Passwordno request neededPOST /login/password
Passwordless email codePOST /login/request-otpPOST /login/verify-otp
Passkey (WebAuthn)POST /passkey/login/optionsPOST /passkey/login/verify
GoogleGoogle ID token from client SDKPOST /login/google

Password login

  1. 1

    Send email and password

    POST /login/password with email and password.
  2. 2

    Handle the result

    If the account doesn't have 2FA enabled, you get a session immediately. If it does, you get a pendingToken instead — see Two-factor authentication below.

Passwordless email code

  1. 1

    Request a code

    POST /login/request-otp with just the email. The response is identical whether or not the address is registered, so this step never reveals account existence.
  2. 2

    Verify the code

    The user receives a code by email. Submit it to POST /login/verify-otp along with the email.

Passkey

  1. 1

    Get a challenge

    POST /passkey/login/options with the email returns a WebAuthn assertion challenge and a challengeId.
  2. 2

    Resolve it with the browser

    Pass the challenge to navigator.credentials.get() in the browser.
  3. 3

    Verify the assertion

    Send the browser's response and the challengeId to POST /passkey/login/verify.

Two-factor authentication

When an account has TOTP enabled, every login method above returns this instead of a session:

{
  "success": true,
  "data": {
    "requiresTotp": true,
    "pendingToken": "mfa_9f8e7d6c5b4a3210"
  }
}

Prompt the user for their 6-digit authenticator code (or an unused backup code), then finish with POST /login/totp, passing the pendingToken.

Turning it on

  1. 1

    Start setup

    POST /totp/setup (authenticated) returns a secret and a QR code to scan into an authenticator app.
  2. 2

    Confirm it

    POST /totp/confirm with the first 6-digit code turns 2FA on and returns a one-time set of backup codes — show these to the user immediately, they aren't retrievable later.

Backup codes

Each backup code works once, as a stand-in for a TOTP code, for the exact situations a user has lost their authenticator device. POST /totp/regenerate-backup-codes invalidates the old set and issues a new one.

Password management

SituationEndpoint
Forgot passwordPOST /password/forgot then POST /password/reset
Change known passwordPOST /password/update
Set a first password (Google/passkey-only accounts)POST /password/create
Both resetting and changing a password revoke other active sessions on the account, as a security precaution.

Session management

A signed-in user can inspect and manage their own active sessions:

ActionEndpoint
List active sessionsGET /sessions
Sign out one deviceDELETE /sessions/:sessionId
Sign out everywherePOST /logout-all

Rate limits

Auth endpoints are grouped into tiers with different limits, tightest where the risk of abuse is highest:

TierApplies toBehavior
Credential checklogin/password, login/verify-otp, password/reset, totp confirm/disableTightest limits, scoped by IP and by account. Repeated failures feed automatic IP blocking.
Request / initiationlogin/request-otp, password/forgot, resend-verificationLimited per IP and per account, with a resend cooldown, to prevent inbox or SMS flooding.
Account creationcreate-account, register/google, login/googleTightly limited per IP, and screened for automated traffic before hitting the limiter.
Sessionme, logout, sessions, refresh-tokenLooser limits — these don't touch credentials.
Authenticated actiontotp/setup, passkey registration, password/createRequires a valid session already; moderate limits.

Error handling

Errors share one shape:

{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Identifiants invalides."
  }
}

Enumeration-safe by design

POST /login/request-otp and POST /password/forgot always return the same generic success message, whether or not the email is registered — the API deliberately doesn't reveal which emails have accounts.
Browse the Authentication endpoints in the API Reference