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

# REST API  -  Setup Guide

> How to get started with the PG:AI REST API

## Prerequisites

> [!NOTE]
>
> Before using the REST API, ensure you have:
>
> * A PG:AI account with **API access enabled**
> * An **API key** generated from Settings

## Generating an API Key

**1. Navigate to API Keys**

Navigate to **Settings → API Keys** in PG:AI.

**2. Generate a new key**

Click **Generate New Key**.

**3. Name and scope the key**

Give the key a **name** (e.g. "CRM Sync", "Data Warehouse", "Internal Dashboard"). Set **permission scope** if applicable (read-only, read-write, or specific entity access).

**4. Copy and store the key**

Copy the key immediately  -  it won't be shown again.

> [!WARNING]
>
> Store your API key securely. Do not commit it to source control or share it in plaintext.

## Authentication

All API requests require an API key passed in the request header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

Or as a query parameter (not recommended for production):

```bash theme={null}
GET /api/v1/companies?api_key=YOUR_API_KEY
```

## Base URL

```
https://api.getpg.ai/v1
```

All endpoints are relative to this base URL.

## Exploring the API

### Swagger UI

The interactive API explorer is available at:

```
https://www.app.getpg.ai/api-docs
```

Swagger UI lets you:

* Browse all available endpoints
* See request/response schemas
* Test endpoints with your API key directly in the browser
* View example payloads

### OpenAPI Specification

Download the full OpenAPI 3.0 spec:

* **JSON:** `https://api.getpg.ai/v1/openapi.json`
* **YAML:** `https://api.getpg.ai/v1/openapi.yaml`

> [!TIP]
>
> Import into Postman, Insomnia, or any OpenAPI-compatible tool to auto-generate client code.

## Quick Test

Verify your API key works with a simple request:

```bash theme={null}
curl -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.getpg.ai/v1/companies?limit=5
```

You should receive a JSON response with up to 5 company records from your workspace.

## Rate Limits

API requests are rate-limited per key:

| Tier | Requests/Minute | Requests/Day |
| - | - | - |
| Standard | 60 | 10,000 |
| Professional | 120 | 50,000 |
| Enterprise | Custom | Custom |

Rate limit headers are included in every response:

```
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1707600000
```

> [!WARNING]
>
> If you exceed the limit, you'll receive a `429 Too Many Requests` response. Back off and retry after the reset time.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.