# RESTful API

## Introduction

#### API Base URL

{% code title="" %}

```http
https://api.cmft.io/v1/
```

{% endcode %}

#### Basic Query Structure

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

```bash
https://api.cmft.io/v1/<repoName>/<endpoint>?key=<apiKey>
```

{% endtab %}

{% tab title="CURL" %}

```bash
curl 'https://api.cmft.io/v1/<repoName>/<endpoint>' \
  -H 'Authorization: <apiKey>'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
window.fetch('https://api.cmft.io/v1/<repoName>/<endpoint>', {
  method: 'get',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': '<apiKey>'
  }
})
  .then(function (response) { return response.json() })
  .then(function (data) {
    console.log(data)
  })
```

{% endtab %}
{% endtabs %}

#### Example Document Structure

```javascript
{
  "fields": {
    "title": "Roses are red"
  },
  "meta": {
    "id": "314159265358979323",
    "contentType": "poem",
    "repository": "314159265358979323",
    "revision": 1,
    "tags": [],
    "createdAt": "2018-01-01T00:00:00.000Z",
    "updatedAt": "2018-01-01T00:00:00.000Z"
  }
}
```

## API Keys

The API Key is mandatory and can be included in the `Authorization Header` or the `URL` for `GET` requests. One key is always valid for the associated repository.

### Creating API Keys

By default there will be an auto-generated API Key for your repository. However, you can always create additional keys.

1. Navigate to the 'Settings' page and select the tab 'API Keys'.
2. On the field below,
3. Click the 'Create New Key'-Button.

### Editing

The keys are generated by our API, therefore you can only change the name you use to describe a keys purpose.

1. Navigate to the 'Settings' page and select the tab 'API Keys'.
2. Click the 'Pencil'-Button when hovering a key in the list.
3. Make your changes.
4. Confirm by clicking the 'Checkmark'-Button

### Revoking or Deleting

You can delete any additional API Keys.

1. Navigate to the 'Settings' Page and select the tab 'API Keys'.
2. Click the 'Pencil'-Button when hovering a key in the list.
3. Click the 'Trashcan'-Butto&#x6E;*.*
4. Confirm.

### Types of Keys

Currently there are just `read-only` keys. Once we've published the write API, we're going to offer different types of keys.

### Usage

{% hint style="info" %}
The API Key can be either included as Query Parameter in the URL or in the Authorization Header.\
However when making `POST` requests, the key must be provided in the **Authorization Header**.&#x20;
{% endhint %}


---

# 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.comfortable.io/apis/rest-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.
