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

# Insights

> Define and track conversation success metrics for your genies

Insights (also accepted as `goals` for backward compatibility) let you define measurable targets — such as lead capture rate or booking completion — and track them against your genies' conversations.

> [!NOTE]
>
> Standard users can only manage their own insights. Admin users can view and manage all insights by passing `adminMode: true`.

***

## List all insights

Returns all insights with full details for the authenticated user.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"all"`

**data** `object`

**properties**

**limit** `number` (default: 50)

Results per page. Maximum 100.

**offset** `number` (default: 0)

Number of results to skip.

**adminMode** `boolean` (default: false)

Admin only. When `true`, returns insights across all users.

**userId** `string`

Admin only. Return insights owned by this user ID.

**filters** `object`

**properties**

**agent\_id** `string`

Filter to insights attached to a specific genie.

**success** `boolean`

**data** `object`

**properties**

**items** `object[]`

Array of insight objects.

**count** `number`

**limit** `number`

**offset** `number`

***

## List insights

Returns a paginated list of insights for the authenticated user.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"list"`

**data** `object`

**properties**

**searchTerm** `string`

Filter insights by name (case-insensitive).

**limit** `number` (default: 50)

Results per page. Maximum 200.

**offset** `number` (default: 0)

Number of results to skip.

**adminMode** `boolean` (default: false)

Admin only. When `true`, returns insights across all users.

**userId** `string`

Admin only. Return insights owned by this user ID.

**success** `boolean`

**data** `object`

**properties**

**items** `object[]`

Array of insight objects.

**count** `number`

**limit** `number`

**offset** `number`

***

## Get insight

Retrieves a single insight by ID.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"get"`

**id** `string` *required*

The insight UUID.

**data** `object`

**properties**

**adminMode** `boolean` (default: false)

Admin only. When `true`, allows fetching insights owned by other users.

***

## Create insight

Creates a new insight metric.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"create"`

**data** `object` *required*

**properties**

**name** `string` *required*

Insight name (e.g. `"Lead capture rate"`).

**description** `string`

A short description of what this insight measures.

**fields** `object[]`

Field definitions for the information this insight collects. Every field needs a non-empty `key` and `label`, otherwise the call returns `VALIDATION_ERROR`.

**item properties**

**key** `string` *required*

Field key in `lowercase_with_underscores`. Collected data is stored under this key.

**label** `string` *required*

Human-readable field label.

**type** `string`

One of `text`, `email`, `phone`, `textarea`, `select`.

**required** `boolean`

Whether the genie should always try to collect this field.

**options** `string[]`

Choices for `select` fields only.

**is\_default** `boolean`

When `true`, marks this insight as a default template that appears as a starting point for new insights.

**userId** `string`

Admin only. Create the insight on behalf of this user instead of the caller.

