# The query language for tasks

Task lists take a query in `q`, in the same language as Advanced search in projqo. Learn it once and use it in the app, on boards and in the API.

```sh
curl -G "$PROJQO_API/orgs/$PROJQO_ORG/tasks" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  --data-urlencode 'q=project = WEB AND status IN ("To do", "In progress") ORDER BY updated DESC'
```

A query only ever finds tasks the person behind the token can open: it runs inside the same access rules as everything else.

## The shape of a query

Each condition is a **field**, an **operator** and a **value**:

- `project = WEB`
- `status IN ("To do", "In progress")`
- `assignee = currentUser()`
- `summary ~ login`

Join conditions with `AND`, `OR` and `NOT`. `AND` comes before `OR`, so use brackets when you mean otherwise: `project = WEB AND (type = Bug OR priority = High)`.

End with `ORDER BY` to choose the order: `ORDER BY rank`, `ORDER BY created DESC, key`. (The `sort` parameter does the same outside `q`.)

Field names, keywords and functions can be written in any letter case. Put a value in quotes when it has spaces or is a keyword: `status = "In review"`.

## Operators

| Operator                                            | Means                                                                   |
| --------------------------------------------------- | ----------------------------------------------------------------------- |
| `=`, `!=`                                           | Is, isn't. `!=` leaves out tasks with no value at all.                  |
| `IN (…)`, `NOT IN (…)`                              | One of a list.                                                          |
| `>`, `>=`, `<`, `<=`                                | Dates, numbers and estimates.                                           |
| `~`, `!~`                                           | Contains, doesn't contain, words (summary, description, comment, text). |
| `IS EMPTY`, `IS NOT EMPTY`                          | Has no value, has one.                                                  |
| `WAS`, `WAS IN`, `WAS NOT`, `WAS NOT IN`, `CHANGED` | What a task held before, or how it changed (see History).               |

## Fields

| Field                                                          | Values                                                                     |
| -------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `project`                                                      | A project's key or name.                                                   |
| `key`, `parent`                                                | A task key, such as `WEB-12`.                                              |
| `type`, `status`, `priority`, `resolution`                     | By name; `resolution` also takes `Unresolved`.                             |
| `statusCategory`                                               | `"To do"`, `"In progress"` or `"Done"`.                                    |
| `assignee`, `reporter`                                         | A person's email address or name, or `currentUser()`.                      |
| `labels`                                                       | A label, exactly as written.                                               |
| `flagged`                                                      | `yes` or `no`.                                                             |
| `summary`, `description`, `comment`, `text`                    | Words, with `~`.                                                           |
| `watcher`, `votes`                                             | Someone watching the task; how many people voted for it.                   |
| `created`, `updated`, `resolved`, `due`, `start`, `lastViewed` | Dates.                                                                     |
| `storyPoints`, `estimate`                                      | Numbers; an estimate can be `2h`, `1d` (8 hours) or `1w` (5 days).         |
| `sprint`                                                       | A sprint's name, or `openSprints()`, `futureSprints()`, `closedSprints()`. |
| `fixVersion`, `affectedVersion`                                | A release's name, or `releasedVersions()`, `unreleasedVersions()`.         |
| `component`                                                    | A component's name.                                                        |
| A custom field                                                 | By its name, in quotes when it has spaces: `"Customer tier" = Gold`.       |

A function that stands for a list needs no brackets after `IN`: `sprint IN openSprints()`.

## Dates and times

Write a day as `2026-11-23` (with a time if you like: `"2026-11-23 14:30"`), or a time from now: `-1d` is a day ago, `-2w` two weeks ago, `4h` four hours from now.

The functions `now()`, `startOfDay()`, `endOfDay()`, `startOfWeek()`, `endOfWeek()`, `startOfMonth()`, `endOfMonth()`, `startOfYear()` and `endOfYear()` take a time too: `startOfDay(-1d)` is the start of yesterday. A week starts on Monday.

:::note
Relative dates use the time zone of **the person behind the token**, not UTC and not the organisation's. Just after midnight in Kolkata, "today" in a query is already the new day there, even though it's still yesterday in UTC.
:::

## Words

`~` looks for whole words, in the organisation's search language: `summary ~ deploy` also finds "deployment" and "deployed" in English.

- Every word is needed: `text ~ "release checklist"` finds tasks with both words.
- A phrase in quotes inside the value keeps the words together: `summary ~ '"release checklist"'`.
- End a word with `*` to find every word that starts with it: `summary ~ deplo*`.

## History

Ask what a task's status, assignee, reporter, priority, resolution, type or parent used to be, or how it changed:

- `status WAS "In progress"`: it was In progress at some point, or is now.
- `status CHANGED FROM "To do" TO Done`: it moved that way at least once.
- Narrow either with `BY` (who), `AFTER`, `BEFORE`, `ON` and `DURING (start, end)`: `assignee CHANGED TO currentUser() AFTER -1w`.

## People and groups

`membersOf("Designers")` stands for the people in a group the person can see: `assignee IN membersOf("Designers")`.

## Mistakes

A query that can't be read answers `400 invalid`, with a message that says what was expected and where, for example "Expected ')' or ',' before the end of the query". A project, person, sprint or value the person can't see reads the same as one that doesn't exist.

## Saved filters

Instead of `q`, send `filter={id}` to run a saved filter the person may open.
