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

# API Reference

> Integrate Neural Factory into your applications with the REST API.

# API Reference

The Neural Factory REST API lets you programmatically interact with the platform — send messages to agents, manage knowledge bases, and retrieve analytics data.

## Base URL

All API requests are made to your Neural Factory instance:

```
https://app.neuralfactory.ai/api/v1
```

For enterprise deployments, replace with your custom domain.

## Authentication

All API requests require authentication using an API key. Include it as a Bearer token in the `Authorization` header:

```bash theme={null}
curl -X POST https://app.neuralfactory.ai/api/v1/chat \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "...", "message": "What is our remote work policy?"}'
```

API keys are created and managed in the [API Keys](/user-guide/admin/api-keys) section of the admin panel.

## Request format

* All request bodies should be JSON with `Content-Type: application/json`
* Dates are in ISO 8601 format
* IDs are strings (MongoDB ObjectIds)

## Response format

Successful responses return JSON with the relevant data:

```json theme={null}
{
  "status": "success",
  "data": { ... }
}
```

## Error handling

Error responses include a status code and error message:

```json theme={null}
{
  "status": "error",
  "message": "Description of what went wrong",
  "code": "ERROR_CODE"
}
```

### Common status codes

| Code  | Meaning                                   |
| ----- | ----------------------------------------- |
| `200` | Success                                   |
| `201` | Created                                   |
| `400` | Bad request — invalid parameters          |
| `401` | Unauthorized — missing or invalid API key |
| `403` | Forbidden — insufficient permissions      |
| `404` | Not found — resource doesn't exist        |
| `429` | Rate limited — too many requests          |
| `500` | Internal server error                     |

## Rate limits

API requests are subject to rate limiting based on your plan:

* **SaaS plans** — Rate limits vary by subscription tier
* **Enterprise** — Rate limits are configured per deployment

When rate limited, the API returns `429 Too Many Requests` with a `Retry-After` header indicating when you can retry.

## Streaming responses

Chat endpoints support streaming responses via Server-Sent Events (SSE). To receive streaming responses, set the `Accept` header:

```bash theme={null}
curl -X POST https://app.neuralfactory.ai/api/v1/chat \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"agent_id": "...", "message": "..."}'
```

## Endpoint documentation

<Note>
  Full auto-generated endpoint documentation from the OpenAPI spec will be available here once the API specification is published. The endpoints cover: agents, knowledge bases, documents, chat, search, users, groups, toolkits, analytics, and API key management.
</Note>

For now, refer to the platform's backend API routes for available endpoints. If you need specific API guidance, contact [support@neuralfactory.ai](mailto:support@neuralfactory.ai).
