> ## Documentation Index
> Fetch the complete documentation index at: https://docs.helpgenie.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Profiles

> Manage user profiles including account information, subscription details, and team associations.

All requests use a single endpoint: `POST https://api.helpgenie.ai/v1` with `resource: "profiles"`.

## Access control

| Action | Regular user | Admin |
| - | - | - |
| `all` | No | Yes |
| `list` | No | Yes |
| `get` | Own profile only | Any profile |
| `create` | No | Yes |
| `update` | Own profile only | Any profile |
| `delete` | Own profile only | Any profile |
| `check-timezone` | Yes (own profile) | Yes |
| `generate-sso-token` | Yes (own session) | Yes (+ impersonation) |
| `generate-sync-consent-link` | Yes (own email) | Yes (any email) |
| `usage-summary` | Yes (own profile) | Yes |
| `list-auth-sessions` | Yes (own signed-in session only) | No impersonation |
| `revoke-auth-session` | Yes (own signed-in session only) | No impersonation |

> [!NOTE]
>
> Admin endpoints require a role starting with `internal_` (e.g. `internal_admin`). Non-admin users attempting admin-only actions receive a `403 Forbidden` response.

### `role` values

| Value | Description |
| - | - |
| `"business"` | Business owner -- can create and manage agents, view leads, and access all standard features |
| `"consumer"` | End user -- can talk to agents and interact with consumer-facing features |
| `"internal_admin"` | Full platform access -- can manage all users, agents, marketplace listings, and system settings |

> [!NOTE]
>
> Profile mutations (`create`, `update`, `delete`) are automatically logged to the `activities` table as `user_action` events. Update actions include the list of changed fields in the activity metadata.

***

## List all profiles (admin)

Retrieves all profiles with complete joined data including subscriptions, call purchases, and phone subscriptions.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"all"`

**data** `object`

**properties**

**limit** `number`

Results per page. Range: 1-100. Default: `50`.

**offset** `number`

Pagination offset. Default: `0`.

**filters** `object`

**properties**

**searchTerm** `string`

Search in `full_name` or `email`.

**role** `string`

Filter by role (exact match): `"business"`, `"consumer"` or `"internal_admin"`.

**teamId** `number`

Filter by team ID.

**hasSubscription** `boolean`

Filter profiles with active subscriptions.

**needsAttention** `boolean`

When `true`, return only accounts with unbilled purchased phone numbers — a paying, non-admin account whose number has no phone subscription, usually because it was added during a trial.

**sortBy** `string`

Column to sort by. One of: `"created_at"` (default), `"email"`, `"full_name"`.

**sortOrder** `string`

Sort direction. `"asc"` or `"desc"`. Default: `"desc"`.

### Response

**success** `boolean`

**data** `object`

**properties**

**profiles** `object[]`

Array of full profile objects with joined relations. See [profile object](#profile-object). Each profile also carries `unbilled_phone_numbers` — the account's purchased numbers with no phone subscription (empty when none). Each entry has the same shape as a `numbers` item from [`billing` → `phones`](https://docs.helpgenie.ai/api-reference/billing#get-phone-billing), with `billing` always `"unbilled"`. Each profile also carries `genie_counts` — `{ active, eligible }`, where `active` is the number of the account's genies that are switched on and `eligible` excludes genies deactivated on purpose. Compare them with the account's seats to spot a mismatch.

**count** `number`

**limit** `number`

**offset** `number`

**attentionCount** `number`

Number of accounts with unbilled purchased phone numbers, ignoring the other filters.

```typescript Example request theme={null}
const response = await ApiService.invoke<{
  profiles: Profile[];
  count: number;
  limit: number;
  offset: number;
  attentionCount: number;
}>({
  resource: "profiles",
  action: "all",
  data: {
    limit: 100,
    offset: 0,
    filters: {
      role: "internal_admin",
    },
  },
});
```

***

## List basic profiles (admin)

Retrieves a paginated list of profiles with basic fields only, optimized for lists and dropdowns.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"list"`

**data** `object`

**properties**

**limit** `number`

Results per page. Range: 1-200. Default: `50`.

**offset** `number`

Pagination offset. Default: `0`.

**filters** `object`

**properties**

**searchTerm** `string`

Search in `full_name` or `email`.

**role** `string`

