
# Tools

A tool is a small internal app in the dashboard: a table, a filter, a form, a few numbers, and buttons that run workflows. It works over the site's own data: collections, contacts, workflows and connections. A bookings desk, an enquiry triage board, a course roster.

Reading needs `tools:read`; creating, changing, deleting and running queries needs `tools:write`. Creating, changing and deleting are for owners and admins.

## Start from a template

`GET /sites/{siteId}/tool-templates` lists ready-made tools: `bookings-desk`, `enquiry-triage` and `course-roster`. Each names the **picks** it needs, such as which collection it shows or which workflow its button runs.

```json title="POST /sites/{siteId}/tools"
{ "templateId": "course-roster", "picks": { "collection": "courses" } }
```

Or create a blank tool with just a `name` and build its spec in the dashboard.

## The spec

`GET /sites/{siteId}/tools/{toolId}` answers the tool with its `spec`:

- `queries`: where data comes from. Each has an `id` and a `kind` (contacts, a collection, a workflow to run…) and may read component values through templates like `{{search.value}}`.
- `components`: what is on screen (`table`, `filter`, `stat` and others), each with an `id`, a place on the grid (`x`, `y`, `w`, `h`) and its props.

`PATCH …/tools/{toolId}` changes the name, icon, description, `spec`, who may use it (`access`) or whether it is `pinned` in the sidebar.

## Run a query

`POST …/tools/{toolId}/queries/{queryId}/run` runs one of the tool's queries with the component values it reads, as `scope`, and answers its rows or result:

```sh
curl https://api.unvop.com/v1/sites/site_…/tools/tool_…/queries/bookings/run \
  -H "Authorization: Bearer $UNVOP_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "scope": { "search": { "value": "Rivera" } } }'
```

This is how you reuse a tool's logic from your own code: the query runs with the same rules as when someone presses the button in the dashboard.
