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

# ERM Open API

> Technical specification for the ERM Open API

The ERM API implements uses RESTful principles to provide consistent, basic data about servers data that you can integrate with your services.

## Authentication Protocol

The API implements stateless authentication using cryptographically secure tokens.

### Implementation Pattern

Requests must include the token in the Authorization header and the Guild in the Guild header:

```bash theme={null}
curl -X GET \
  -H "Authorization: ${TOKEN}" \
  -H "Guild: $GUILD_ID" \
  -H "Content-Type: application/json" \
  https://core.ermbot.xyz/api/v1/shifts
```

## Response Schema

The API implements a normalized response envelope pattern:

```typescript theme={null}
interface ResponseEnvelope<T> {
  data: T[];              // Resource collection
  pagination: {
    next_cursor: number;  // Temporal cursor position
    limit: number;        // Result set boundary
    has_more: boolean;    // Collection continuation flag
  }
}
```

## Cursor-Based Pagination Implementation

The API implements resource-specific pagination mechanisms:

### Resource-Specific Cursor Types

#### Shifts

* Type: Unix Timestamp (float)
* Format: Base-10 decimal timestamp
* Example: `1736302471.07677`
* Usage: Time-based ordering of shift records

#### Moderations

* Type: Discord Snowflake (int64)
* Format: Discord-generated unique ID
* Example: `1090340521350131742`
* Usage: Discord event sequencing

#### Leaves

* Type: Unix Epoch (int64)
* Format: Seconds since Unix epoch
* Example: `1702544876`
* Usage: Chronological ordering of leave records

### Query Parameters

| Parameter | Type      | Description                         |
| --------- | --------- | ----------------------------------- |
| `after`   | Varies    | Cursor position (see resource type) |
| `limit`   | `integer` | Result set size constraint          |

### Implementation Examples

```bash theme={null}
# Shifts - Unix timestamp cursor
GET /api/v1/shifts?after=1736302471.07677&limit=50

# Moderations - Snowflake cursor
GET /api/v1/moderations?after=1090340521350131742&limit=50

# Leaves - Epoch timestamp cursor
GET /api/v1/leaves?after=1702544876&limit=50
```

## Error Handling

When an error occurs, you'll receive:

```json theme={null}
{
  "status": 400,
  "message": "Error description",
  "error_code": "ERROR_TYPE"
}
```
