Skip to main content

Before you start

Sign in to your Peak workspace. For runner and run history reads, connect GitHub and keep repository access. Install Node.js 22.13 or newer to use the CLI examples.

Connect a terminal or agent

Open the printed sign-in link. Match the code and approve access within ten minutes. Read the authenticated event after approval. Add run history access when needed.

Create a token

  1. Open Settings → API access.
  2. Choose Create token.
  3. Name the token.
  4. Select the access you need.
  5. Choose an expiry of 7, 30, or 90 days.
  6. Create the token.
  7. Copy it before you close the token view.
  8. Store it in your agent’s secret manager.
Set the token through this environment variable.
Use the matching scope for each task. Check which token you use before logging out. Unset the environment token to use your stored CLI login instead. Revoke the active token from the CLI.
Or choose Revoke beside the token in API access. Revoke CLI tokens separately from signing out of your browser.

Call the API

Send the token in the Authorization header. Use a token for API calls even when you are signed in through your browser.
Use these endpoints with the listed scopes. Check the metering flag in setup and runner-status responses. Treat zero minute balances as disabled credits during the pilot.
For pilot run records, handle this usage state without a metered duration.
For lists of runners, runner types, runs, or activity, read the pagination fields below. Pass the next cursor as the next request’s after query parameter.
For run filters, use these query parameters. Use a numeric GitHub ID for the repository filter.

Preview a workflow

Choose a label from the runner type catalog. Send the workflow text and job ID to the preview endpoint. Set this header for JSON requests.
Check the source hash before applying the returned change. Check the updated hash before applying its rollback. Read edit ranges as zero-based, end-exclusive UTF-16 string indices. Keep the decoded workflow under 128 KiB. Use workflow changes to choose between preview and setup.

Plan workflow changes

Send your repository name, default branch, released runner label, and workflow files to the planning endpoint.
Send 1–20 files with at least one GitHub Actions workflow. Keep each file under 64 KiB and the JSON request body under 256 KiB. Remove hardcoded secrets before sending files. Check the returned status before using the plan.
Review the returned files, diffs, notes, and moved and unmoved job counts. Apply ready changes through a pull request. Read the notes if the plan fails.

Handle errors

Read the error code, message, and request ID. Keep the request ID when reporting a failed request.
For a rate limit, wait for the delay in this response header before retrying.

Choose an API origin

Use the hosted origin by default.
For a local Peak instance, pass the origin explicitly.
Or set the origin through this environment variable.
Use HTTPS for remote origins. Use separate credential directories for independent agent sessions. Set each directory through this environment variable.