# Hex

> Discover Hex data-science projects, run published projects with inputs, and poll or cancel their runs via the Hex API.

Lets an agent work with your Hex data-science notebooks and data apps: list and inspect projects, kick off runs of published projects with input parameters, poll a run's status until it finishes, cancel a run in flight, and review a project's run history.

## What it can do

| Method | What it does |
| --- | --- |
| `hex_projects_list` | List projects you can access (limit, cursor, include archived/trashed). |
| `hex_project_get` | Get one project's metadata, schedules, and input parameters. |
| `hex_project_run` | Run a published project with optional input parameters; returns a run id. |
| `hex_run_status` | Get the status, timings, and result URLs of a run. |
| `hex_run_cancel` | Cancel a running project run. |
| `hex_runs_list` | List a project's run history (limit, offset, status filter). |
| `hex_request` | Generic passthrough to any Hex endpoint for full API coverage. |

## How to get your token

Hex authenticates with a Bearer API token.

1. Sign in at [app.hex.tech](https://app.hex.tech).
2. Open **Settings** and find the **API keys** section.
3. Create a token, copy it, and paste it into FlyMyAI. See the [Hex API reference](https://learn.hex.tech/docs/api/api-reference) for details.

## Fields to fill

| FlyMyAI field | Where it comes from |
| --- | --- |
| `HEX_API_TOKEN` | Hex -> Settings -> API keys |

## Troubleshooting

- **`401 Unauthorized`** - the token is wrong or revoked. Create a new token in Hex Settings -> API keys.
- **`404 Not Found` on run** - the project must be published to run via the API, and the token's workspace must have access to it.
- **Run stays `PENDING` / `RUNNING`** - runs are asynchronous; poll `hex_run_status` with the run id until it reaches `COMPLETED` or `ERRORED`.
- **`422` on `hex_project_run`** - an input parameter name or type does not match the project; check the project's parameters with `hex_project_get`.

## Links

- [Hex](https://hex.tech)
- [Hex API reference](https://learn.hex.tech/docs/api/api-reference)
