# Public API Documentation

## Overview

We provide interactive API documentation that allows you to explore all available endpoints of the Public API and try them out directly in your browser. This API is available for enterprise customers who have opted in to the feature.

### What You Can Do

- **Explore Endpoints** - Browse all available API operations
- **Try It Out** - Execute API calls directly from the documentation
- **View Examples** - See request and response payloads for each endpoint
- **Understand the Schema** - Review all data models and their properties

## How to Access

Open your backend host URL and add `/public/swagger`. This is the same URL as the Public URL.

Examples:

- `https://api.<your-suffix>.unique.app/public/swagger`
- `https://gateway.unique.app/public/swagger`
- `https://gateway.us.unique.app/public/swagger`

## Authentication

To use the Public API, you need to authenticate with a Personal API Key and provide identifying headers.

### Generate a Personal API Key

Check the Public API documentation to find out more about how to create a Personal Key: [Personal API Key](https://docs.unique.ai/developers/software-development-kit-sdk/personal-api-key).

### Required Headers

All API requests require the following headers. All the header values can be retrieved as shown in the Personal API Key documentation.

| Header       | Description                               |
|--------------|-------------------------------------------|
| Api Key      | Your Personal API Key                     |
| App Id      | Your Application ID                       |
| User Id      | Your user ID                              |
| Company Id   | Your company ID                           |
| Api Version   | The version of the API to be used - see API Version |

### Try It Out in Swagger UI

To test the API using the Swagger documentation:

1. Open the Swagger UI at your environment's URL
2. Click the **"Authorize"** button at the top of the page
3. Fill in all 4 authentication values (as per the documentation above):
   1. **API Key** - Enter your Personal API Key
   2. Click **"Authorize"**
   3. **App Id** - Enter your application ID
   4. Click **"Authorize"**
   5. **User Id** - Enter your user ID
   6. Click **"Authorize"**
   7. **Company Id** - Enter your company ID
   8. Click **"Authorize"**
4. Click “x” to close the **“Authorize”** menu.
5. Navigate to the endpoint you want to test
6. Click **"Try it out"**
7. Fill in the required parameter values
8. Click **"Execute"** to send the request

### Example request (curl)

```
curl --location --request GET 'https://<base-url>/public/chat/space/<space-id>' \
--header 'x-user-id: <user-id>' \
--header 'x-company-id: <company-id>' \
--header 'Authorization: Bearer <api-key>' \
--header 'x-app-id: <app-id>' \
--header 'x-api-version: 2023-12-06'
```

## API Version

The current API version is `2023-12-06`. This needs to be passed via the `x-api-version` header otherwise calls to the API will result in a `404 - not found` errors.
