> ## 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.

# Genie Access

> Manage access control for private Genies — create shareable access links, grant direct user access, and handle inbound access requests.

Genie Access gives you fine-grained control over who can interact with a private Genie. Access is tracked in two ways:

* **Access grants** — tokenised links with optional use-count limits and expiry dates, shareable with anyone.
* **Agent users** — direct per-user access records tied to a specific HelpGenie account.
* **Access password** — one shared password per private Genie. Visitors who enter it on the Genie's page receive an access token that lasts 90, 180 or 365 days.

When a visitor requests access to a private Genie, an `agent_access_requests` record is created and the Genie owner can approve or deny it via `resolve`.

***

## Actions

### `all`

Returns all users who have been granted direct access to a Genie.

**Parameters**

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Genie UUID (passed as request ID) |

**Response**

```json theme={null}
{
  "users": [
    {
      "agent_id": "agent-uuid",
      "user_id": "user-uuid",
      "granted_by": "owner-uuid",
      "expires_at": null,
      "created_at": "2024-01-01T00:00:00Z",
      "profile": { "id": "user-uuid", "full_name": "Jane Doe", "email": "jane@example.com", "avatar_url": null }
    }
  ]
}
```

***

### `list`

Returns access grant links (token-based access, not per-user). When no Genie is specified, returns grants for all genies you own.

**Parameters**

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | No | Genie UUID (passed as request ID). Filters results to this genie. |
| `data.agentId` | string | No | Alternative to `id` — Genie UUID passed in the request body. |

When neither `id` nor `data.agentId` is provided, non-admin users receive grants for all genies they own. Admin users receive all grants across the platform.

**Response**

```json theme={null}
{
  "grants": [
    {
      "id": 1,
      "agent_id": "agent-uuid",
      "max_uses": 10,
      "use_count": 3,
      "expires_at": "2025-01-01T00:00:00Z",
      "last_used_at": "2024-06-01T00:00:00Z",
      "granted_by": "owner-uuid",
      "created_at": "2024-01-01T00:00:00Z",
      "label": "ab12cd",
      "token": "64-char-token"
    }
  ]
}
```

`token` is omitted for expired grants. Tokens issued by the Genie's access password are not included — use `password` to see how many are active.

***

### `list-team-access`

Returns direct per-user access records for a Genie, with profile data for each user.

**Parameters**

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Genie UUID (passed as request ID) |

**Response**

```json theme={null}
{
  "access": [
    {
      "agent_id": "agent-uuid",
      "user_id": "user-uuid",
      "granted_by": "owner-uuid",
      "expires_at": null,
      "created_at": "2024-01-01T00:00:00Z",
      "profile": { "id": "user-uuid", "full_name": "Jane Doe", "email": "jane@example.com", "avatar_url": null }
    }
  ]
}
```

***

### `create`

Creates a shareable access link for a private Genie.

**id** `string` *required*

Genie UUID (passed as request ID).

**max\_uses** `number`

Maximum number of times the link can be used. Defaults to `0` (unlimited).

**expires\_at** `string`

ISO 8601 expiry datetime for the link. Omit for a link that never expires.

**Response** — `201`

```json theme={null}
{
  "grant": {
    "id": 1,
    "agent_id": "agent-uuid",
    "max_uses": 0,
    "use_count": 0,
    "expires_at": null,
    "granted_by": "owner-uuid",
    "created_at": "2024-01-01T00:00:00Z",
    "token": "64-char-token-shown-only-once"
  }
}
```

***

### `invite`

Sends email invitations to a batch of addresses. Each recipient gets a unique, one-use access link. If the email matches an existing HelpGenie account, that user is also added directly to the Genie's access list. Up to 50 emails per call.

**agentId** `string` *required*

Genie UUID to invite people to.

**emails** `string[]` *required*

List of email addresses to invite. Maximum 50. Invalid or duplicate addresses are silently ignored.

**expires\_at** `string`

ISO 8601 expiry datetime for the access links. Omit for links that never expire.

**campaignId** `string`

Optional idempotency key for the invite batch. If omitted, one is generated automatically. Re-sending with the same `campaignId` skips already-delivered addresses.

**Response**

```json theme={null}
{
  "campaignId": "campaign-uuid",
  "invited": [
    { "email": "user@example.com", "sent": true, "deliveredNow": true, "state": "sent" }
  ]
}
```

