# State

## List State

<mark style="color:blue;">`GET`</mark> `https://{organisation}.clearlrs.com/xapi/activities/state`

Returns a list of **stateIds** stored for the specified parameters.

#### Query Parameters

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| activityId   | string | 1           |
| agent        | object | 2           |
| registration | string | 3           |

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

```
```

{% endtab %}
{% endtabs %}

## Retrieve State

<mark style="color:blue;">`GET`</mark> `https://{organisation}.clearlrs.com/xapi/activities/state`

Retrieves the state document

#### Query Parameters

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| activityId   | string | 1           |
| agent        | object | 2           |
| stateId      | string | 3           |
| registration | string | 4           |

{% tabs %}
{% tab title="200 The document currently stored in the state resource." %}

```
```

{% endtab %}

{% tab title="302 " %}

```
```

{% endtab %}
{% endtabs %}

## Update State

<mark style="color:orange;">`PUT`</mark> `https://{organisation}.clearlrs.com/xapi/activities/state`

Replaces the state document for the given **agent**, **activityId** and **stateId**.

#### Query Parameters

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| activityId   | string | 1           |
| agent        | object | 2           |
| stateId      | string | 3           |
| registration | string | 4           |

{% tabs %}
{% tab title="204 The document was successfully updated." %}

```
```

{% endtab %}

{% tab title="400 The request is missing required parameters." %}

```javascript
{
    "code": 400,
    "name": "Bad Request",
    "body": [
        {
            "name": "ValidationError",
            "description": "'query' must contain property  'activityId'",
            "property": "query",
            "value": {
                "document": ""
            }
        },
        {
            "name": "ValidationError",
            "description": "'query' must contain property  'agent'",
            "property": "query",
            "value": {
                "document": ""
            }
        },
        {
            "name": "ValidationError",
            "description": "'query' must contain property  'stateId'",
            "property": "query",
            "value": {
                "document": ""
            }
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Merge State

<mark style="color:green;">`POST`</mark> `https://{organisation}.clearlrs.com/xapi/activities/state`

#### Query Parameters

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| activityId   | string | 1           |
| agent        | object | 2           |
| stateId      | string | 3           |
| registration | string | 4           |

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

```
```

{% endtab %}
{% endtabs %}

## Remove State

<mark style="color:red;">`DELETE`</mark> `https://{organisation}.clearlrs.com/xapi/activities/state`

#### Query Parameters

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| activityId   | string | 1           |
| agent        | object | 2           |
| stateId      | string | 3           |
| registration | string | 4           |

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

```
```

{% 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://dev.clearxp.com/xapi-reference/state.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.