Filter by role (exact match): `"business"`, `"consumer"` or `"internal_admin"`.

**teamId** `number`

Filter by team ID.

### Response

**success** `boolean`

**data** `object`

**properties**

**profiles** `object[]`

**Basic profile fields**

**id** `string`

**full\_name** `string | null`

**email** `string | null`

**role** `string | null`

**avatar\_url** `string | null`

**team\_id** `number | null`

**created\_at** `string`

**updated\_at** `string`

**count** `number`

**limit** `number`

**offset** `number`

```typescript Example request theme={null}
const response = await ApiService.invoke<{
  profiles: Profile[];
  count: number;
}>({
  resource: "profiles",
  action: "list",
  data: {
    limit: 50,
    filters: {
      searchTerm: "john@example.com",
    },
  },
});
```

***

## Get a profile

Retrieves a single profile with complete details including subscriptions and team data. Users can only access their own profile; admins can access any profile.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"get"`

**id** `string` *required*

The profile ID (user UUID).

### Response

**success** `boolean`

**data** `object`

**properties**

**profile** `object`

Full profile object with all joined relations. See [profile object](#profile-object).

```typescript Example request theme={null}
const { user } = await supabase.auth.getUser();
const response = await ApiService.invoke<{ profile: Profile }>({
  resource: "profiles",
  action: "get",
  id: user.id,
});

const subscriptions = response?.profile?.call_purchases;
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "get",
    "id": "d4f8e2a1-5b3c-4e9f-a1b2-c3d4e5f67890"
  }'
```

***

## Create a profile (admin)

Creates a new user profile. There are two ways to call it:

* **Attach to an existing account** -- send `id` set to the UUID of an existing sign-in account.
* **Create the account too** -- send `email` with `password`, or `email` with `send_welcome_email: true` (no `id` needed). The sign-in account is created first with its email already confirmed, and its UUID becomes the profile `id`. Without a `password`, the account gets a random one that the user replaces through the set-password link in the welcome email. Fields you leave out keep the defaults the new account was given; they are not reset to empty. If saving the profile fails, the new sign-in account is removed again.

No email is sent to the user unless `send_welcome_email` is `true`, so accounts can be set up quietly.

Any field not listed below is ignored.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"create"`

**data** `object` *required*

**properties**

**id** `string`

UUID of an existing sign-in account to attach the profile to. Required unless `email` is sent with `password` or `send_welcome_email: true`.

**email** `string`

Profile email. Sent together with `password` or `send_welcome_email: true`, it also creates the sign-in account. When present, the new profile is also added to the customer contact list (best-effort -- a failure there does not fail the request).

**password** `string`

Sent together with `email`, creates the sign-in account first. The email is marked as confirmed.

**send\_welcome\_email** `boolean` (default: false)

With `email`, sends the welcome email with a set-password link once the account is created. Without `password`, the account is created with a random password the user replaces via that link. Leave `false` to create the account without emailing the user.

**full\_name** `string`

**role** `string` (default: business)