Each item in `invited` contains the email, whether the message was sent in this request (`deliveredNow`), and a `state` of `"sent"`, `"skipped"` (already delivered), or `"unknown"` (delivery state unconfirmed).

***

### `update`

Updates an existing access grant (use limit or expiry).

**Parameters**

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Grant ID (numeric, passed as request ID) |
| `max_uses` | number | No | New maximum use count |
| `expires_at` | string \| null | No | New expiry datetime, or `null` to remove expiry |

**Response**

```json theme={null}
{
  "grant": { /* updated grant row */ }
}
```

***

### `delete`

Deletes an access grant link. Anyone using the link after deletion will lose access.

**Parameters**

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Grant ID (numeric, passed as request ID) |

**Response**

```json theme={null}
{ "deleted": true }
```

***

### `update-user`

Updates the expiry date for a specific user's direct access to a Genie.

**agentId** `string` *required*

Genie UUID.

**userId** `string` *required*

User UUID whose access to update.

**expires\_at** `string`

New expiry datetime (ISO 8601), or `null` to make access permanent.

**Response**

```json theme={null}
{
  "agentUser": {
    "agent_id": "agent-uuid",
    "user_id": "user-uuid",
    "granted_by": "owner-uuid",
    "expires_at": "2025-01-01T00:00:00Z",
    "created_at": "2024-01-01T00:00:00Z"
  }
}
```

***

### `delete-user`

Revokes a specific user's direct access to a Genie.

**agentId** `string` *required*

Genie UUID.

**userId** `string` *required*

User UUID to revoke access for.

**Response**

```json theme={null}
{ "deleted": true }
```

***

### `requests`

Returns all inbound access requests for a Genie (visitors who clicked "Request access").

**Parameters**

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Genie UUID (passed as request ID) |

**Response**

```json theme={null}
{
  "requests": [
    {
      "id": "request-uuid",
      "agent_id": "agent-uuid",
      "email": "requester@example.com",
      "requested_at": "2024-01-01T00:00:00Z",
      "resolved_at": null,
      "solution": null,
      "created_at": "2024-01-01T00:00:00Z"
    }
  ]
}
```

***

### `resolve`

Approves or denies an access request. On approval, the requester receives an email with an access link and (if they have a HelpGenie account) is added to the Genie's direct-access list.

**requestId** `string` *required*

Access request ID (numeric, from the `requests` action).

**solution** `string` *required*

`"approved"` or `"denied"`.

**expires\_at** `string`

Expiry for the granted access (approval only). Omit for permanent access.

**Response**

```json theme={null}
{
  "resolved": true,
  "solution": "approved"
}
```

***

### `password`

Returns the access-password status of a private Genie. The password is stored hashed and is never returned.

**id** `string` *required*

Genie UUID (passed as request ID).

**password** `object`

**properties**

**enabled** `boolean`

`true` when a password is set.

**grant\_days** `number | null`

How long each unlock lasts — `90`, `180` or `365`. `null` when no password is set.

**updated\_at** `string | null`

When the password or its duration was last changed.

**active\_unlocks** `number`

Number of unexpired access tokens issued by the current password.

```typescript ApiService.invoke() theme={null}
const { password } = await ApiService.invoke("genie-access", "password", genieId);
```

```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": "genie-access",
    "action": "password",
    "id": "550e8400-e29b-41d4-a716-446655440000"
  }'
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "password": {
      "enabled": true,
      "grant_days": 90,
      "updated_at": "2026-11-03T11:34:31.000Z",
      "active_unlocks": 12
    }
  }
}
```

***

### `set-password`

