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

# Multi-step API checks

> Upload a code bundle and create a scheduled Multi-step API monitor using the published API

Use a multi-step API check when availability depends on several requests succeeding together. A token endpoint returning 200 does not prove that a caller can create an invoice and read it back.

Write the sequence as a Playwright test that uses the request fixture. Assert the expected response at each step and clean up resources your test creates. Use test accounts and data suitable for repeated execution against the target environment.

## Prepare your bundle

Put the test entrypoint and the local files it imports in one set. Paths are relative to the bundle root: `tests/invoice.spec.ts` identifies that file, not an absolute path on your computer.

You need:

* The file contents, as a JSON map of path to text, or a ZIP of those files
* The entrypoint path
* An environment ID in the monitor's workspace

DevHelm computes the bundle digest from the import closure. Do not hash the ZIP yourself and send that hash as the bundle id. The same files always return the same digest.

Do not include credentials in the bundle. Set sensitive values through your environment's secret bindings and read them from `process.env` in the test. The upload rejects a literal secret in a source file, a dotfile, or a symlink.

## Upload and create the monitor

Authenticate with a token that can write monitors in the selected workspace. Set `DEVHELM_API_TOKEN`, `DEVHELM_WORKSPACE_ID`, and `ENVIRONMENT_ID` before running the examples.

### Upload the bundle

```bash API theme={null}
curl -sS -X POST "https://api.devhelm.io/api/v1/bundles" \
  -H "Authorization: Bearer $DEVHELM_API_TOKEN" \
  -H "x-phelm-workspace-id: $DEVHELM_WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d "{\"entrypoint\":\"tests/invoice.spec.ts\",\"files\":{\"tests/invoice.spec.ts\":\"import { expect, test } from '@playwright/test';\n\ntest('invoice roundtrip', async ({ request }) => {\n  const created = await request.post('/invoices', { data: { sku: 'meter' } });\n  expect(created.ok()).toBeTruthy();\n});\n\"}}"
```

The response `data.digest` is `sha256:` followed by 64 hexadecimal characters. Use that value as `code.bundle`. `data.files` is the import closure. `data.keys` lists secret names found in that closure. `data.uploadDigest` covers every file you sent, which matches `data.digest` when the map is already the closure.

A ZIP body is the same upload. Set `Content-Type: application/zip` and pass the entrypoint as a query parameter:

```bash API theme={null}
curl -sS -X POST "https://api.devhelm.io/api/v1/bundles?entrypoint=tests/invoice.spec.ts" \
  -H "Authorization: Bearer $DEVHELM_API_TOKEN" \
  -H "x-phelm-workspace-id: $DEVHELM_WORKSPACE_ID" \
  -H "Content-Type: application/zip" \
  --data-binary "@invoice.zip"
```

An unreferenced bundle expires after 24 hours. Create or update the monitor with `data.digest` before then. Sending the same closure again returns the existing bundle.

### Create the monitor

```bash API theme={null}
curl -sS -X POST "https://api.devhelm.io/api/v1/monitors" \
  -H "Authorization: Bearer $DEVHELM_API_TOKEN" \
  -H "x-phelm-workspace-id: $DEVHELM_WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d "{\"name\":\"invoice-roundtrip\",\"type\":\"MULTI_STEP_API\",\"environmentId\":\"$ENVIRONMENT_ID\",\"config\":{\"timeoutSeconds\":30},\"frequencySeconds\":3600,\"regions\":[\"us-east\"],\"code\":{\"bundle\":\"$BUNDLE_DIGEST\",\"entrypoint\":\"tests/invoice.spec.ts\"}}"
```

Set `BUNDLE_DIGEST` to `data.digest` from the upload. The entrypoint must be one of the files in that closure. Do not send `files`, `keys`, or `config.script`. The server derives the file list and secret names from the bundle.

Browser and multi-step API checks default to a 30 second timeout. The maximum is 240 seconds.

The minimum frequency and run allowance depend on your plan. The example uses a one-hour interval; check the workspace's limits before selecting a faster schedule or additional regions.

> [!NOTE]
>
> Do not send an inline `config.script` or HTTP-monitor assertion objects for a
> code monitor. The bundle contains the test and its assertions. An environment
> is required.

## Inspect the result

Open the monitor in the dashboard and inspect its run history. A failed request or assertion makes the test fail. Review the recorded evidence and runner output to understand which condition was not met.

**Run now** is a real run, with normal usage accounting. The synchronous uptime-monitor **Test** action is not supported for this check type.

## Update the test

Upload the changed files with `POST /api/v1/bundles`, then publish that digest on the monitor. Sending `code` on update replaces the published revision.

```bash API theme={null}
curl -sS -X PUT "https://api.devhelm.io/api/v1/monitors/<monitor-id>" \
  -H "Authorization: Bearer $DEVHELM_API_TOKEN" \
  -H "x-phelm-workspace-id: $DEVHELM_WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d "{\"code\":{\"bundle\":\"$BUNDLE_DIGEST\",\"entrypoint\":\"tests/invoice.spec.ts\"}}"
```

Keep the entrypoint aligned with a file in the uploaded closure. Optional `code.source` can record `repo`, `branch`, `commit`, and `file`.

> [card] [Synthetics overview](https://docs.devhelm.io/synthetics/overview.md)
>
> Choose Browser or API checks and understand their schedules and evidence.

> [card] [API authentication](https://docs.devhelm.io/authentication.md)
>
> Set up access to the workspace that owns your monitors.


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