See [`role` values](#role-values).

**avatar\_url** `string`

**phone\_number** `string`

**phone\_country\_code** `string`

**address\_line1** `string`

**address\_line2** `string`

**city** `string`

**state\_province** `string`

**country** `string`

Two-letter ISO 3166-1 country code, e.g. `"NZ"`. A full country name (e.g. `"New Zealand"`) is converted to its code and, when no `country_name` is sent, kept as `country_name`. A name that cannot be matched leaves `country` empty.

**country\_name** `string`

Full country name. When `country` is not sent, `country` is filled from this name.

**postal\_code** `string`

**company\_name** `string`

**job\_title** `string`

**date\_of\_birth** `string`

**timezone** `string`

**preferred\_language** `string`

**billing\_currency** `string`

One of `USD`, `NZD`, `AUD`, `GBP`, `EUR` (any case). An unsupported value is ignored, the rest of the profile still saves, and the response includes a `warnings` entry.

**stripe\_id** `string`

**hubspot\_id** `string`

Overwritten with the customer contact ID when the contact sync succeeds.

**team\_id** `number`

**marketplace\_creator\_bio** `string`

**marketplace\_creator\_verified** `boolean`

**impersonatedUserId** `string`

Admin only. Records the activity log entry against this user. It does not change the created profile's `id`.

### Response (status 201)

**success** `boolean`

**data** `object`

**properties**

**profile** `object`

The created profile with joined data. See [Profile object](#profile-object).

**user** `object`

Present only when the sign-in account was created by this request. The new account record, including its `id` and `email`.

**welcome\_email\_sent** `boolean`

Present only when the sign-in account was created with `send_welcome_email: true`. `false` if the welcome email could not be sent; the profile is still created.

**warnings** `string[]`

Present only when a field was ignored, e.g. an unsupported `billing_currency`.

```typescript Example request theme={null}
// Attach a profile to an existing account
const response = await ApiService.invoke<{ profile: Profile }>(
  {
    resource: "profiles",
    action: "create",
    data: {
      id: "auth-user-uuid-here",
      full_name: "Jane Smith",
      email: "jane@example.com",
      role: "business",
    },
  },
  201
);

// Create the sign-in account and profile together
const created = await ApiService.invoke<{ profile: Profile; user: { id: string; email: string } }>(
  {
    resource: "profiles",
    action: "create",
    data: {
      email: "jane@example.com",
      password: "a-strong-password",
      full_name: "Jane Smith",
    },
  },
  201
);

// Create the account and let the user set their own password from the welcome email
const invited = await ApiService.invoke<{
  profile: Profile;
  user: { id: string; email: string };
  welcome_email_sent: boolean;
}>(
  {
    resource: "profiles",
    action: "create",
    data: {
      email: "jane@example.com",
      full_name: "Jane Smith",
      send_welcome_email: true,
    },
  },
  201
);
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "create",
    "data": {
      "email": "jane@example.com",
      "password": "a-strong-password",
      "full_name": "Jane Smith"
    }
  }'
```

***

## Update a profile

Updates an existing profile. Users can only update their own profile; admins can update any profile. This is a partial update -- only include the fields you want to change.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"update"`

**id** `string` *required*

The profile ID (user UUID).

**data** `object` *required*

Any key not listed below is rejected with a validation error. `country`, `country_name` and `billing_currency` are normalized the same way as on `create`.

**properties**

**full\_name** `string`

**avatar\_url** `string`

**phone\_number** `string`

**phone\_country\_code** `string`

**address\_line1** `string`

**address\_line2** `string`

**city** `string`

**state\_province** `string`

**country** `string`

**country\_name** `string`

**postal\_code** `string`

**company\_name** `string`

**job\_title** `string`

**date\_of\_birth** `string`

**timezone** `string`

**preferred\_language** `string`

**socials** `number`

Number of connected social accounts.

**email** `string`

Admin only.

**role** `string`

Admin only. Only admins can change a profile's role after sign-up.

**team\_id** `number`

Admin only.

**billing\_currency** `string`

Admin only.

**stripe\_id** `string`

Admin only.

**hubspot\_id** `string`

Admin only.

**marketplace\_creator\_bio** `string`

Admin only.

**marketplace\_creator\_verified** `boolean`

Admin only.

**password** `string`

Admin only. Sets a new sign-in password. Minimum 6 characters.

> [!WARNING]
>
> Auth-context keys such as `adminMode` and `impersonatedUserId` are also rejected. Because admin API keys add `adminMode` to `data` automatically, `update` currently fails when called with an admin API key.

### Response

**success** `boolean`

**data** `object`

**properties**

**profile** `object`

The updated profile with joined data.

**warnings** `string[]`

Present only when a field was ignored, e.g. an unsupported `billing_currency`.

```typescript Example request theme={null}
const response = await ApiService.invoke<{ profile: Profile }>({
  resource: "profiles",
  action: "update",
  id: userId,
  data: {
    full_name: "John Doe",
    timezone: "America/New_York",
    company_name: "Acme Corp",
  },
});
```

***

## Delete a profile

Permanently deletes a profile. Users can only delete their own profile; admins can delete any profile.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"delete"`

**id** `string` *required*

The profile ID (user UUID).

### Response

**success** `boolean`

**data** `object`

**properties**

**success** `boolean`

**message** `string`

> [!WARNING]
>
> This permanently deletes the profile record, the user's sign-in account, and cancels any active subscriptions.

Before the profile is deleted, the mailbox of every genie the user owns is permanently removed. The profile is kept in place, and the request returns an `INTERNAL_ERROR`, when:

* one or more mailboxes can't be removed — the error names the affected genies. Try again.
* the account has too many genies to clear in one call — the error reports how many mailboxes were removed. Call `delete` again to continue; each call picks up where the last one stopped.

```typescript Example request theme={null}
const response = await ApiService.invoke<{
  success: boolean;
  message: string;
}>({
  resource: "profiles",
  action: "delete",
  id: "user-uuid",
});
```

***

## Check timezone

Checks the authenticated user's profile for a timezone value. If the timezone is not set, auto-detects it from the server and saves it to the profile. No-op if timezone is already set.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"check-timezone"`

### Response

**success** `boolean`

**data** `object`

**properties**

**success** `boolean`

```typescript Example request theme={null}
await ApiService.invoke({
  resource: "profiles",
  action: "check-timezone",
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "action": "check-timezone" }'
```

***

## Get inbox filters

Returns the filters the authenticated user last used on the Conversations inbox, so the inbox can reopen the way they left it.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"get-inbox-filters"`

### Response

**success** `boolean`

**data** `object`

**properties**

**filters** `object | null`

The saved filters, or `null` when the user has never saved any. Same shape as the `filters` returned by [Save inbox filters](#save-inbox-filters).

```typescript Example request theme={null}
const response = await ApiService.invoke<{
  filters: {
    agentId: string | null;
    channel: string | null;
    viewId: string | null;
    timeRange: string | null;
    queue: string | null;
  } | null;
}>({
  resource: "profiles",
  action: "get-inbox-filters",
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "action": "get-inbox-filters" }'
```

```json Example response theme={null}
{
  "success": true,
  "data": {
    "filters": {
      "agentId": null,
      "channel": "phone",
      "viewId": "view-uuid",
      "timeRange": "30d",
      "queue": null
    }
  }
}
```

***

## Save inbox filters

Remembers the authenticated user's Conversations inbox filters. The saved filters are replaced as a whole — any field you leave out is stored as `null`. Malformed or unknown values are stored as `null` (meaning "all") rather than rejected, so a bad value never blocks the save.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"save-inbox-filters"`

**data** `object` *required*

**properties**

**agentId** `string | null`

Selected genie UUID. `null` for all genies.

**channel** `string | null`

Selected channel. One of `"phone"`, `"web"`, `"link"`, `"app"`, `"email"`, `"meeting"`, `"slack"`, `"teams"`. `null` for all channels.

**viewId** `string | null`

Selected saved inbox view UUID. `null` for none.

**timeRange** `string | null`

Relative time range: `{value}{unit}` where unit is `h` (hours), `d` (days) or `m` (minutes), for example `"30d"`, or `"all"`.

**queue** `string | null`

Selected inbox queue: `"attention"`, `"mine"` or `"handled"`. `null` for all.

### Response

**success** `boolean`

**data** `object`

**properties**

**filters** `object`

The filters as stored, after invalid values were replaced with `null`.

**properties**

**agentId** `string | null`

**channel** `string | null`

**viewId** `string | null`

**timeRange** `string | null`

**queue** `string | null`

```typescript Example request theme={null}
await ApiService.invoke({
  resource: "profiles",
  action: "save-inbox-filters",
  data: {
    agentId: null,
    channel: "phone",
    viewId: "view-uuid",
    timeRange: "30d",
    queue: "attention",
  },
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "save-inbox-filters",
    "data": {
      "agentId": null,
      "channel": "phone",
      "viewId": "view-uuid",
      "timeRange": "30d",
      "queue": "attention"
    }
  }'
```

> [!NOTE]
>
> Returns `VALIDATION_ERROR` when `data` is missing or is not an object.

***

## List sign-in sessions

Lists the authenticated user's active sign-ins (browsers and devices), most recently active first.

> [!WARNING]
>
> Sign-ins can only be listed from the user's own signed-in browser session. API keys, service calls and admin impersonation receive `403 Forbidden`.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"list-auth-sessions"`

### Response

**success** `boolean`

**data** `object`

**properties**

**sessions** `object[]`

**properties**

**id** `string`

Session UUID. Pass this to `revoke-auth-session`.

**device** `string`

Browser and operating system, e.g. `"Chrome on macOS"`, or `"Unknown device"`.

**ip** `string | null`

IP address the session was created from.

**createdAt** `string`

ISO 8601 timestamp of the sign-in.

**lastActiveAt** `string`

ISO 8601 timestamp of the session's most recent activity.

**current** `boolean`

`true` for the session making this request.

```typescript Example request theme={null}
const response = await ApiService.invoke<{ sessions: AuthSession[] }>({
  resource: "profiles",
  action: "list-auth-sessions",
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "list-auth-sessions"
  }'
```

```json Example response theme={null}
{
  "success": true,
  "data": {
    "sessions": [
      {
        "id": "8d6c1f8e-1a2b-4c3d-9e8f-0a1b2c3d4e5f",
        "device": "Chrome on macOS",
        "ip": "203.0.113.7",
        "createdAt": "2026-11-01T09:00:00Z",
        "lastActiveAt": "2026-11-11T08:40:00Z",
        "current": true
      }
    ]
  }
}
```

***

## Revoke a sign-in session

Signs out one of the authenticated user's other sign-ins. The current session cannot be revoked this way; sign out instead.

> [!WARNING]
>
> Sign-ins can only be revoked from the user's own signed-in browser session. API keys, service calls and admin impersonation receive `403 Forbidden`.

> [!NOTE]
>
> The revoked device can no longer renew its sign-in, but the access token it already holds stays valid until it expires (about an hour).

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"revoke-auth-session"`

**data** `object` *required*

**properties**

**sessionId** `string` *required*

Session UUID from `list-auth-sessions`. Must not be the current session.

### Response

**success** `boolean`

**data** `object`

**properties**

**success** `boolean`

Returns `VALIDATION_ERROR` when `sessionId` is not a valid UUID or is the current session, and `NOT_FOUND` when the session does not exist or belongs to someone else.

```typescript Example request theme={null}
await ApiService.invoke({
  resource: "profiles",
  action: "revoke-auth-session",
  data: {
    sessionId: "8d6c1f8e-1a2b-4c3d-9e8f-0a1b2c3d4e5f",
  },
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "revoke-auth-session",
    "data": {
      "sessionId": "8d6c1f8e-1a2b-4c3d-9e8f-0a1b2c3d4e5f"
    }
  }'
```

***

## Profile object

The full profile object returned by `all`, `get`, `create`, and `update` actions.

### Core fields

**id** `string`

User UUID.

**full\_name** `string | null`

**email** `string | null`

**role** `string | null`

**avatar\_url** `string | null`

### Contact information

**phone\_number** `string | null`

**phone\_country\_code** `string | null`

### Address

**address\_line1** `string | null`

**address\_line2** `string | null`

**city** `string | null`

**state\_province** `string | null`

**country** `string | null`

**country\_name** `string | null`

**postal\_code** `string | null`

### Company

**company\_name** `string | null`

**job\_title** `string | null`

### Preferences

**date\_of\_birth** `string | null`

**timezone** `string | null`

**preferred\_language** `string | null`

**billing\_currency** `string | null`

### External IDs

**stripe\_id** `string | null`

**hubspot\_id** `string | null`

### Marketplace

**marketplace\_creator\_bio** `string | null`

**marketplace\_creator\_verified** `boolean | null`

### Team

**team\_id** `number | null`

**team** `object | null`

**properties**

**id** `number`

**name** `string`

**brand** `string`

**owner\_id** `string`

**created\_at** `string`

### Subscription

**subscription** `object | null`

**properties**

**id** `number`

**status** `string | null`

**price\_id** `string | null`

**stripe\_id** `string | null`

**quantity** `number | null`

**extra\_quantity** `number | null`

**trial\_ends\_at** `string | null`

**ends\_at** `string | null`

**created\_at** `string`

### Call purchases

**call\_purchases** `object[]`

**properties**

**id** `number`

**quantity** `number | null`

**status** `string | null`

**stripe\_subscription\_id** `string | null`

**created\_at** `string`

### Phone subscriptions

**phone\_subscriptions** `object[]`

**properties**

**id** `string`

**phone\_number** `string`

**phone\_type** `string`

**status** `string`

**stripe\_price\_id** `string`

**created\_at** `string`

### Timestamps

**created\_at** `string`

**updated\_at** `string`

***

## Generate SSO token

Generates a signed, time-limited SSO token for the authenticated user. The token is used to authenticate the user into connected suite applications without a separate login.

When impersonation parameters are provided, the token encodes the target user's identity alongside the admin's, allowing the receiving application to establish an impersonated session.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"generate-sso-token"`

**data** `object`

**properties**

**impersonatedUserId** `string`

The user ID of the account to impersonate. Must be supplied together with `adminUserId`. Both fields must be present for impersonation fields to be embedded; supplying only one has no effect.

**adminUserId** `string`

The admin user's own ID. Must be supplied together with `impersonatedUserId`.

### Response

**success** `boolean`

**data** `object`

**properties**

**token** `string`

A signed token string in the format `email={email}&ts={unix_timestamp}[&imp_uid={id}&admin_uid={id}]&sig={hmac_hex}`. Pass this value to the target suite application to authenticate the session.

```typescript Own session theme={null}
const response = await ApiService.invoke<{ token: string }>({
  resource: "profiles",
  action: "generate-sso-token",
});

const ssoToken = response?.token;
// Redirect: https://app.example.com/sso?token=<ssoToken>
```

```typescript With impersonation (admin) theme={null}
const response = await ApiService.invoke<{ token: string }>({
  resource: "profiles",
  action: "generate-sso-token",
  data: {
    impersonatedUserId: "target-user-uuid",
    adminUserId: "admin-user-uuid",
  },
});

const ssoToken = response?.token;
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/profiles \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "generate-sso-token"
  }'
```

***

## Generate sync consent link

Generates a signed, time-limited URL that redirects the user through an OAuth consent flow to authorise a third-party integration. The link is valid for a short window and is tied to the user's email address.

Regular users can only generate a link for their own email. Admins can generate a link for any user's email.

**resource** `string` *required*

Must be `"profiles"`

**action** `string` *required*

Must be `"generate-sync-consent-link"`

**data** `object` *required*

**properties**

**email** `string` *required*

The email address of the user to generate the link for. Must match the authenticated user's email unless the caller is an admin.

**connection** `string` *required*

The integration to connect. Must be one of: `"airtable"`, `"anthropic"`, `"asana"`, `"github-app"`, `"google-calendar"`, `"google-sheet"`, `"hubspot"`, `"simpro"`, `"slack"`, `"supabase"`, `"xero"`.

### Response

**success** `boolean`

**data** `object`

**properties**

**url** `string`

A signed consent URL. Redirect the user to this URL to complete the integration authorisation flow. The URL includes HMAC-verified query parameters (`email`, `ts`, `sig`, `connection`) and is time-limited.

```typescript Own account theme={null}
const response = await ApiService.invoke<{ url: string }>({
  resource: "profiles",
  action: "generate-sync-consent-link",
  data: {
    email: "user@example.com",
    connection: "slack",
  },
});

// Redirect the user to response?.url to complete authorisation
const consentUrl = response?.url;
```

```typescript Another user (admin only) theme={null}
const response = await ApiService.invoke<{ url: string }>({
  resource: "profiles",
  action: "generate-sync-consent-link",
  data: {
    email: "customer@example.com",
    connection: "hubspot",
  },
});

const consentUrl = response?.url;
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1 \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "resource": "profiles",
    "action": "generate-sync-consent-link",
    "data": {
      "email": "user@example.com",
      "connection": "google-calendar"
    }
  }'
```

***

## Usage summary

Returns a usage summary for the profile (calls, leads, conversations, etc.).

**action** `string` *required*

`usage-summary`

**id** `string`

Profile UUID. Defaults to the authenticated user. Admins may pass any profile ID.

***

## Activity logging

Profile mutations are logged to the `activities` table:

| Action | Activity type | Action logged |
| - | - | - |
| Create | `user_action` | `profile_created` |
| Update | `user_action` | `profile_updated` (includes `updated_fields` in metadata) |
| Delete | `user_action` | `profile_deleted` |

***

## Error responses

| Status | Code | Description |
| - | - | - |
| 400 | `VALIDATION_ERROR` | Profile ID not provided |
| 401 | `UNAUTHORIZED` | Invalid or missing authentication token |
| 403 | `FORBIDDEN` | Non-admin accessing admin-only action, or user accessing another user's profile |
| 404 | `NOT_FOUND` | Profile does not exist |
| 500 | `INTERNAL_ERROR` | Database operation failed |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.