FriendChise Docs

Users and Accounts

Endpoints for the current user profile, organization membership list, and account deletion

Get current user

GET /api/mobile/me

Returns the profile of the currently authenticated user. Used by the mobile app after sign-in to confirm identity and load the user's name and avatar.

Authentication

Bearer token required.

Response

{
  "user": {
    "id": "usr_01abc",
    "name": "Alex Chen",
    "email": "alex.chen@example.com",
    "image": "https://lh3.googleusercontent.com/..."
  }
}

Errors

StatusReason
401Token missing or invalid
404Authenticated user ID has no database record

List user organizations (mobile)

GET /api/mobile/me/organizations

Returns all organizations the authenticated user is a member of, ordered by name. Used by the mobile app to populate the org picker.

Authentication

Bearer token required.

Response

{
  "organizations": [
    {
      "id": "org_01abc",
      "name": "Downtown Doughnuts",
      "image": "https://cdn.friendchise.app/orgs/..."
    }
  ]
}

image is a resolved public URL, or null if the org has no image set.

Errors

StatusReason
401Token missing or invalid

Get default organization (mobile)

GET /api/mobile/me/organization

Returns the user's first organization by name. Used by the mobile app when no explicit org has been selected yet.

Authentication

Bearer token required.

Response

{
  "organization": {
    "id": "org_01abc",
    "name": "Downtown Doughnuts"
  },
  "orgId": "org_01abc"
}

Errors

StatusReason
401Token missing or invalid
404User has no org memberships

List user organizations (web)

GET /api/me/organizations

Returns a paginated list of organizations for the current web session user. Supports search and active-org resolution.

Authentication

Session cookie (web only).

Query parameters

ParamTypeDefaultMaxDescription
pageinteger1Page number
limitinteger24100Items per page
searchstringFilter orgs by name
activeOrgIdstringOrg ID to resolve alongside the paginated list

Response

{
  "organizations": [
    { "id": "org_01abc", "name": "Downtown Doughnuts", "image": null }
  ],
  "activeOrganization": {
    "id": "org_01abc",
    "name": "Downtown Doughnuts",
    "image": null
  },
  "totalCount": 3,
  "totalPages": 1,
  "page": 1,
  "pageSize": 24,
  "search": ""
}

If no session is present, returns an empty result (totalCount: 0) rather than a 401.


Delete account

DELETE /api/account/delete

Permanently deletes the authenticated user's account after confirmation.

Authentication

Bearer token or session cookie.

Request body

{
  "confirmText": "Alex Chen"
}

confirmText must exactly match the user's display name if one exists, otherwise their email address. The comparison is case-sensitive and is only used as the deletion confirmation check.

Response

{ "ok": true }

Errors

StatusReason
400confirmText is missing from the request body
400confirmText does not match the user's name or email
403Session-cookie request did not come from the same origin
401Not authenticated
404User record not found
500Unexpected error during deletion

Important notes

  • Deletion is permanent and irreversible.
  • Any organizations the user owns remain in place, but their ownerId is cleared before the account row is deleted.
  • The user's memberships are converted to bot accounts before deletion.
  • Session-cookie requests must come from the same origin; bearer-token requests are allowed without the browser-origin check.