# Glob APIs

Glob APIs could be used in the template to access the global key-value store. These values are useful to enable interaction between templates and control the behaviour of simulation through the user.&#x20;

## Create a new Glob entry or update an existing Glob entry

<mark style="color:green;">`POST`</mark> `https://nsim.iotify.io/api/datastore/:workspaceId/glob`

This endpoint allows you to create/update a Glob entry

#### Path Parameters

| Name                                          | Type   | Description                        |
| --------------------------------------------- | ------ | ---------------------------------- |
| workspaceId<mark style="color:red;">\*</mark> | String | The Workspace ID where the Glob is |

#### Headers

| Name                                           | Type   | Description                                |
| ---------------------------------------------- | ------ | ------------------------------------------ |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                           |
| domain<mark style="color:red;">\*</mark>       | String | The domain under which your account exists |
| key <mark style="color:red;">\*</mark>         | String | API token for the account                  |

#### Request Body

| Name                                    | Type   | Description                  |
| --------------------------------------- | ------ | ---------------------------- |
| key<mark style="color:red;">\*</mark>   | String | The key for the Glob entry   |
| value<mark style="color:red;">\*</mark> | String | The value for the Glob entry |

{% tabs %}
{% tab title="201: Created Glob successfully created" %}

```json
true
```

{% endtab %}

{% tab title="400: Bad Request Glob could not be created" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% code overflow="wrap" %}

```javascript
// Example curl command

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -H "key:$KEY" -H "domain:nsim.iotify.io" -d '{"key":"$GLOBKEY","value":"$GLOBVALUE"}' nsim.iotify.io/api/datastore/$WORKSPACE/glob
```

{% endcode %}

## Get a Glob object

<mark style="color:blue;">`GET`</mark> `https://nsim.iotify.io/api/datastore/:workspaceId/glob/item/:globKey`

#### Path Parameters

| Name                                          | Type   | Description                                                  |
| --------------------------------------------- | ------ | ------------------------------------------------------------ |
| workspaceId<mark style="color:red;">\*</mark> | string | The workspace ID for the workspace where the Glob is present |
| globKey<mark style="color:red;">\*</mark>     | String | The key for the glob entry to be fetched                     |

#### Headers

| Name                                           | Type   | Description                                |
| ---------------------------------------------- | ------ | ------------------------------------------ |
| key<mark style="color:red;">\*</mark>          | string | API token for the account                  |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                           |
| domain<mark style="color:red;">\*</mark>       | String | The domain under which your account exists |

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

```json
{
    "key": "CurlTest",
    "value": "Testing"
}
```

{% endtab %}
{% endtabs %}

{% code overflow="wrap" %}

```javascript
// Example curl command

curl -X GET -H "Accept: application/json" -H "Content-Type: application/json" -H "key:$KEY" -H "domain:nsim.iotify.io" nsim.iotify.io/api/datastore/$WORKSPACE/glob/item/$GLOBKEY
```

{% endcode %}

## Get all the Glob keys

<mark style="color:blue;">`GET`</mark> `nsim.iotify.io/api/datastore/:workspaceId/glob/keys`

#### Path Parameters

| Name                                          | Type   | Description                                                  |
| --------------------------------------------- | ------ | ------------------------------------------------------------ |
| workspaceId<mark style="color:red;">\*</mark> | String | The workspace ID for the workspace where the Glob is present |

#### Headers

| Name                                           | Type   | Description                                |
| ---------------------------------------------- | ------ | ------------------------------------------ |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                           |
| domain<mark style="color:red;">\*</mark>       | String | The domain under which your account exists |
| key<mark style="color:red;">\*</mark>          | String | API token for the account                  |

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

```javascript
key1, key2, key3, key4, key5
```

{% endtab %}
{% endtabs %}

{% code overflow="wrap" %}

```javascript
// Example curl command

curl -X GET -H "Accept: application/json" -H "Content-Type: application/json" -H "key:$KEY" -H "domain:nsim.iotify.io" nsim.iotify.io/api/datastore/$WORKSPACE/glob/keys
```

{% endcode %}

## Glob Delete

<mark style="color:red;">`DELETE`</mark> `nsim.iotify.io/api/datastore/:workspaceId/glob/item/:globKey`

Deletes the key value pair of the glob

#### Path Parameters

| Name                                          | Type   | Description                                                  |
| --------------------------------------------- | ------ | ------------------------------------------------------------ |
| globKey<mark style="color:red;">\*</mark>     | string | The key for the glob entry to be deleted                     |
| workspaceId<mark style="color:red;">\*</mark> | String | The workspace ID for the workspace where the Glob is present |

#### Headers

| Name         | Type   | Description                                |
| ------------ | ------ | ------------------------------------------ |
| Content-Type | string | application/json                           |
| key          | String | API token for the account                  |
| domain       | String | The domain under which your account exists |

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

```
true
```

{% endtab %}
{% endtabs %}

{% code overflow="wrap" %}

```javascript
// Example curl command

curl -X GET -H "Accept: application/json" -H "Content-Type: application/json" -H "key:$KEY" -H "domain:nsim.iotify.io" nsim.iotify.io/api/datastore/$WORKSPACE/glob/item/$GLOBKEY
```

{% endcode %}
