# API: Get started

The API of saaster provides the oppurtunity to use the functionality of saaster in other application.\
To use the API of saaster you need to create one. Follow this guide for this process:

{% content-ref url="/pages/m86rrQNcZVu60Hu9ezXC" %}
[API Settings](/fundementals/administration/system/api-settings.md)
{% endcontent-ref %}

We have chosen to use custom headers for passing additional parameters like the customerID and language etc. This approach offers a number of benefits when compared to using path parameters or query parameters. By using headers, we can add new parameters to the API without modifying the endpoint itself, making it more flexible for different use cases. Additionally, custom headers are not visible in the URL, ensuring that sensitive information such as user IDs or authentication tokens can be passed securely without being exposed in the URL. This approach also keeps the URL clean and easy to read, making it easier to understand the purpose of the endpoint.

## First steps

In order to use the saaster API, you need to follow these steps:

1. Generate an access token. Example:<br>

   ```powershell
   curl -X GET \
      http://localhost/api/authenticate \
      -H 'Accept: application/json' \
      -H 'apiID: 1' \
      -H 'apiKey: 1c1932d0-81da-4ad0-93bd-5ca03002f17e' \
   ```
2. Use the access token to create a request to the saaster API. The example below fetches the current plan of a customer:<br>

   ```powershell
   curl -X GET \
      http://localhost/api/getPlanFeatureSetting \
      -H 'Accept: application/json' \
      -H 'Authorization: Bearer {access-token}' \
      -H 'customerID: 1' \
   ```

   > Make sure to replace `{access-token}` with the token you received in Step 1.

#### CFML example:

<pre class="language-cfscript"><code class="lang-cfscript">// Change values to your API
apiID = 1
<strong>apiKey = "YourOwnKey"
</strong>
// Authenticate with API and get token
cfhttp(method="get", charset="utf-8", url="http://localhost/api/authenticate", result="getToken") {
    cfhttpparam(name="Content-Type", type="header", value="application/json");
    
    // Custom saaster related header variables
    cfhttpparam(name="apiID", type="header", value="#apiID#");
    cfhttpparam(name="apiKey", type="header", value="#apiKey#");
}

token = DeserializeJSON(getToken.filecontent).token;

cfhttp(method="get", charset="utf-8", url="http://localhost/api/getPlanFeatureSetting", result="getPlanFeatureSettings") {
    
    cfhttpparam(name="Authorization", type="header", value="Bearer #token#");
    cfhttpparam(name="Content-Type", type="header", value="application/json");

    // Custom saaster related header variables
    cfhttpparam(name="settingVariable", type="header", value="YourVariableName");
    cfhttpparam(name="planID", type="header", value="1");
    cfhttpparam(name="language", type="header", value="en");
}

dump( var=getPlanFeatureSettings.filecontent, label="getPlanFeatureSettings");
</code></pre>


---

# 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.saaster.io/api/api-get-started.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.
