# API Documentation

## Store Data (Create & Update)

<mark style="color:orange;">`PUT`</mark> `https://localhost:7021/api/kv/:key`

This endpoint allows you store data at a specific key. If the key is not used yet, it will be created.

#### Path Parameters

| Name | Type   | Description               |
| ---- | ------ | ------------------------- |
| key  | string | Key of the value to store |

#### Headers

| Name          | Type   | Description                         |
| ------------- | ------ | ----------------------------------- |
| Authorization | string | API authentification JSON Web Token |

#### Request Body

| Name     | Type   | Description                                            |
| -------- | ------ | ------------------------------------------------------ |
| Raw Body | string | Raw body (Plain text, JSON, ...) or raw binary content |

{% tabs %}
{% tab title="200 Data was successfully updated." %}

```javascript
{
  "message": "The specified key was successfully updated."
}
```

{% endtab %}

{% tab title="201 Data was successfully created." %}

```javascript
{
  "message": "The specified key was successfully created."
}
```

{% endtab %}

{% tab title="401 " %}

```javascript
{
  "message": "You are not allowed to perform this action."
}
```

{% endtab %}

{% tab title="409 " %}

```javascript
{
  "message": "The specified key cannot be updated."
}
```

{% endtab %}
{% endtabs %}

## Get Data

<mark style="color:blue;">`GET`</mark> `https://localhost:7021/api/kv/:key`

This endpoint allows you to get data associated with a key.

#### Path Parameters

| Name | Type   | Description            |
| ---- | ------ | ---------------------- |
| key  | string | Key of the data to get |

#### Headers

| Name          | Type   | Description                         |
| ------------- | ------ | ----------------------------------- |
| Authorization | string | API authentification JSON Web Token |

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

```
hello world
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "message": "The specified key does not exists."
}
```

{% endtab %}
{% endtabs %}

## Delete Data

<mark style="color:red;">`DELETE`</mark> `https://localhost:7021/api/kv/:key`

This endpoint allows you to delete an existing key with its associated data.

#### Path Parameters

| Name | Type   | Description               |
| ---- | ------ | ------------------------- |
| key  | string | Key of the data to remove |

#### Headers

| Name          | Type   | Description                         |
| ------------- | ------ | ----------------------------------- |
| Authorization | string | API authentification JSON Web Token |

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

```javascript
{
  "message": "The specified key and its data was successfully deleted."
}
```

{% endtab %}

{% tab title="401 " %}

```javascript
{
  "message": "You are not allowed to perform this action."
}
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "message": "The specified key does not exists."
}
```

{% endtab %}
{% endtabs %}

## Check key initialization

`HEAD` `https://localhost:7021/api/kv/:key`

Check if a key was initialized in the Lucid node.

#### Path Parameters

| Name | Type   | Description              |
| ---- | ------ | ------------------------ |
| key  | string | Key of the data to check |

#### Headers

| Name          | Type   | Description                         |
| ------------- | ------ | ----------------------------------- |
| Authorization | string | API authentification JSON Web Token |

{% tabs %}
{% tab title="200 The specified key is initialized." %}

```javascript
{
  "message": "The specified key is initialized."
}
```

{% endtab %}

{% tab title="401 " %}

```javascript
{
  "message": "You are not allowed to perform this action."
}
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
  "message": "The specified key does not exists."
}
```

{% endtab %}
{% endtabs %}

## Execute a Specific Operation

<mark style="color:purple;">`PATCH`</mark> `https://localhost:7021/api/kv/:key`

Execute some operation like lock/unlock or other.

#### Path Parameters

| Name | Type   | Description                |
| ---- | ------ | -------------------------- |
| key  | string | Key of the data to operate |

#### Headers

| Name          | Type   | Description                         |
| ------------- | ------ | ----------------------------------- |
| Authorization | string | API authentification JSON Web Token |

#### Request Body

| Name      | Type   | Description                             |
| --------- | ------ | --------------------------------------- |
| operation | string | Operation to perform (lock, unlock etc) |

{% 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://clintnetwork.gitbook.io/lucid/docs/api.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.