> [!TIP]
>
> To build an insight for a genie, call [Generate insight](#generate-insight) with the genie's `agentId` first, pass its `name`, `description` and `fields` here, then [attach](#attach-insight-to-genie) it. Hand-written field lists tend to drift from what the genie actually does.

**success** `boolean`

**data** `object`

**properties**

**insight** `object`

The created insight object.

```typescript Example request theme={null}
const response = await ApiService.invoke({
  resource: "insights",
  action: "create",
  data: {
    name: "Lead capture rate",
    description: "Percentage of conversations that result in a captured lead",
    fields: [
      { key: "full_name", label: "Full name", type: "text", required: true },
      { key: "email", label: "Email", type: "email", required: true },
    ],
    is_default: false,
  },
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/insights \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "resource": "insights",
    "action": "create",
    "data": {
      "name": "Lead capture rate",
      "description": "Percentage of conversations that result in a captured lead",
      "fields": [
        { "key": "full_name", "label": "Full name", "type": "text", "required": true },
        { "key": "email", "label": "Email", "type": "email", "required": true }
      ],
      "is_default": false
    }
  }'
```

***

## Update insight

Updates an existing insight. Supports partial updates — send only the fields you want to change.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"update"`

**id** `string` *required*

The insight ID. Must be numeric — a non-numeric value returns `VALIDATION_ERROR`.

**data** `object`

**properties**

**name** `string`

New insight name.

**description** `string`

New description of what this insight measures.

**fields** `object[]`

Replaces the whole field list — same shape as on create. Every field needs a non-empty `key` and `label`, otherwise the call returns `VALIDATION_ERROR`. Keep the `key` of an existing field unchanged: collected data is stored under it.

**item properties**

**key** `string` *required*

Field key in `lowercase_with_underscores`. Collected data is stored under this key.

**label** `string` *required*

Human-readable field label.

**type** `string`

One of `text`, `email`, `phone`, `textarea`, `select`.

**required** `boolean`

Whether the genie should always try to collect this field.

**options** `string[]`

Choices for `select` fields only.

**is\_default** `boolean`

When `true`, marks this insight as a default template that appears as a starting point for new insights.

**adminMode** `boolean` (default: false)

Admin only. When `true`, allows updating insights owned by other users and includes the owner profile in the response.

> [!NOTE]
>
> Only `name`, `description`, `fields`, and `is_default` are applied. If `data` contains none of them — for example when it carries only unrelated keys — nothing is written and the insight is returned unchanged, with the same response shape as a successful update.

**success** `boolean`

**data** `object`

**properties**

**insight** `object`

The updated insight.

**properties**

**id** `number`

Insight ID.

**name** `string | null`

Insight name.

**description** `string | null`

Insight description.

**fields** `object[] | null`

Field definitions for the tracked metrics.

**is\_default** `boolean | null`

Whether this insight is a default template.

**created\_at** `string`

ISO 8601 creation timestamp.

**dependent\_agents** `object[]`

Genies this insight is attached to. Omitted when there are none.

**item properties**

**id** `string`

Genie ID.

**name** `string`

Genie name.

**owner** `object`

Owner profile — present only when `adminMode` is `true`.

**properties**

**id** `string`

User ID.

**full\_name** `string`

Full name.

**email** `string`

Email address.

**goal** `object`

The same object as `insight`, kept for backward compatibility.

```typescript Example request theme={null}
const response = await ApiService.invoke({
  resource: "insights",
  action: "update",
  id: "42",
  data: {
    name: "Lead capture rate",
    is_default: true,
  },
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/insights \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "resource": "insights",
    "action": "update",
    "id": "42",
    "data": {
      "name": "Lead capture rate",
      "is_default": true
    }
  }'
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "insight": {
      "id": 42,
      "name": "Lead capture rate",
      "description": "Percentage of conversations that result in a captured lead",
      "fields": [{ "label": "Leads captured", "key": "leads_captured" }],
      "is_default": true,
      "created_at": "2024-01-15T10:30:00.000Z"
    },
    "goal": {
      "id": 42,
      "name": "Lead capture rate",
      "description": "Percentage of conversations that result in a captured lead",
      "fields": [{ "label": "Leads captured", "key": "leads_captured" }],
      "is_default": true,
      "created_at": "2024-01-15T10:30:00.000Z"
    }
  }
}
```

***

## Delete insight

Permanently deletes an insight. A default insight (`is_default: true`) cannot be deleted — update it with `is_default: false` first.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"delete"`

**id** `string` *required*

The insight UUID.

> [!WARNING]
>
> This action is irreversible.

***

## Attach insight to genie

