> For the complete documentation index, see [llms.txt](https://help.imotions.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.imotions.com/lab/sensor-setup/api/imotions-lab-api.md).

# iMotions Lab API

Set up and use the iMotions Lab API to send data and markers to iMotions, forward live data to other software and control iMotions remotely.

iMotions Lab has three network APIs that let other software work together with a study: the Event Receiving API sends sensor data and markers into iMotions, the Event Forwarding API streams live data out of iMotions, and the Remote Control API runs and manages studies from another program. This article explains how to enable each API and describes the message formats, so that you can write a program that uses them.

Using the API requires programming knowledge. For working code in Python, PsychoPy and TypeScript, see the [iMotions API examples on GitHub](https://github.com/imotions/iMotions-ApiExamples).

## Overview

| API                     | Direction                              | Default port | Transport            |
| ----------------------- | -------------------------------------- | ------------ | -------------------- |
| Event Receiving         | Your program → iMotions                | 8089         | UDP (default) or TCP |
| Event Forwarding        | iMotions → your program                | 8088         | UDP (default) or TCP |
| Replay Event Forwarding | iMotions → your program, during replay | 8090         | UDP (default) or TCP |
| Remote Control          | Your program → iMotions, with replies  | 8087         | TCP                  |

All three APIs use the same message format:

* Messages are UTF-8 text.
* Fields are separated by semicolons (`;`). A field value cannot contain a semicolon.
* Every message ends with a carriage return and line feed (`\r\n`), also over UDP. A message cannot contain `\r\n` inside it.

Use TCP when you can. Open one connection and reuse it for all messages, instead of opening a new connection for each message.

## Enabling the APIs

The API settings are on the **API** tab of Global Settings. If the settings on the tab are unavailable, your license does not include the API; contact your Customer Success Manager.

1. From the iMotions menu, select **Preferences** > **Global Settings**.
2. Open the **API** tab.
3. Enable the APIs you need, as described in the sections below, and note the port numbers.
4. Click **OK**.

The tab has four groups:

| Group                   | Setting                                                                           | Default                          | Description                                                                                                 |
| ----------------------- | --------------------------------------------------------------------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Remote Control          | **Enable remote control**                                                         | Off                              | Starts the Remote Control API.                                                                              |
|                         | **TCP Port**                                                                      | 8087                             | Port that iMotions listens on.                                                                              |
|                         | **Default Load & Save Folders**                                                   | Empty                            | Folders used by the `LOAD`, `SAVE` and export commands when a command does not give a full path.            |
| Event Forwarding        | **Enable forwarding**                                                             | Off                              | Starts the Event Forwarding API.                                                                            |
|                         | **Outside slideshow**                                                             | Off                              | Also forwards sensor data when no recording is in progress.                                                 |
|                         | **Use TCP**                                                                       | Off                              | Uses TCP instead of UDP. With TCP, iMotions listens on the port and your program connects to it.            |
|                         | **Serialize as JSON**                                                             | Off                              | Forwards each event as a JSON object instead of semicolon-separated text.                                   |
|                         | **Hostname** and **Port**                                                         | `localhost`, 8088                | Destination for UDP. With TCP, only the port is used.                                                       |
|                         | **Forward iMotions events**                                                       | On                               | Forwards keyboard and mouse events.                                                                         |
|                         | **Include all mouse events**                                                      | Off                              | Also forwards mouse movements, which produce a large number of events.                                      |
| Replay Event Forwarding | **Enable forwarding**, **Use TCP**, **Serialize as JSON**, **Hostname**, **Port** | Off, Off, Off, `localhost`, 8090 | Forwards data again when you replay a recording. Works like Event Forwarding.                               |
| Event Receiving         | **Enable event reception**                                                        | Off                              | Starts the Event Receiving API.                                                                             |
|                         | **Use TCP**                                                                       | Off                              | Uses TCP instead of UDP.                                                                                    |
|                         | **Port**                                                                          | 8089                             | Port that iMotions listens on.                                                                              |
|                         | **Event Sources**                                                                 | Empty                            | Event source definitions for the sensor data you send. Use **Add**, **View** and **Delete** to manage them. |

If your license includes it, the Event Forwarding group also has an **LSL Stream Outlet** section, which publishes forwarded events as a Lab Streaming Layer stream.

If a port is already used by another program, the API does not start. iMotions only reports this in its log file, `C:\ProgramData\iMotions\Lab_XG\Log\imotions.log`.

## Sending data and markers to iMotions

With the Event Receiving API, your program sends sensor data and markers to iMotions while a respondent is recorded. iMotions timestamps and stores them with the rest of the recording.

To use it:

1. On the **API** tab of Global Settings, select **Enable event reception** and, preferably, **Use TCP**. Note the port.
2. To send sensor data, add an event source definition for it; see [Event source definitions](#event-source-definitions). Markers need no definition.
3. In the study, include the **External Events API** sensor. Data and markers are only recorded in studies that include it.
4. Connect your program to the port on the computer that runs iMotions. Your program can run on the same computer or on another computer on the network.

iMotions does not reply to sensor data or markers. Messages that cannot be read are discarded and only reported in the log file.

### Markers

Markers mark a moment or a period in the recording, for example a trial start or a response. A marker message has this format:

```
M;2;<Timestamp>;<MediaTime>;<MarkerName>;<Description>;<MarkerType>;<RangeType>\r\n
```

| Field         | Description                                                                                                                                                                                                                                                                                                                               |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `M;2`         | Message type and version.                                                                                                                                                                                                                                                                                                                 |
| `Timestamp`   | Optional. Leave empty to let iMotions timestamp the marker when it arrives; see [Timestamps](#timestamps).                                                                                                                                                                                                                                |
| `MediaTime`   | Not used. Leave empty.                                                                                                                                                                                                                                                                                                                    |
| `MarkerName`  | Required. The name of the marker. Start and end markers of a period are matched by name.                                                                                                                                                                                                                                                  |
| `Description` | Optional description.                                                                                                                                                                                                                                                                                                                     |
| `MarkerType`  | `D` for a single moment (default), `S` for the start of a period, `E` for the end of a period, `N` to end all open periods of the same kind and start the next.                                                                                                                                                                           |
| `RangeType`   | For `S` and `N` markers: `I` or `V` creates an image or video scene for the period, so that it can be analyzed across respondents. `A` creates a respondent annotation for the period; see [Annotations from markers](#annotations-from-markers). Leave empty for neither. For `E` markers: leave empty, or use `A` to end an annotation. |

For example:

```
M;2;;;Trial start;Stroop trial 1;D;\r\n
M;2;;;Clip1;Product video;S;V\r\n
M;2;;;Clip1;;E;\r\n
```

A scene that is still open when the stimulus ends is closed at the end of the stimulus. An end marker without a matching start marker is ignored, and so is a start marker for a name that is already open.

### Annotations from markers

Markers with the `RangeType` `A` create [respondent annotations](https://help.imotions.com/lab/analysis/using-annotations.md), so that periods your program knows about, such as trials, are available for analysis without setting up automated annotations afterwards. For example:

```
M;2;;;Trial 1;Congruent;S;A\r\n
M;2;;;Trial 1;;E;A\r\n
```

* iMotions creates the annotations when it saves the recording. Each annotation is named after `MarkerName`, and the `Description` of the start marker becomes its comment.
* An annotation is not tied to a stimulus. It can start in one stimulus and end in another, and the end marker can also be sent between stimuli. An annotation that is still open when the recording ends is closed at the end of the recording.
* If the study already has a respondent annotation with the same name, the period is added to it. Otherwise iMotions creates a respondent annotation with a random color. If the name belongs to an automated annotation, no annotation is created.
* `N` with `A` ends all open annotations and starts a new one. It does not end open scenes, and `N` for a scene does not end open annotations.
* `E` with an empty `RangeType` ends the open scene with that name or, if there is none, the open annotation with that name. Use `E` with `A` when a scene and an annotation have the same name.

### Sensor data

A sensor data message has this format:

```
E;1;<SourceId>;<SourceVersion>;<Instance>;<Timestamp>;<MediaTime>;<SampleId>;<Value1>;...;<ValueN>\r\n
```

| Field             | Description                                                                                                                     |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `E;1`             | Message type and version.                                                                                                       |
| `SourceId`        | The `Id` of the event source definition.                                                                                        |
| `SourceVersion`   | The `Version` of the definition. Leave empty to use the latest version.                                                         |
| `Instance`        | Optional. Tells several devices of the same type apart, for example `LeftBicep` and `RightBicep`.                               |
| `Timestamp`       | Optional; see [Timestamps](#timestamps).                                                                                        |
| `MediaTime`       | Not used. Leave empty.                                                                                                          |
| `SampleId`        | The `Id` of a sample in the definition.                                                                                         |
| `Value1`…`ValueN` | One value for each field of the sample, in the order of the definition. The number of values must match the definition exactly. |

For example, for the definition below:

```
E;1;MySource;1;;;;Heart;72;0.85\r\n
```

### Event source definitions

An event source definition describes the data your program sends: its samples and their fields. It is an XML file:

```xml
<EventSource Version="1" Id="MySource" Name="My Source">
  <Sample Id="Heart" Name="Heart">
    <Field Id="Rate" Name="Heart rate" Range="Fixed" Min="40" Max="180"/>
    <Field Id="Quality" Name="Signal quality" Range="Variable"/>
  </Sample>
</EventSource>
```

| Element       | Attribute    | Description                                                                                                                                                                                                                         |
| ------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `EventSource` | `Id`         | Required, 1–20 characters. Used as `SourceId` in messages.                                                                                                                                                                          |
|               | `Version`    | Required, a whole number from 0 to 255.                                                                                                                                                                                             |
|               | `Name`       | Required, 1–60 characters. Shown in iMotions.                                                                                                                                                                                       |
| `Sample`      | `Id`         | Required, 1–20 characters, unique within the source. Used as `SampleId` in messages.                                                                                                                                                |
|               | `Name`       | Required.                                                                                                                                                                                                                           |
| `Field`       | `Id`         | Required, unique within the sample.                                                                                                                                                                                                 |
|               | `Name`       | Optional display name.                                                                                                                                                                                                              |
|               | `Range`      | Optional. `Fixed` or `Variable` makes the field numeric and shows it as a graph; `Fixed` uses `Min` and `Max` as the graph range. Fields without `Range`, or with `Range="None"`, can contain any text and are not shown as graphs. |
|               | `Min`, `Max` | Optional graph range for `Range="Fixed"`.                                                                                                                                                                                           |

A source can have several samples, and each sample needs at least one field. When you add fields to a source, increase its `Version`. iMotions keeps the older versions, so data recorded with them stays valid.

To add a definition to iMotions:

1. On the **API** tab of Global Settings, under **Event Sources**, click **Add**.
2. Select the XML file. iMotions checks the file and lists any errors with their line and position.

You cannot delete an event source definition while respondents with data from that source exist.

#### Sending a definition from your program

Over TCP, your program can also send the definition itself before the recording starts, instead of adding a file in Global Settings. Send `D;1`, then the XML, then an empty line:

```
D;1\r\n
<EventSource Version="1" Id="MySource" Name="My Source">\r\n
  ...\r\n
</EventSource>\r\n
\r\n
```

iMotions replies `D;1;1;<SourceId>;<Version>;<SampleCount>` when the definition is accepted, or `D;1;0;<Error message>;;` when it is not, for example when a different definition with the same `Id` and `Version` already exists. In a definition sent this way, every field is numeric unless it has `Range="None"`.

A definition sent from your program is not saved: send it again each time iMotions has been restarted. For a permanent setup, add the definition in Global Settings.

### Timestamps

Leave the timestamp empty in most cases. iMotions then timestamps each message when it arrives, which is precise enough when your program sends data as soon as it has it.

Set a timestamp only when there is a significant delay between capturing the data and sending it. The timestamp can be:

* The local time when the data was captured, as 17 digits in the format `yyyyMMddHHmmssfff`, for example `20261007141059234`.
* The number of milliseconds since the recording started.

Invalid timestamps are ignored, and iMotions uses the arrival time instead.

## Receiving data from iMotions

With the Event Forwarding API, iMotions sends events to your program in real time while it records.

1. On the **API** tab of Global Settings, select **Enable forwarding**.
2. Choose the transport:
   * With **Use TCP** selected, iMotions listens on **Port** and your program connects to it as a client.
   * Without **Use TCP**, iMotions sends UDP packets to **Hostname** and **Port**.
3. Optionally, select **Serialize as JSON** and **Outside slideshow**.
4. On the **Sensors** tab of Global Settings, select **Forward samples** for each sensor whose data you want to forward. For eye tracking, the setting is on the **Eye tracking** tab; see [Eye tracking data](#eye-tracking-data).
5. Connect your program and start a recording.

Only data from sensors that are collecting data is forwarded.

### Text format

By default, each event is a line of semicolon-separated fields:

```
<SeqNo>;<Source>;<SampleName>;<Timestamp>;-1;<Value1>;...;<ValueN>\r\n
```

| Field        | Description                                                                                                                                                                                                                 |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SeqNo`      | Sequence number with eight digits, for example `00000136`.                                                                                                                                                                  |
| `Source`     | The sensor, for example `EyeTracker`, or `AttentionTool` for events from iMotions itself.                                                                                                                                   |
| `SampleName` | The type of event, for example `EyeData` or `SlideStart`.                                                                                                                                                                   |
| `Timestamp`  | Milliseconds since the recording started. Empty or `-1` when no recording is in progress.                                                                                                                                   |
| `-1`         | Not used. Always `-1`.                                                                                                                                                                                                      |
| `Value1`…    | The values of the event. For sensor data, they follow the order of the columns in the [sensor data export](https://help.imotions.com/lab/exports/export-sensor-data.md). Semicolons inside values are replaced with commas. |

For example:

```
00000940;EyeTracker;EyeData;18352;-1;...\r\n
```

### JSON format

With **Serialize as JSON**, each event is one JSON object on its own line, ending with `\r\n`:

```json
{"SeqNo":12,"DeviceName":"AttentionTool","SampleName":"SlideStart","Timestamp":5321, ...}
```

The object contains `SeqNo`, `DeviceName`, `SampleName` and, during a recording, `Timestamp`, followed by the named values of the event. Values that are not available may be left out. Values that are not a number or infinite are sent as `null`.

### Eye tracking data

Eye tracking samples are `EyeData` events from the source `EyeTracker`. They always contain 13 standard fields: `GazeTime`, `GazeLeftX`, `GazeLeftY`, `GazeRightX`, `GazeRightY`, `PupilLeft`, `PupilRight`, `DistanceLeft`, `DistanceRight`, `CameraLeftX`, `CameraLeftY`, `CameraRightX` and `CameraRightY`.

Eye trackers that record more signals, such as Smart Eye eye trackers and VR headsets, can also forward those, for example eyelid opening, head pose or gaze intersections. To choose the signals:

1. On the **Eye tracking** tab of Global Settings, select the eye tracker **Model**.
2. Open the **Forward samples** drop-down below **Test Connection**. Its switch turns forwarding of eye tracking data on or off, and is on by default.
3. Select the signals to forward. They are grouped as in replay. Use the search box, **Select all signals** or **Select basic signals** to find and select them. The standard signals cannot be cleared.
4. Click **Copy signal names** to copy the field names of a forwarded message, separated by semicolons, in the order they are sent. The tooltip of the link shows the same list.

![The Forward samples drop-down for Smart Eye Pro, with the Blink group expanded and Left Eyelid Opening and Right Eyelid Opening selected](https://286068319-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLNBWkNpljDaAj5rQtNa%2Fuploads%2FfeLbiTEyKkhwWtEN34Gh%2Fglobal-settings_eye-tracking_forward-samples.png?alt=media)

The extra signals follow the standard fields, in the same order as in the sensor data export. A value that is missing from a sample is an empty field in the text format and is left out of the JSON object. Most eye trackers have no signals beyond the standard ones.

### Events from iMotions

Besides sensor data, iMotions forwards these events with the source `AttentionTool`:

| Event               | When                                                                                   |
| ------------------- | -------------------------------------------------------------------------------------- |
| `SlideshowStart`    | The recording starts. Includes the respondent, study and stimulus list.                |
| `SlideStart`        | A stimulus starts. Includes the stimulus name and slide type.                          |
| `SlideEnd`          | A stimulus ends.                                                                       |
| `SlideshowEnd`      | The recording ends.                                                                    |
| `Keyboard`, `Mouse` | The respondent uses the keyboard or mouse, if **Forward iMotions events** is selected. |

Use `SlideshowEnd` to detect when a recording has finished, for example before you send a Remote Control command.

## Controlling iMotions remotely

With the Remote Control API, your program sends commands to iMotions, for example to start a study for a respondent or export data, and receives a reply to each command.

1. On the **API** tab of Global Settings, select **Enable remote control** and note the **TCP Port**.

   Alternatively, start iMotions with the command-line option `/REMOTECONTROL`. iMotions then starts minimized with remote control enabled, and the remote control settings cannot be changed in Global Settings. If your program starts iMotions this way, let it retry the connection until iMotions accepts it.
2. Connect your program to the port over TCP and send commands.

### Commands and replies

A command has this format:

```
R;<Version>;<Id>;<COMMAND>;<Argument1>;...;<ArgumentN>\r\n
```

| Field       | Description                                                                                                                          |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `R`         | Message type.                                                                                                                        |
| `Version`   | The version of the command, starting at 1. Higher versions accept more arguments or return more data, as described for each command. |
| `Id`        | Any text. iMotions returns it in the reply, so that you can match replies to commands.                                               |
| `COMMAND`   | The command, in uppercase.                                                                                                           |
| `Argument`… | The arguments of the command. Leave an optional argument empty to use its default.                                                   |

Each command gets one reply. Commands that take time, such as exports, reply when they are complete. A reply has this format:

```
<SeqNo>;RemoteControl;<COMMAND>;<Timestamp>;<MediaTime>;<Id>;<Status>;<FailReason>;<Result1>;...\r\n
```

`Status` is `1` when the command succeeded and `0` when it failed, in which case `FailReason` explains why. Some commands return results after `FailReason`. A message that iMotions cannot read gets a reply with the command `ERROR` and status `0`.

For example, `R;2;cmd42;STATUS\r\n` asks for the status, and the reply contains `cmd42` as its `Id`.

While a recording is in progress, only `STATUS`, `SLIDESHOWNEXT`, `SLIDESHOWCANCEL` and `SLIDESHOWQUEUESTIMULUS` are accepted. While iMotions is busy, for example with an export, only `STATUS`, `MIN` and `MAX` are accepted.

### Command reference

| Command                  | Arguments                                                                                                                                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `STATUS`                 | None                                                                                                                                                     | Returns the open study, the respondent and the current stimulus. Version 2 adds whether iMotions is busy (`0` or `1`), a status text and a progress text. Version 3 adds the study and respondent IDs, the current slide number, the number of slides and the elapsed time. Version 4 adds the status of background jobs as JSON, for example post-processing. Use `STATUS` to check that iMotions is ready before you send other commands. |
| `RUN`                    | Study; respondent. Version 2 adds the properties of a new respondent, `Gender=<gender> Age=<age>`, separated by a space. Version 3 adds a prompt option. | Starts a recording of the study for the respondent. With version 1, the respondent must already exist; with version 2 and later, a new respondent is created with the given properties. The prompt option is `NormalPrompt` (default; the operator confirms warnings), `NoPromptIgnoreWarnings` (warnings are skipped) or `NoPrompt` (warnings stop the recording from starting).                                                           |
| `SLIDESHOWNEXT`          | None                                                                                                                                                     | Goes to the next stimulus, like **Shift+Space**. Fails if the stimulus cannot be advanced manually.                                                                                                                                                                                                                                                                                                                                         |
| `SLIDESHOWCANCEL`        | None                                                                                                                                                     | Cancels the recording, like **Shift+F1**.                                                                                                                                                                                                                                                                                                                                                                                                   |
| `SLIDESHOWQUEUESTIMULUS` | Displayed stimulus; stimulus to queue; position (optional, 1 = next)                                                                                     | Shows a stimulus of the study next or later in the current recording.                                                                                                                                                                                                                                                                                                                                                                       |
| `SAVE`                   | What to include; study; respondent; folder                                                                                                               | Saves the study as a .zip file, like **Save To File**. What to include: `0` data only, `1` data with recordings (default), `2` all data including stimuli, `3` data with screen recordings, `4` all data including analyses. Leave the respondent empty for all respondents. Returns the path of the file.                                                                                                                                  |
| `LOAD`                   | File; study name (optional); mode (optional)                                                                                                             | Imports a study .zip file, like **Load Study From File**. Mode: `Create` creates a new study, `Merge` merges the data into an existing study with the same stimuli, `Auto` (default) chooses.                                                                                                                                                                                                                                               |
| `DELETE`                 | Study; prompt option (optional, default `NoPromptIgnoreWarnings`)                                                                                        | Deletes the study. With `NormalPrompt`, the operator must confirm.                                                                                                                                                                                                                                                                                                                                                                          |
| `EXPORTSENSORDATA`       | Options; study; respondent; folder; from; to                                                                                                             | Exports sensor data, like the [sensor data export](https://help.imotions.com/lab/exports/export-sensor-data.md). Options is a space-separated list of what to include; leave it empty for all data. From and to are dates in the format `yyyyMMddHHmmss`. Returns the path.                                                                                                                                                                 |
| `EXPORTRECORDEDVIDEOS`   | Type; study; respondent; folder; from; to                                                                                                                | Exports recordings. Type: `Screen` (default), `FaceCam` or `EnvCam`.                                                                                                                                                                                                                                                                                                                                                                        |
| `AFFDEXPROCESS`          | Study                                                                                                                                                    | Starts AFFDEX post-processing of the study. Use `STATUS` version 4 to follow its progress.                                                                                                                                                                                                                                                                                                                                                  |
| `MIN`, `MAX`             | None                                                                                                                                                     | Minimizes or restores the iMotions window.                                                                                                                                                                                                                                                                                                                                                                                                  |
| `SHUTDOWN`               | None                                                                                                                                                     | Closes iMotions. The reply is sent before iMotions closes.                                                                                                                                                                                                                                                                                                                                                                                  |

For example, to start a recording of the study `MyStudy` for a new respondent without prompts:

```
R;3;run1;RUN;MyStudy;Respondent 01;Gender=Female Age=34;NoPromptIgnoreWarnings\r\n
```

## Programmer's guide and examples

* The [iMotions API examples on GitHub](https://github.com/imotions/iMotions-ApiExamples) contain ready-to-run code for each API in Python, PsychoPy and TypeScript. The PsychoPy example shows how to send markers from a PsychoPy experiment that iMotions starts.
* The iMotions Programmer's Guide describes the APIs in more detail, including all fields of the forwarded events.

{% file src="/files/3vDEuZLsOJMyIggDlcu4" %}
iMotions Programmer's Guide (iMotions 10.1.13)
{% endfile %}

For an introduction to what the APIs can be used for, see [iMotions API overview](https://help.imotions.com/lab/sensor-setup/api/imotions-api-overview.md). For a step-by-step example of receiving forwarded data, see [Event Forwarding API example (streaming to external software)](https://help.imotions.com/lab/sensor-setup/api/event-forwarding-api-example-streaming-to-external-software.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.imotions.com/lab/sensor-setup/api/imotions-lab-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
