> ## Documentation Index
> Fetch the complete documentation index at: https://hc.saas-manager.biz.nuro.jp/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination

> List endpoints in the IT Management API support cursor-based pagination. Use the `cursor` and `limit` parameters to control which results are returned.

## Pagination Types

The IT Management API primarily uses **cursor-based** pagination. A small number of endpoints (users) use page-number pagination.

## Cursor-Based Pagination (Primary)

Most list endpoints (people / services / devices / identity / event-logs / contracts / alerts, etc.) use cursor-based pagination.

### Request Parameters

| Parameter | Type   | Default | Maximum | Description                                                                         |
| --------- | ------ | ------- | ------- | ----------------------------------------------------------------------------------- |
| `cursor`  | string | —       | —       | The `nextCursor` value from the previous response. Omit to start from the beginning |
| `limit`   | number | —       | 200     | Number of items to return per request                                               |

<Info>
  For the `event-logs` endpoint, the request parameter is named `nextCursor` instead of `cursor`.
</Info>

### Response Format

```json theme={null}
{
  "meta": {
    "nextCursor": "F3UdkoSbpBNrjwP93AX2HQ",
    "totalItems": 100
  },
  "items": [
    // Array of resources
  ]
}
```

### Response Fields

| Field             | Type            | Description                                            |
| ----------------- | --------------- | ------------------------------------------------------ |
| `meta.nextCursor` | string \| null  | Cursor for the next page. `null` when on the last page |
| `meta.totalItems` | integer \| null | Total item count. May be `null`                        |
| `items`           | array           | Array of resources                                     |

### Examples

```bash theme={null}
# Retrieve the first page
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.itmc.i.moneyforward.com/api/v1/organizations/YOUR_ORG_ID/people?limit=50"

# Retrieve the next page (using nextCursor from previous response)
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.itmc.i.moneyforward.com/api/v1/organizations/YOUR_ORG_ID/people?cursor=F3UdkoSbpBNrjwP93AX2HQ&limit=50"
```

```javascript theme={null}
async function fetchAllPeople(orgId) {
  const allItems = [];
  let cursor = undefined;

  do {
    const params = new URLSearchParams({ limit: '200' });
    if (cursor) params.set('cursor', cursor);

    const response = await fetch(
      `https://api.itmc.i.moneyforward.com/api/v1/organizations/${orgId}/people?${params}`,
      { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
    );

    const data = await response.json();
    allItems.push(...data.items);
    cursor = data.meta.nextCursor;
  } while (cursor);

  return allItems;
}
```

## Page-Number Pagination (users endpoint)

`GET /api/v1/organizations/{id}/users` uses page-number pagination.

### Request Parameters

| Parameter | Type   | Description             |
| --------- | ------ | ----------------------- |
| `page`    | number | Page number (1-indexed) |
| `limit`   | number | Items per page          |

### Response Format

```json theme={null}
{
  "metadata": {
    "prevPage": 1,
    "nextPage": 3
  },
  "users": [
    // Array of users
  ]
}
```

## Best Practices

1. Loop until `nextCursor` is `null` to retrieve all items
2. Avoid setting `limit` higher than necessary (maximum: 200)
3. Do not rely on `totalItems` for loop termination — use `nextCursor` instead, as `totalItems` may be `null`
