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

# Reading and filtering

> How to read a list with GET, choose its columns, filter, sort and page it, and how to call an action with POST.

The API has two kinds of endpoint. A **list** such as `/assets` or `/work_orders` is read with GET, and
you shape the answer with query parameters. An **action** such as `/rpc/create_asset` is called
with POST, and its arguments are the keys of a JSON body.

## Choose the columns

`select` names the columns you want. Without it you get every column, which on `/assets` or
`/work_orders` is a lot.

```bash theme={null}
curl "https://app.assetinfinity.ai/api/assets?select=id,asset_number,name,status,site_name" \
  -H "Authorization: Bearer $TOKEN"
```

## Filter

Add a parameter named after a column, with an operator and a value:

| You want | Write |
| - | - |
| equal to | `status=eq.OPEN` |
| one of several | `status=in.(OPEN,ASSIGNED)` |
| greater or less than | `due_at=lt.2026-10-10T00:00:00Z`, `current_reading=gte.1000` |
| text containing, ignoring case | `name=ilike.*pump*` |
| empty, or not | `asset_id=is.null`, `asset_id=not.is.null` |

Several filters on one request must all match.

```bash theme={null}
curl "https://app.assetinfinity.ai/api/work_orders?select=work_order_number,status,priority,due_at&status=in.(OPEN,ASSIGNED)&priority=eq.HIGH" \
  -H "Authorization: Bearer $TOKEN"
```

The full set of operators is in [PostgREST's own reference](https://postgrest.org/en/stable/references/api/tables_views.html),
which is the server answering these requests.

## Sort and page

`order` sorts, and `limit` and `offset` page. Send `Prefer: count=exact` to learn how many rows match
in total. The answer then has a `Content-Range` header such as `0-1/10`, meaning rows 0 to 1 of 10.

```bash theme={null}
curl -i "https://app.assetinfinity.ai/api/work_orders?select=work_order_number,due_at&status=in.(OPEN,ASSIGNED)&order=due_at.asc&limit=2&offset=0" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Prefer: count=exact"
```

## Find an id

Actions take ids, and the record you have in hand usually has a code instead. Two ways to turn one into
the other:

* **Filter the list by its code.** Most lists carry the record's own number or code, so
  `/asset_meters?select=meter_id&code=eq.P-102-HRS` returns the meter whose code is `P-102-HRS`.
* **Ask `list_options`.** It returns the id and label of every record a field may point at, and takes a
  search term:

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/list_options \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_entity": "core.asset_categories", "p_search": "pump"}'
```

```json theme={null}
[{ "id": "7cd4438d-33c9-4d3f-9892-64b10ab6ac87", "label": "Centrifugal Pump", "path": "Rotating Equipment › Centrifugal Pump", "depth": 1 }]
```

## Call an action

Every action is a POST to `/rpc/<name>`. Each key of the JSON body is the name of one argument, and
an argument you leave out takes its default:

```bash theme={null}
curl -X POST https://app.assetinfinity.ai/api/rpc/record_meter_reading \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"p_meter_id": "a5e81b84-aeee-49fd-820f-009ed959c89a", "p_reading": 7864}'
```

An action that takes `p_values` takes a record's fields inside it, as an object. The page for each of
those actions, under **Integration API** in the sidebar, lists the fields.

## What you can see

A token sees what its account may see. A list returns only the rows at the sites the account can
reach, and an action is refused when the account does not hold its permission. Two accounts can
make the same request and get different answers, and both are correct.


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