# REST API

Akenza provides a REST API for programmatic access to its features. If you have any questions or want to request new API features, please submit a feature request [here](https://feedback.akenza.io).&#x20;

A set of examples, showing how to use the API:

{% embed url="<https://github.com/akenza-io/akenza-examples>" %}

The API documentation can be found here:

{% embed url="<https://docs.api.akenza.io>" %}

## API-keys

API-keys can be used to authenticate API Requests without having to provide a User JWT in the request. This is often used when writing an application based on akenza services.&#x20;

API-keys are created on Organization level and have permissions, which can be specified to suit the use case for the API-key. This means that API-keys can be denied access to certain parts of the Organization and its Workspaces, or a complete feature altogether.&#x20;

API-keys can be found under the API-key menu entry. They can only be created and viewed by **Organization Owners** and **Organization Administrators**. Other Members of the Organization have no access to API-keys.

![API-keys with assigned premissions](https://2165942204-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMKXTFIN5ZlLOjBlfC4%2Fuploads%2FWY3XQER4fLbMIlBnOX9H%2Fscreely-1685093330043.png?alt=media\&token=b28c84dd-80ae-4770-9937-129e9615c49f)

## Authenticating Requests

Requests can be authenticated with an API Key by providing the `x-api-key` header. The value of the header is the secret of the API Key.&#x20;

If the request is out of the specified permission scopes (e.g. Organization Delete) the API will return permission denied error.

## Example Request

<mark style="color:blue;">`GET`</mark> `https://api.akenza.io/v3/assets`

This request will fetch all Assets in a workspace using an API Key for authentication.

#### Query Parameters

| Name        | Type   | Description      |
| ----------- | ------ | ---------------- |
| workspaceId | string | The Workspace Id |

#### Headers

| Name      | Type   | Description        |
| --------- | ------ | ------------------ |
| x-api-key | string | The API Key Secret |

{% tabs %}
{% tab title="200 Returns a paginated list of Assets." %}

```
{
   "content":[
      {
         "id":"02d2327fedce2128",
         "name":"some device",
         "description":null,
         "type":"DEVICE",
         ...
      }
   ],
   "pageable":{
      ...
   },
   "totalPages":1,
   "totalElements":1,
   "last":true,
   "number":0,
   "sort":{
      ...
   },
   "size":25,
   "numberOfElements":1,
   "first":true,
   "empty":false
}
```

{% endtab %}

{% tab title="403 Returns an error object with the status and reason if e.g. the API Key permissions don't allow access to the Asset List. " %}

```
{
    "timestamp": "2021-02-19T15:06:56.928+00:00",
    "path": "/v3/assets",
    "status": 403,
    "error": "Forbidden",
    "message": "Permission denied",
    "requestId": "64fa58b0-18361",
    "errorId": "33a00d16-6a22-4687-99ca-90bb448e5eb2",
    "traceId": "8a7c4ea8ae80a5e4"
}
```

{% endtab %}
{% endtabs %}

## Backfilling

Backfilling allows adding data to a device using an http endpoint. It is possible to backfill data individually or in bulk for a single device.

All data sent this way will be processed by the output connectors and rules, therefore the body has to match the output of the device type script. If not specified the `timestamp` will be set to the current time and the `topic` to default.

The example requests can be found in the [akenza api documentation](https://docs.api.akenza.io/#4ce13d02-8eb7-42be-a661-a7abd767ae91)


---

# 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://docs.akenza.io/akenza.io/get-started/reference/api-documentation.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.
