# Requests, filters and pagination

Every Desktop Books endpoint is a `GET` under `https://desktop-app.greatwork.company/v1`. Lists come back in pages of up to 500 records with a `next_cursor`, filters narrow them by date, status or customer, and any list can come back as CSV. Nothing in the API writes to QuickBooks.

## Endpoints

| Endpoint | Returns |
| --- | --- |
| `GET /v1/me` | The key, its scope and its account |
| `GET /v1/files` | Your company files and their status |
| `GET /v1/files/{file_id}` | One company file |
| `GET /v1/files/{file_id}/status` | Last check-in, record counts and a plain sentence about the file's health |
| `GET /v1/files/{file_id}/{resource}` | A page of records, such as `customers`, `invoices` or `bills` |
| `GET /v1/files/{file_id}/{resource}/{qb_id}` | One record by its QuickBooks ListID or TxnID |
| `GET /v1/files/{file_id}/reports/{report}` | A QuickBooks report: `profit-and-loss`, `balance-sheet`, `ar-aging`, `ap-aging` or `job-profitability` |
| `GET /v1/files/{file_id}/power-query/{name}` | A ready Power Query for a resource or report, for Excel (see [Excel and Power Query](/docs/excel-power-query)) |
| `GET /v1/jobs/{job_id}` | The answer to a queued read (see [No-copy mode](/docs/no-copy-mode)) |

The 18 resources, with every field, are in [the API reference](/docs/api).

## Filters

| Parameter | Works on | Example |
| --- | --- | --- |
| `modified_since` | Every list | `modified_since=2026-11-01T00:00:00-06:00`, or a date |
| `date_from`, `date_to` | Transactions (invoices, bills, checks...) | `date_from=2026-10-01&date_to=2026-10-31` |
| `status` | Lists with an open or active state | `status=open` on invoices, `status=overdue` on invoices and bills, `status=active` on customers |
| `customer` | Customers and customer transactions | `customer=Acme Construction` includes that customer's jobs |
| `vendor` | Bills, bill payments, purchase orders | `vendor=Northside Lumber` |
| `payee` | Checks | `payee=City of Plano` |
| `fields` | Every list | `fields=number,customer,balance` (the id always comes back) |
| `order` | Every list | `date` (newest first, the default for transactions), `modified` (oldest change first) or `id` |
| `limit` | Every list | 1 to 500 records, 100 by default |

Each resource accepts its own status words (invoices: open, paid; payments: unused, applied; purchase orders: open, received), all listed on its reference page. A filter that doesn't apply, such as `date_from` on customers, answers `400 bad_parameter` with a message that names it, so a typo never silently returns everything.

## Pages

A list answers with up to `limit` records, `has_more`, and `next_cursor`:

```json
{
  "object": "list",
  "resource": "customers",
  "file_id": "file_8f2c41",
  "data": [
    { "id": "80000004-1700000000", "name": "Acme Construction", "balance": 4250 }
  ],
  "next_cursor": "c_9f31...",
  "has_more": true,
  "synced_at": "2026-11-29T07:04:12-06:00",
  "as_of": "2026-11-29T07:03:58-06:00"
}
```

Send the cursor back as `cursor` with the same filters until `next_cursor` is `null`:

```bash
curl -H "Authorization: Bearer dbk_your_key" \
  "https://desktop-app.greatwork.company/v1/files/file_8f2c41/customers?limit=500&cursor=c_9f31..."
```

The same cursor is in the `X-Next-Cursor` header and a `Link: <...>; rel="next"` header, for tools that follow links. A cursor belongs to the filters it came with: changing a filter mid-way answers `400 bad_cursor`.

Ask for `limit=500` when you read everything. A file with 3,400 invoices is 7 requests at 500 a page and 34 at the default 100, and the per-key limit is 60 requests a minute ([Limits](/docs/limits)).

## Keeping your own copy current

To mirror a company file into your own database, read each list once in full, then poll for changes:

1. Page through `GET /v1/files/{id}/invoices?order=modified&limit=500` and store the newest `modifiedAt` you saw.
2. Next time, ask for `modified_since=<that value>&order=modified`. Records come oldest change first, so if a run stops halfway, the value you stored is still a safe place to resume.
3. Deleted records stop appearing in lists after the daily deleted sweep ([Freshness and sync](/docs/freshness-and-sync)). To catch them, compare ids with a full read now and then.

Polling more often than the file checks in returns the same data, so match your schedule to the file's interval (60 minutes by default).

## CSV

Add `format=csv`, or send `Accept: text/csv`, and the same records come back as CSV with one flat row per record. References become two columns (`customer_id` and `customer_name`), and the freshness moves to the `X-Synced-At` and `X-As-Of` headers.

```bash
curl -H "Authorization: Bearer dbk_your_key" \
  "https://desktop-app.greatwork.company/v1/files/file_8f2c41/customers?format=csv&fields=fullName,email,balance&limit=500" \
  -o customers.csv
```

| Option | Gives |
| --- | --- |
| `format=csv` | CSV, one row per record |
| `format=csv&rows=lines` | CSV, one row per line item (invoices, bills, estimates and other transactions with lines) |
| `flat=1` | The flat rows as JSON, for tools that want columns without nesting |

## Freshness in every answer

Every response carries `synced_at` (when that list last finished syncing) and `as_of` (the check-in the data comes from). If they are older than you expect, `GET /v1/files/{id}/status` says why in words, such as "Your office PC hasn't checked in since 6:10 PM".

The machine-readable description of all of this is [the OpenAPI document](https://desktop-app.greatwork.company/openapi.json), which code generators and coding assistants can read directly.

Previous: [Authentication](/docs/authentication) | Next: [Freshness and sync](/docs/freshness-and-sync)
