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

# InsForge REST API overview

> Call InsForge auth, database, storage, and functions directly over HTTP with any language, using API keys, JWTs, and standard REST conventions.

The InsForge REST API provides direct HTTP access to all InsForge services. Use this when you need to integrate with languages or platforms without an official SDK.

## Base URL

```
https://your-app.insforge.app
```

## Authentication

All API requests require authentication via the `Authorization` header:

### Bearer token

```bash theme={null}
Authorization: Bearer your-jwt-token-or-anon-key
```

## Quick start

```bash theme={null}
# Register a new user
curl -X POST https://your-app.insforge.app/api/auth/users \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "securepassword123"}'

# Sign in and get token
curl -X POST https://your-app.insforge.app/api/auth/sessions \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "securepassword123"}'

# Use the token for authenticated requests
curl https://your-app.insforge.app/api/database/records/posts \
  -H "Authorization: Bearer your-jwt-token"
```

## Response format

### Success response

Data is returned directly in the response body:

```json theme={null}
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "email": "user@example.com",
  "createdAt": "2024-01-15T10:30:00Z"
}
```

### Error response

```json theme={null}
{
  "error": "ERROR_CODE",
  "message": "Human-readable error message",
  "statusCode": 400,
  "nextActions": "Suggested action to resolve the error"
}
```

## Common HTTP status codes

| Status | Description                             |
| ------ | --------------------------------------- |
| `200`  | Success                                 |
| `201`  | Created                                 |
| `204`  | No Content (for DELETE)                 |
| `400`  | Bad Request - Invalid input             |
| `401`  | Unauthorized - Invalid or missing token |
| `403`  | Forbidden - Insufficient permissions    |
| `404`  | Not Found                               |
| `409`  | Conflict - Resource already exists      |
| `500`  | Internal Server Error                   |

## Features

* **Database** - PostgREST-style CRUD operations
* **Authentication** - Email/password and OAuth authentication
* **Storage** - File upload, download, and management
* **Functions** - Invoke serverless edge functions
* **AI** - Chat completions and image generation
* **Realtime** - Channel management and message history (WebSocket for real-time)

## API reference

<CardGroup cols={2}>
  <Card title="Database" icon="database" href="/sdks/rest/database">
    CRUD operations, filters, and queries
  </Card>

  <Card title="Authentication" icon="lock" href="/sdks/rest/auth">
    Sign up, sign in, OAuth, and user management
  </Card>

  <Card title="Storage" icon="cloud-arrow-up" href="/sdks/rest/storage">
    File upload, download, and management
  </Card>

  <Card title="Functions" icon="bolt" href="/sdks/rest/functions">
    Invoke serverless edge functions
  </Card>

  <Card title="AI" icon="brain" href="/sdks/rest/ai">
    Chat completions and image generation
  </Card>

  <Card title="Realtime" icon="signal-stream" href="/sdks/rest/realtime">
    Channel management and message history
  </Card>
</CardGroup>
