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

# API Overview

> Complete EngageFabric REST API reference. Explore endpoints for players, events, quests, leaderboards, and achievements with interactive examples.

The EngageFabric API is a RESTful API that allows you to integrate gamification features into your applications. All API endpoints are versioned and follow consistent patterns.

## Base URL

```
https://api.engagefabric.com/api/v1
```

## Authentication

All API requests require authentication via API key:

```bash theme={null}
curl -X GET "https://api.engagefabric.com/api/v1/players" \
  -H "X-API-Key: your-api-key"
```

See [Authentication](https://docs.engagefabric.com/authentication.md) for detailed information.

***

## Request Format

### Headers

| Header | Required | Description |
| - | - | - |
| `X-API-Key` | Yes | Your project API key |
| `Content-Type` | Yes\* | `application/json` for POST/PUT/PATCH |
| `X-Idempotency-Key` | No | Unique key for idempotent requests |

### Request Body

All request bodies should be JSON:

```json theme={null}
{
  "externalUserId": "user-123",
  "displayName": "John Doe",
  "metadata": {
    "email": "john@example.com"
  }
}
```

***

## Response Format

### Success Response

```json theme={null}
{
  "id": "player-uuid",
  "externalUserId": "user-123",
  "displayName": "John Doe",
  "xp": 1500,
  "level": 5,
  "createdAt": "2025-01-21T10:00:00Z",
  "updatedAt": "2025-01-21T12:00:00Z"
}
```

### Error Response

```json theme={null}
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request parameters",
    "details": [
      {
        "field": "externalUserId",
        "message": "Must be a non-empty string"
      }
    ],
    "requestId": "req-abc123",
    "timestamp": "2025-01-21T10:00:00Z"
  }
}
```

***

## HTTP Status Codes

| Status | Description |
| - | - |
| `200 OK` | Request succeeded |
| `201 Created` | Resource created successfully |
| `400 Bad Request` | Invalid request parameters |
| `401 Unauthorized` | Missing or invalid authentication |
| `403 Forbidden` | Insufficient permissions |
| `404 Not Found` | Resource not found |
| `409 Conflict` | Resource already exists |
| `429 Too Many Requests` | Rate limit exceeded |
| `500 Internal Server Error` | Server error |

***

## Pagination

List endpoints support pagination:

```bash theme={null}
GET /api/v1/players?page=1&limit=20
```

**Response:**

```json theme={null}
{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  }
}
```

***

## Filtering & Sorting

Many endpoints support filtering and sorting:

```bash theme={null}
# Filter by status
GET /api/v1/quests?status=ACTIVE

# Sort by creation date
GET /api/v1/players?sort=createdAt&order=desc
```

***

## Idempotency

For POST requests, use the `X-Idempotency-Key` header to ensure idempotent operations:

```bash theme={null}
curl -X POST "https://api.engagefabric.com/api/v1/events" \
  -H "X-API-Key: your-api-key" \
  -H "X-Idempotency-Key: unique-request-id" \
  -H "Content-Type: application/json" \
  -d '{"name": "purchase_completed", "playerId": "..."}'
```

> [!NOTE]
>
> Idempotency keys are valid for 24 hours. Requests with the same key within
> this window will return the same response.

***

## API Endpoints

> [card] [Players](https://docs.engagefabric.com/api-reference/players/overview)
>
> Manage player profiles, XP, levels, and currencies

> [card] [Events](https://docs.engagefabric.com/api-reference/events/overview)
>
> Track player actions and trigger gamification rules

> [card] [Quests](https://docs.engagefabric.com/api-reference/quests/overview)
>
> Create and manage quest progress

> [card] [Adventures](https://docs.engagefabric.com/api-reference/adventures/overview)
>
> Seasonal content and quest collections

> [card] [Leaderboards](https://docs.engagefabric.com/api-reference/leaderboards/overview)
>
> Real-time rankings and competitions

> [card] [Lobbies](https://docs.engagefabric.com/api-reference/lobbies/overview)
>
> Multiplayer lobby management

> [card] [Chat](https://docs.engagefabric.com/api-reference/chat/overview)
>
> Real-time messaging

> [card] [Rules](https://docs.engagefabric.com/api-reference/rules/overview)
>
> Configure gamification logic

***

## SDKs

We provide official SDKs for easier integration:

| Language | Package | Documentation |
| - | - | - |
| JavaScript/TypeScript | `@engagefabricsdk/sdk` | [SDK Docs](https://docs.engagefabric.com/sdks/javascript.md) |
| React | `@engagefabricsdk/react` | [React Docs](https://docs.engagefabric.com/sdks/react.md) |

***

## OpenAPI Specification

Download the complete OpenAPI specification:

> [card] [OpenAPI Spec](https://docs.engagefabric.com/api-reference/openapi.json)
>
> Download the OpenAPI 3.0 specification for code generation and API exploration


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