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

# REST API overview

> Programmatic access to Krastie AI visibility reports, workspace data, and content tools.

The Krastie REST API lets Business and Enterprise customers automate AI visibility reporting, pull workspace analytics, and integrate content workflows into their stack.

<Note>
  API access requires a **Business** or **Enterprise** plan. Startup and free trial accounts cannot call the REST API, even with a valid key.
</Note>

## What you can build

| Use case | Primary endpoints |
| - | - |
| Visibility dashboards | `POST/GET /seo-site-report`, `/seo-site-report/history` |
| AI traffic analytics | `GET /ai-traffic/stats`, `/ai-traffic/sites` |
| Agency client reporting | Prefill, report, and history endpoints per workspace |
| Recommendation workflows | Report data + `POST /improve-content-*` |
| AI assistant integrations | `POST /chat` with `useWorkspaceContext: true` |

Start with the [AI visibility endpoints](/api-reference/ai-visibility) — they are the core of the API.

## Plan eligibility

| Plan | API access | Monthly AI credits |
| - | - | - |
| Free trial | No | 10 |
| Startup | No | 300 |
| Business | Yes | 500 |
| Enterprise | Yes | Unlimited |

Requests authenticated with an API key on a lower plan receive:

```json theme={null}
{
  "message": "API access requires a Business plan or higher.",
  "errCode": 403
}
```

## Base URL

```
https://api.krastie.ai
```

All documented routes are prefixed with `/v1`.

## Authentication

Send your API key in the `api-key` request header on every call:

```http theme={null}
api-key: krastie_abc123...
Content-Type: application/json
```

Keys use the `krastie_` prefix, expire **30 days** after generation, and are shown **only once** when created. Store them securely.

### Create and manage keys

Key management uses your logged-in Krastie session (cookie auth), not the API key itself.

| Method | Endpoint | Description |
| - | - | - |
| `GET` | `/v1/users/api-key` | Key metadata (prefix, expiry, name). Does not return the secret. |
| `POST` | `/v1/users/generateApiKey` | Create or rotate a key. Body: `{ "name": "My integration" }` |
| `DELETE` | `/v1/users/api-key` | Revoke the current key |

**Generate key response (200):**

```json theme={null}
{
  "message": "API key successfully generated. Save it securely - you won't be able to see it again.",
  "apiKey": "krastie_...",
  "apiKeyPrefix": "krastie_abc1234",
  "expiresAt": "2026-07-07T12:00:00.000Z"
}
```

## Usage and limits

* Each successful AI text or chat request consumes **1 AI credit** from your monthly plan allowance.
* Visibility report refresh limits vary by plan. See the [pricing page](https://www.krastie.ai/pricing).
* Image generation increments image-generation usage separately.
* When credits are exhausted, endpoints return `403` with a plan-specific limit message.
* Usage resets monthly for paid plans.

Premium models (`o1`, `o3-mini`, `gpt-5`, `gpt-4.5`) require a paid plan (Startup or above), not just API access.

## Response headers

All `/v1` routes include:

| Header | Value |
| - | - |
| `api-version` | `v1` |
| `deprecated` | `false` |

## Error format

Errors return JSON with `message` and usually `errCode`:

| Status | Meaning |
| - | - |
| `401` | Missing/invalid API key, expired key, or banned user |
| `403` | Plan not eligible, usage limit reached, or feature restricted |
| `404` | Resource not found (e.g. job ID) |
| `429` | Rate limit or refresh limit exceeded |
| `500` | Server error |

## Supported models

Text and chat endpoints accept model IDs from supported providers:

* **OpenAI:** `gpt-4o`, `gpt-4o-mini`, `gpt-4.1`, `o1`, `o3-mini`, and related GPT-family IDs
* **Anthropic:** Claude models (IDs containing `claude`)
* **Google:** Gemini models (IDs containing `gemini`)

Pass the same model identifiers you use in the Krastie app.

## Quick start

1. Upgrade to **Business** or **Enterprise**.
2. Log in at [app.krastie.ai](https://app.krastie.ai) and generate an API key under account settings.
3. Run a visibility report:

```bash theme={null}
# Suggest competitors and prompts
curl -X POST https://api.krastie.ai/v1/ai/generate/seo-site-report/prefill \
  -H "Content-Type: application/json" \
  -H "api-key: krastie_YOUR_KEY" \
  -d '{"websiteurl": "https://example.com"}'

# Run the report
curl -X POST https://api.krastie.ai/v1/ai/generate/seo-site-report \
  -H "Content-Type: application/json" \
  -H "api-key: krastie_YOUR_KEY" \
  -d '{
    "websiteurl": "https://example.com",
    "competitors": ["https://competitor.com"],
    "prompts": ["best tools for AI search visibility"]
  }'

# Fetch the latest results
curl https://api.krastie.ai/v1/ai/generate/seo-site-report \
  -H "api-key: krastie_YOUR_KEY"
```

## API sections

<CardGroup cols={2}>
  <Card title="AI visibility" icon="eye" href="/api-reference/ai-visibility">
    Reports, prefill, history, and workspace context.
  </Card>

  <Card title="AI traffic" icon="line-chart" href="/api-reference/ai-traffic">
    Track visits from AI assistants and pull traffic analytics.
  </Card>

  <Card title="AI generation" icon="sparkles" href="/api-reference/ai-generation">
    Content generation, SEO scoring, and improvement.
  </Card>

  <Card title="Chat sessions" icon="messages-square" href="/api-reference/chat-sessions">
    Assistant with visibility-aware workspace context.
  </Card>

  <Card title="Brand voice" icon="audio-lines" href="/api-reference/brand-voice">
    Manage brand voices for consistent content.
  </Card>
</CardGroup>

## Support

Questions about API access, Enterprise limits, or custom integrations: [info@krastie.ai](mailto:info@krastie.ai)


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