---
title: API Reference
description: Use the Marseil AI REST API for custom integrations
---


# API Reference

If you need a custom integration, you can use our chat API. You need the API key for that. Get it from the **Settings** tab in your project. If no key exists, click **Generate** and copy it.

> **Warning:** Do not expose your API keys and tokens in the frontend. Use a backend service to proxy your API calls.

## Parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `projectId` | string | From the Settings page under API section | Yes |
| `question` | string | The question you want to ask | Yes |
| `conversationId` | string | Chat ID to have a continuous conversation | No |
| `userId` | string | Identify users with email or unique ID (visible in chat history) | No |
| `additionalDetails` | json | Custom fields like email, name, and other IDs | No |

## Example Request

```js
fetch('https://app.marseil.ai/api/v1/chat', {
  method: 'POST',
  body: JSON.stringify({
    projectId: '<project_id>',
    question: '<your_question>'
  }),
  headers: {
    'Authorization': 'Bearer <api_key>',
    'Content-Type': 'application/json'
  }
})
```

## Success Response

```json
{
  "tokens": 724,
  "answer": "The answer to your question",
  "sources": "https://marseil.ai/pricing,https://marseil.ai/analytics",
  "limitReached": false,
  "conversationId": "clgyrh8vm0003u1kix801l4qz"
}
```

## Error Responses

**Invalid `projectId`:**
```json
{ "message": "project not found" }
```

**Invalid Bearer token:**
```json
{ "message": "unauthourised request" }
```

**Invalid request body:**
```json
{ "message": "Something happened! Please check your data validity or contact help" }
```

Contact `Support@Marseil.ai` if you believe there is a server issue.

---

## Export Conversations

Retrieve all conversations for a project as a CSV file. Useful for analysis, reporting, and backup.

### `GET /api/v1/conversations`

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `projectId` | string | From the Settings page under API section | Yes |
| `orgId` | string | Your organization ID | Yes |

### Example Request

```js
fetch('https://app.marseil.ai/api/v1/conversations?projectId=<project_id>&orgId=<org_id>', {
  headers: {
    'Authorization': 'Bearer <api_key>'
  }
})
```

The response is a CSV file download with the following columns:

| Column | Description |
|--------|-------------|
| Conversation ID | Unique conversation identifier |
| Date | ISO 8601 timestamp |
| Source | `DASHBOARD`, `WIDGET`, `SLACK`, or `API` |
| Visitor Email | User email or ID (from `userId` field) |
| Rating | `POSITIVE`, `NEGATIVE`, or `NEUTRAL` |
| Summary | AI-generated conversation summary |
| Message Role | `user` or `assistant` |
| Message | The message content |
| Feedback | `positive`, `negative`, or empty |

Each conversation produces one row per message. The server streams the CSV in batches of 100 conversations to avoid overloading, so large datasets are handled efficiently.

### Example Response

```csv
Conversation ID,Date,Source,Visitor Email,Rating,Summary,Message Role,Message,Feedback
clgyrh8vm0003u1kix801l4qz,2026-07-13T10:30:00.000Z,WIDGET,user@example.com,POSITIVE,User asked about pricing,user,How much does the pro plan cost?,
clgyrh8vm0003u1kix801l4qz,2026-07-13T10:30:00.000Z,WIDGET,user@example.com,POSITIVE,User asked about pricing,assistant,The pro plan is $49/month.,
```

### Error Responses

**Missing `projectId` or `orgId`:**
```json
{ "message": "projectId is required" }
```

**Unauthorized:**
```json
{ "message": "Unauthorized" }
```
