# injectMarker

This method is to create an "instance" marker to the current record of a session. Then you can call [updateMarker](/cortex-api/markers/updatemarker.md) to turn this marker into an "interval" marker.

{% hint style="info" %}
You must call [createRecord](/cortex-api/records/createrecord.md) before you call this method.
{% endhint %}

## Parameters

| Name        | Type               | Required | Description                                                                                                                                                                     |
| ----------- | ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cortexToken | `string`           | yes      | A token returned by [authorize](/cortex-api/authentication/authorize.md).                                                                                                       |
| session     | `string`           | yes      | <p>A session id returned by <a href="/pages/-LfwIFn734JJKbPMLoRc">createSession</a>.</p><p>The marker will be added to the current record of this session.</p>                  |
| time        | `number`           | yes      | <p>The <strong>start</strong> timestamp of the marker.<br>It is the number of <strong>milliseconds</strong> that have elapsed since 00:00:00 Thursday, 1 January 1970 UTC.I</p> |
| value       | `string or number` | yes      | <p>The value of the marker. It can be a string or an integer.</p><p>If it is an integer then it must be positive or zero.</p>                                                   |
| label       | `string`           | yes      | The label of the marker.                                                                                                                                                        |
| port        | `string`           | no       | <p>The port of the marker, or where the marker comes from. Examples: "USB", "Serial", etc... <br>The default value is "Software"</p>                                            |
| extras      | `object`           | no       | Any extra information you want to associate with the marker.                                                                                                                    |

## Result

The result is an object containing these fields:

| Name      | Type     | Description                                                                                          |
| --------- | -------- | ---------------------------------------------------------------------------------------------------- |
| recordId  | `string` | The id of the record this marker was added to.                                                       |
| sessionId | `string` | The id of the session associated to the record.                                                      |
| marker    | `object` | A [marker object](/cortex-api/markers/marker-object.md) that represents the marker that was created. |

## Examples

{% tabs %}
{% tab title="Request" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "injectMarker",
    "params": {
        "cortexToken": "xxx",
        "label": "test2",
        "port": "Cortex Example",
        "session": "4cbf7554-31bd-4659-ac58-400b823503f0",
        "time": 1559811461532,
        "value": 42
    }
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "marker": {
            "endDatetime": "2019-06-06T15:57:41.529661+07:00",
            "extras": {},
            "label": "test2",
            "port": "Cortex Example",
            "startDatetime": "2019-06-06T15:57:41.529661+07:00",
            "type": "instance",
            "uuid": "26fccfd8-e487-4623-910a-1ba8591fcdcf",
            "value": 42
        },
        "recordId": "db01c15e-d916-4a7b-9f1d-16295fd1c643",
        "sessionId": "4cbf7554-31bd-4659-ac58-400b823503f0"
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://emotiv.gitbook.io/cortex-api/markers/injectmarker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
