> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maalbar.dk/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Learn how to use Målbar`s API to programmatically manage resources in Målbar LCA.

You can use the API to:

* [Create screening](/api-reference/product/create-a-screening-for-a-product)
* [Create locations](/api-reference/locations/create-a-location)
* [Retrieve screening results](/api-reference/screenings/get-all-screening-results)

## Base URL

Målbar's API is built on REST principles and is served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported.

The Base URL for all API endpoints is:

```bash theme={null}
https://api.maalbar.dk
```

## Authentication

Authentication to Målbars's API is performed via the header "X-Api-Key" with the key generated when logged in to Målbar LCA. To authenticate, you need to include the header "X-Api-Key" followed by your [API key](/api-reference/authentication#api-keys) in your requests like so:

```bash Terminal theme={null} theme={null}
X-Api-Key: mb_live_xxxxxxxxxxxxxxxx
```

Here are examples of how to authenticate with Målbar's API:

```bash cURL theme={null} theme={null}
curl --request GET \
--url https://api.maalbar.dk/v1/customer \
--header 'X-Api-Key: mb_live_xxxxxxxxxxxxxxxx'
```

Learn more about [how to get your API key](/docs/api-reference/authentication#api-keys).

## Error handling

Målbar API returns machine readable error codes and human readable error messages.

Here is how an error response looks like:

```json theme={null} theme={null}
{
  "error": {
    "code": "not_found",
    "message": "The requested resource was not found."
  }
}
```

Here is a list of all error codes Målbar API returns:

<AccordionGroup>
  <Accordion title="bad_request">
    * **Status:** 400
    * **Problem:** The request is malformed, either missing required fields, using wrong datatypes, or being syntactically incorrect.
    * **Solution:** Check the request and make sure it is properly formatted.
  </Accordion>

  <Accordion title="unauthorized">
    * **Status:** 401 \* **Problem:** The request has not been applied because it
      lacks valid authentication credentials for the target resource. \*
      **Solution:** Make sure you are using the correct API key.
  </Accordion>

  <Accordion title="forbidden">
    * **Status:** 403 \* **Problem:** The server understood the request, but is
      refusing to fulfill it because the client lacks proper permission. \*
      **Solution:** Make sure you have the necessary permissions to access the
      resource.
  </Accordion>

  <Accordion title="not_found">
    * **Status:** 404 \* **Problem:** The server has not found anything matching
      the request URI. \* **Solution:** Check the request and make sure the resource
      exists.
  </Accordion>

  <Accordion title="rate_limit_exceeded">
    * **Status:** 429 \* **Problem:** The request has been rate limited. \*
      **Solution:** Wait for a while and try again.
  </Accordion>

  <Accordion title="internal_server_error">
    * **Status:** 500
    * **Problem:** The server encountered an unexpected condition that prevented it from fulfilling the request.
    * **Solution:** Try again later. If the problem persists, contact Målbar support.
  </Accordion>
</AccordionGroup>

## Pagination

Målbar's API supports pagination. This is useful when you have a large number of resources and you want to retrieve them in smaller chunks.

### Parameters

<ParamField body="page" type="string" default="1">
  The page number to retrieve. By default, the first page is returned.
</ParamField>

<ParamField body="pageSize" type="string">
  The number of items to retrieve per page. The default value varies by
  endpoint. Maximum value is 100.
</ParamField>

### Example

The following example demonstrates how to retrieve the first page of 10 links:

```bash cURL theme={null} theme={null}
curl --request GET \
--url https://api.maalbar.dk/v1/products?page=1&pageSize=10 \
--header 'X-Api-Key: mb_live_xxxxxxxxxxxxxxxx'
```
