
# Pagination and Field Selection

## Responses

A single resource comes back in `data`:

```json
{ "data": { "id": 1, "slug": "vendor", "label": "Vendor" } }
```

A list comes back in `data`, with `page_context` describing the page:

```json
{
  "data": [{ "id": 1, "slug": "vendor", "label": "Vendor" }],
  "page_context": { "count": 1, "page": 1, "per_page": 100, "total": 1, "has_more": false }
}
```

| Field | Meaning |
|---|---|
| `count` | Items on this page |
| `page` | This page's number |
| `per_page` | The page size used |
| `total` | Items across all pages |
| `has_more` | `true` if there's a next page |

## Pagination

Every list endpoint takes:

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | number | 1 | Page number, from 1 |
| `limit` | number | 100 | Items per page, up to 500 |

```bash
curl -X GET "https://mdm.finopsbricks.com/api/v1/records?object=1&page=2&limit=50" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET"
```

Keep requesting the next `page` while `has_more` is `true`.

## Field selection

Pass `fields` with a comma-separated list to get only those fields. Unknown names are ignored.

```bash
curl -X GET "https://mdm.finopsbricks.com/api/v1/objects?fields=id,slug" \
  -H "api-key: $MDM_API_KEY" \
  -H "api-secret: $MDM_API_SECRET"
```

```json
{ "data": [{ "id": 1, "slug": "vendor" }], "page_context": { "count": 1, "page": 1, "per_page": 100, "total": 1, "has_more": false } }
```

## Ordering

Each list has one fixed order, stated on its page: objects by label, fields by position, records by id, history newest first.