Sets or replaces a private Genie's access password, or changes how long each unlock lasts. Visitors who enter the password on the Genie's private page (via the public `genies` [`unlock`](https://docs.helpgenie.ai/api-reference/public-genies#unlock) action) receive an access token for `grant_days`.

**id** `string` *required*

Genie UUID (passed as request ID).

**password** `string`

The new password, 6–128 characters. Omit to change only `grant_days` on an existing password — returns `VALIDATION_ERROR` if no password is set yet.

**grant\_days** `number` (default: 90)

How long each unlock lasts. One of `90`, `180` or `365`.

Returns the same `password` object as `password`.

> [!WARNING]
>
> Setting a new password revokes every token the previous password issued. Changing only `grant_days` keeps existing tokens and applies to new unlocks.

```typescript ApiService.invoke() theme={null}
const { password } = await ApiService.invoke("genie-access", "set-password", genieId, {
  password: "correct-horse",
  grant_days: 180,
});
```

```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": "genie-access",
    "action": "set-password",
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "data": { "password": "correct-horse", "grant_days": 180 }
  }'
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "password": {
      "enabled": true,
      "grant_days": 180,
      "updated_at": "2026-11-04T09:00:00.000Z",
      "active_unlocks": 0
    }
  }
}
```

***

### `remove-password`

Removes a private Genie's access password and revokes every token it issued.

**id** `string` *required*

Genie UUID (passed as request ID).

```typescript ApiService.invoke() theme={null}
await ApiService.invoke("genie-access", "remove-password", genieId);
```

```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": "genie-access",
    "action": "remove-password",
    "id": "550e8400-e29b-41d4-a716-446655440000"
  }'
```

```json Response theme={null}
{
  "success": true,
  "data": { "removed": true }
}
```

***

### `diagnose`

> [!WARNING]
>
> Internal admin only. Requests from other accounts return `403 Forbidden`.

Explains whether a user can access a Genie under the platform's Genie access rule, and why. A non-admin user has access when they own the Genie, when the Genie belongs to the owner of their team, or when they are on the same team as the Genie owner. The response includes the Genie's owner, the owner's team and its members, explicit direct-access grants, the user's profile, the matching rule, and a plain-language verdict. It reflects current data, not the state at the time of an earlier request.

**Parameters**

| Field | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Genie UUID (passed as request ID) |
| `data.userId` | string | Yes | UUID of the user whose access is being explained |

**Response**

```json theme={null}
{
  "agent": { "id": "agent-uuid", "name": "Front Desk Genie", "user_id": "owner-uuid" },
  "owner": { "id": "owner-uuid", "email": "owner@example.com", "full_name": "Alex Rivera", "role": "user", "team_id": 12 },
  "team": { "id": 12, "name": "Acme Support", "owner_id": "owner-uuid" },
  "members": [
    { "id": "member-uuid", "email": "jane@example.com", "full_name": "Jane Doe", "role": "user", "team_id": 12 }
  ],
  "grants": [
    {
      "user_id": "user-uuid",
      "granted_by": "owner-uuid",
      "expires_at": null,
      "created_at": "2026-09-01T00:00:00Z",
      "user": { "id": "user-uuid", "email": "guest@example.com", "full_name": "Guest User", "role": "user", "team_id": null }
    }
  ],
  "caller": {
    "id": "user-uuid",
    "email": "guest@example.com",
    "full_name": "Guest User",
    "role": "user",
    "team_id": null,
    "team": null
  },
  "rule": null,
  "reason": "Denied: the caller is not the owner and is not on the owner's team (caller: no team, owner: team #12). The caller has an explicit genie-access grant, but grants are not accepted by this check."
}
```

| Field | Description |
| - | - |
| `agent` | The Genie, or `null` if it does not exist |
| `owner` | The Genie owner's profile |
| `team` | The owner's team, or `null` if the owner has no team |
| `members` | Other members of the owner's team, sorted by email |
| `grants` | Explicit direct-access grants on the Genie, each with the granted user's profile (`user`) |
| `caller` | The profile of `data.userId` with their team, or `null` if no profile exists |
| `rule` | The rule that grants access — `"admin"`, `"owner"`, `"team-owner"`, or `"teammate"` — or `null` when access is denied |
| `reason` | Plain-language explanation of the verdict |

> [!NOTE]
>
> Explicit direct-access grants are listed for context but do not satisfy this access check — a user with a grant and no ownership or team link is still reported as denied.

***

## Error codes

| Code | Meaning |
| - | - |
| `VALIDATION_ERROR` | Missing required parameter (including `id` or `data.userId` for `diagnose`), request already resolved, password shorter than 6 characters, `grant_days` not one of `90`/`180`/`365`, or `grant_days` changed with no password set |
| `NOT_FOUND` | Grant or access request not found |
| `FORBIDDEN` | You do not own this Genie, or `diagnose` was called by a non-admin |
| `AGENT_NOT_FOUND` | Genie does not exist |
| `INTERNAL_ERROR` | Unexpected server error |


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