---
url: /api-keys.md
---
# API Key

## API Key Management

It is possible to access the API Key management panel through the side menu, as indicated in the figure:

![api-keys-management-page](/images/api-keys-management-page.png)
*Side menu with link to API Keys management page highlighted*

### API Key Visualization

Once the management page is reached, it will be possible to:

* View the list of API Keys that the user has previously generated
* Search among these
* Create API Keys
* Delete API Keys

![api-keys-visualization](/images/api-keys-visualization.png)
*API Keys management page*

### API Key Creation

Clicking on ![create-api-key-button](/images/create-api-key-button.png) will open the API Key creation panel:
![create-api-key-dialog](/images/create-api-key-dialog.png)
*API Key creation panel*

From here, select:

* A `Module`: ALIDA module to which you want to access through the API Key. These include:
  * bda: *to generate a key for access to a *Workflow* that exposes REST endpoints*
* A `Role`: entity managed by the selected module in `Module` towards which you want to authorize access.
  * In the case of a `Module` of type `bda`, it will be possible to select one of the *Workflows*

Once you click on **Save**, the generated key will be displayed:

::: warning Key saving
The key must be kept safe, as it will no longer be possible to copy it
:::

![api-key-created-dialog](/images/api-key-created-dialog.png)
*Panel with API Key creation result*

### API Key Deletion

Clicking on ![api-key-delete-button](/images/api-key-delete-button.png) will allow
to delete the related API Key.

### API Key Usage

#### Accessing endpoints exposed by *Workflows*

Let's assume we have created a *Workflow* with a *Service* that exposes a REST-type port.
If we wanted to access the endpoint exposed through the API Key, we would need to create a new *API Key*
with `Module` = `bda` and `Role` =  `id-of-workflow-containing-the-service`.

At that point, using it in a REST call as indicated below, it will be possible
to access the endpoint:

```
curl --header 'Authorization: Apikey <api-key>' \
      --location 'https://alida.<your-domain>/events/bda/<bda-id>/<service-id>/<path-based-on-your-app>'
  
```

### Advanced API Key Usage

#### Accessing Alida Platform REST Resources

It is possible to use an API Key to access, with read and/or write permissions, to Alida REST resources such as:

* *Datasources*
* *Datasets*
* *Services*
* *etc.*

At API Key creation time, select:

* Module: `alida`
* Role: *`roles corresponding to permissions to be associated to the API Key`*

as shown here:

*Creating an API Key for accessing Alida Platform REST resources*

At that point, it will be possible to make a REST call as shown below.
The role associated to the API Key also determines the type of allowed HTTP methods (GET, PUT, POST):

```
curl --header 'Authorization: Apikey <api-key>' \
      --location 'https://alida.<your-domain>/events/alida/api/v1/<resource-name>'
```

Where `<resource-name>` can accept values such as, for instance:

* `datasources`
* `services`
* `models`
* `etc.`
