> For the complete documentation index, see [llms.txt](https://alphamoon.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alphamoon.gitbook.io/documentation/api/process-api-keys-beta.md).

# Process API keys (Beta)

{% hint style="info" %}
The following endpoints are available in the v0.4 Alphamoon Workspace REST API (BETA).
{% endhint %}

To use the following endpoints, a user needs to get the **process\_id** from one of the following sources:

* [Get process](/documentation/api/get-processes.md)[es](/documentation/api/get-processes.md) endpoint
* Create process endpoint
* URL\
  **e.g.** <https://workspace.alphamoon.ai/queue/**2080d36bf94c4147b2e543104342fc2f>\*\*

## Create a process API key

The following endpoint enables you to create a new process API key:

<mark style="color:blue;">`POST`</mark> `/api/v0.4/processes/{process-id}/api-keys`

**Parameters**

| Name                                          | Type   | Description                                                  |
| --------------------------------------------- | ------ | ------------------------------------------------------------ |
| process\_id<mark style="color:red;">\*</mark> | string | ID of the process for which you want to create a new API key |

**Request body example:**

```json
{
  "name": "TEST API key",
  "exp": "2024-07-17T07:54:02.687Z",
  "scopes": [
    "workspace.collection:create"
  ]
}
```

Make sure you:

* Enter the **name of your API key,**&#x20;
* Set the **API key expiration date** (we recommend changing the API key every 3 to 6 months),
* Enter the [**process** **API scopes**](#process-api-scopes).

{% tabs %}
{% tab title="201: OK Successful Response" %}

```json
{
  "id": "688874d9d9064c23bf78bf3ec93cbd2d",
  "name": "TEST API key",
  "orgId": "USER:google-oauth2|123456789123456789123",
  "scopes": [
    "workspace.collection:create"
  ],
  "status": "Active",
  "createdAt": "2024-05-17T07:54:17Z",
  "exp": "2024-07-17T07:54:02Z",
  "key": "your_api_key_here",
  "processId": "93580f176efb48cda64f25cba74d8ca4"
}
```

{% endtab %}

{% tab title="400: Bad Request" %}

```json
{
  "action": "The client should not repeat this request without modification.",
  "detail": "Please see the 'errors' field for details.",
  "errors": [
    {
      "location": "body: priority",
      "message": "field required",
      "type": "request_validation_error"
    }
  ],
  "instance": "30e18f59-7c88-4e25-9bed-61863b2abf4b",
  "status": 400,
  "timestamp": "2021-11-09T17:43:36Z",
  "title": "The server cannot process the request due to a client error.",
  "type": "RequestValidationError"
}
```

{% endtab %}
{% endtabs %}

**See the example:**

{% tabs %}
{% tab title="API call" %}

```bash
curl -X 'POST' \
  'https://workspace.alphamoon.ai/api/v0.4/processes/93580f176efb48cda64f25cba74d8ca4/api-keys' \
  -H 'accept: application/json' \
  -H 'Authorization: Basic API_KEY_BASE64_ENCODED' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "TEST API key",
  "exp": "2024-07-17T07:54:02.687Z",
  "scopes": [
    "workspace.collection:create"
  ]
}'
```

{% endtab %}

{% tab title="Server response" %}

```json
{
  "id": "688874d9d9064c23bf78bf3ec93cbd2d",
  "name": "TEST API key",
  "orgId": "USER:google-oauth2|123456789123456789123",
  "scopes": [
    "workspace.collection:create"
  ],
  "status": "Active",
  "createdAt": "2024-05-17T07:54:17Z",
  "exp": "2024-07-17T07:54:02Z",
  "key": "your_api_key_here",
  "processId": "93588f176efb48cda64f25cba74d8ca4"
}
```

{% endtab %}
{% endtabs %}

## List the process API keys

Use the endpoint below to get the list of the process API keys:

<mark style="color:blue;">`GET`</mark> `/api/v0.4/processes/{process-id}/api-keys`

**Parameters**

| Name                                          | Type   | Description                                                |
| --------------------------------------------- | ------ | ---------------------------------------------------------- |
| process\_id<mark style="color:red;">\*</mark> | string | ID of the process for which you want to list your API keys |
| offset                                        | query  | The number of elements to skip                             |
| limit                                         | query  | The maximum number of elements to return at once           |

{% tabs %}
{% tab title="201: OK Successful Response" %}

```json
{
  "apiKeys": [
    {
      "id": "688874d9d9064c23bf78bf3ec93cbd2d",
      "name": "TEST API key",
      "orgId": "USER:google-oauth2|123456789123456789123",
      "scopes": [
        "workspace.collection:create"
      ],
      "status": "Active",
      "createdAt": "2024-05-17T07:54:17Z",
      "exp": "2024-07-17T07:54:02Z"
    }
  ],
  "pagination": {
    "offset": 0,
    "limit": 100,
    "total": 1
  },
  "processId": "93580f176efb48cda64f25cba74d8ca4"
}
```

{% endtab %}

{% tab title="400: Bad Request" %}

```json
{
  "action": "The client should not repeat this request without modification.",
  "detail": "Please see the 'errors' field for details.",
  "errors": [
    {
      "location": "body: priority",
      "message": "field required",
      "type": "request_validation_error"
    }
  ],
  "instance": "30e18f59-7c88-4e25-9bed-61863b2abf4b",
  "status": 400,
  "timestamp": "2021-11-09T17:43:36Z",
  "title": "The server cannot process the request due to a client error.",
  "type": "RequestValidationError"
}
```

{% endtab %}
{% endtabs %}

**See the example:**

{% tabs %}
{% tab title="API call" %}

```bash
curl -X 'GET' \
  'https://workspace.alphamoon.ai/api/v0.4/processes/93580f176efb48cda64f25cba74d8ca4/api-keys?offset=0&limit=100' \
  -H 'accept: application/json' \
  -H 'Authorization: Basic API_KEY_BASE64_ENCODED'
```

{% endtab %}

{% tab title="Server response" %}

```json
{
  "apiKeys": [
    {
      "id": "688874d9d9064c23bf78bf3ec93cbd2d",
      "name": "TEST API key",
      "orgId": "USER:google-oauth2|123456789123456789123",
      "scopes": [
        "workspace.collection:create"
      ],
      "status": "Active",
      "createdAt": "2024-05-17T07:54:17Z",
      "exp": "2024-07-17T07:54:02Z"
    }
  ],
  "pagination": {
    "offset": 0,
    "limit": 100,
    "total": 1
  },
  "processId": "93580b176efb48cda64f25cba74d8ca4"
}
```

{% endtab %}
{% endtabs %}

## Process API scopes

### Collections & images

The following API scopes allow users to manage collections of files in Alphamoon, including uploading, organizing, deleting, and updating existing collections.

<table><thead><tr><th width="361">Scope</th><th width="302">Description</th></tr></thead><tbody><tr><td>"workspace.collection:create"</td><td>Grants access to create new collections of files in the process.</td></tr><tr><td>"workspace.collection:read"</td><td>Lists collections in the process and display collections.</td></tr><tr><td>"workspace.collection:update"</td><td>Grants access to update collections of files.</td></tr><tr><td>"workspace.collection:delete"</td><td>Grants access to delete collections of files in the process.</td></tr><tr><td>"workspace.collection_editor:override"</td><td>Grants access to make changes to existing collections in the given process.</td></tr></tbody></table>

### Files & documents

The API scopes below provide access to file management features. These scopes allow users to upload new files to the platform as well as download them from Alphamoon to users device.

<table><thead><tr><th width="360">Scope</th><th>Description</th></tr></thead><tbody><tr><td>"workspace.file:upload"</td><td>Grants access to upload files to the given process.</td></tr><tr><td>"workspace.file:download"</td><td>Grants access to download files uploaded to the process to the user's device.</td></tr></tbody></table>

### Results

Results API scopes enable access to the processed extraction results of uploaded documents. Users can retrieve, review, update, and delete the results, as well as create new ones when necessary.

<table><thead><tr><th width="372">Scope</th><th>Description</th></tr></thead><tbody><tr><td>"workspace.result:read" </td><td>Grants access to read the extraction result.</td></tr><tr><td>"workspace.result:update"</td><td>Grants access to edit the extraction result (e.g. adding or deleting extractions). </td></tr></tbody></table>

### Processes

Processes API scopes encompass the coordination and oversight of document processing workflows, enabling users to view, update, and delete processes, as well as manage them.

<table><thead><tr><th width="372">Scope</th><th>Description</th></tr></thead><tbody><tr><td>"workspace.process:read" </td><td>Grants access to view the given process (e.g. enter the <a href="/pages/ZLLHfKghu5nZyPp1eIPP">Queue</a>, <a href="/pages/qNUoZyITCJmhsxTBhQ1B">Supervision</a>).</td></tr><tr><td>"workspace.process:update" </td><td>Grants access to edit the process and its configuration.</td></tr><tr><td>"workspace.process:delete" </td><td>Grants access to delete the given process.</td></tr><tr><td>"workspace.process.api_key:manage"</td><td>Grants access to create process API keys.</td></tr></tbody></table>

### Destinations

Destinations API scopes enable the configuration and management of data destinations. Users can specify where results are sent, ensuring they reach the appropriate systems or storage locations.

<table><thead><tr><th width="371">Scope</th><th>Description</th></tr></thead><tbody><tr><td>"workspace.destination:create" </td><td>Grants access to configure data destinations in the process.</td></tr><tr><td>"workspace.destination:read" </td><td>Grants access to view the data destinations in the process.</td></tr><tr><td>"workspace.destination:delete"</td><td>Grants access to delete the data destinations in the process.</td></tr></tbody></table>

### Exports

Exports API scopes provide functionality for exporting processed data, including options for defining export formats, and deleting existing exports if necessary.

<table><thead><tr><th width="365">Scope</th><th>Description</th></tr></thead><tbody><tr><td>"workspace.export:create"  </td><td>Grants access to create new exports in the process.</td></tr><tr><td>"workspace.export:delete"</td><td>Grants access to delete created exports in the process.</td></tr></tbody></table>

### Users administration

Users Administration API scopes allow Admins to create, modify, and control user access to ensure secure and efficient work with Alphamoon.

<table><thead><tr><th width="337">Scope</th><th>Description</th></tr></thead><tbody><tr><td>"workspace.admin.user:read" </td><td>Grants access to view user's details.</td></tr><tr><td>"workspace.admin.user:invite" </td><td>Grants access to inviting new users to Alphamoon.</td></tr><tr><td>"workspace.admin.user:manage"</td><td>Grants access to manage Alphamoon users.</td></tr></tbody></table>

**See next:**