Links an insight to a genie. Each genie can have only one insight attached at a time — attaching a new one replaces the existing attachment.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"attach"`

**data** `object` *required*

**properties**

**agentId** `string` *required*

UUID of the genie to attach the insight to.

**insightId** `number` *required*

ID of the insight to attach. Required unless `goalId` is given.

**goalId** `number` *deprecated*

Backward-compatible alias for `insightId`. Used only when `insightId` is absent.

**success** `boolean`

```typescript Example request theme={null}
await ApiService.invoke({
  resource: "insights",
  action: "attach",
  data: {
    agentId: "agent-uuid",
    insightId: 42,
  },
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/insights \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "resource": "insights",
    "action": "attach",
    "data": {
      "agentId": "agent-uuid",
      "insightId": 42
    }
  }'
```

***

## Detach insight from genie

Removes the insight attachment from a genie.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"detach"`

**data** `object` *required*

**properties**

**agentId** `string` *required*

UUID of the genie to detach the insight from.

***

## Generate insight

Builds a tailored insight — name, description and fields — matched to a genie's business, audience and job. Nothing is saved: review the result, then pass it to [Create insight](#create-insight) and [attach](#attach-insight-to-genie) it to the genie.

**resource** `string` *required*

Must be `"insights"`

**action** `string` *required*

Must be `"generate"`

**data** `object` *required*

**properties**

**agentId** `string`

Recommended. UUID of the genie the insight is for. Its brand, category, purpose and instructions are loaded server-side so the fields match what the genie actually does. Returns `AGENT_NOT_FOUND` if you don't have access to the genie.

**description** `string`

What you want to collect or achieve, in your own words (e.g. `"Track how often callers book an appointment"`). Anything you name is always included. Required unless `agentId` is given.

**genieContext** `object`

Context for a genie that is not saved yet. Non-empty values override what `agentId` loads.

**properties**

**name** `string`

Genie name.

**description** `string`

Genie description.

**purpose** `string`

Genie's primary purpose.

**systemPrompt** `string`

Genie's instructions.

> [!NOTE]
>
> Without `agentId` or `genieContext`, fields are inferred from the description alone and come out more generic. The call fails with `INTERNAL_ERROR` when fewer than 3 usable fields can be produced.

**success** `boolean`

**data** `object`

**properties**

**name** `string`

Suggested insight name.

**description** `string`

Suggested description.

**fields** `object[]`

Suggested field definitions, ready to pass to `create`.

**item properties**

**key** `string`

Field key in `lowercase_with_underscores`.

**label** `string`

Human-readable label.

**type** `string`

One of `text`, `email`, `phone`, `textarea`, `select`.

**required** `boolean`

Whether the field should always be collected.

**options** `string[]`

Choices — present for `select` fields only.

**confidence** `number`

Confidence score between 0 and 1.

**geniePurpose** `string | null`

What the generator understood the genie to be for.

```typescript Example request theme={null}
const result = await ApiService.invoke({
  resource: "insights",
  action: "generate",
  data: {
    agentId: "550e8400-e29b-41d4-a716-446655440000",
    description: "Track how often callers book an appointment",
  },
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/insights \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "resource": "insights",
    "action": "generate",
    "data": {
      "agentId": "550e8400-e29b-41d4-a716-446655440000",
      "description": "Track how often callers book an appointment"
    }
  }'
```

```json Response theme={null}
{
  "success": true,
  "data": {
    "name": "Appointment bookings",
    "description": "Details captured when a caller books or asks about an appointment",
    "fields": [
      { "key": "full_name", "label": "Full name", "type": "text", "required": true },
      { "key": "phone", "label": "Phone number", "type": "phone", "required": true },
      { "key": "service_type", "label": "Service", "type": "select", "required": false, "options": ["Consultation", "Follow-up"] },
      { "key": "preferred_date", "label": "Preferred date", "type": "text", "required": false }
    ],
    "confidence": 0.8,
    "geniePurpose": "Books appointments for a dental clinic"
  }
}
```

***

## Error codes

| Code | Meaning |
| - | - |
| `VALIDATION_ERROR` | Missing or invalid required parameter |
| `NOT_FOUND` | Insight not found |
| `AGENT_NOT_FOUND` | Genie not found or not accessible (`generate`) |
| `FORBIDDEN` | Access denied |
| `INTERNAL_ERROR` | Unexpected server error |


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