# 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 %}
