Skip to the content

API documentation

Start audits from a script or from CI with an API key, and read their results. This page is the short guide. The full reference is at the end.

Before you start

The API runs the same audits as the app, with the same credits, and gives back the same scores and findings.

Create a key in Settings, on the API keys tab. The key is shown once, when you create it, so store it in your CI secrets. A key starts with pr_.

Open Settings to create a key

The base address of the API is the address of this site followed by /api/v1.

https://chyosi.com/api/v1

Send the key in the Authorization header of every request. A missing, wrong or revoked key gets the answer 401 with the code unauthorized.

Authorization: Bearer YOUR_KEY

The examples on this page read the key from the environment variable CHYOSI_API_KEY. Set it, then check that the key works. The check reads your plan and your credits and starts nothing.

export CHYOSI_API_KEY="paste the key here"
curl -s "https://chyosi.com/api/v1/me/usage" \
  -H "Authorization: Bearer $CHYOSI_API_KEY"

A working key gets the answer 200 with your plan, your credits and the limits of your plan.

Start an audit

An audit belongs to a project. List your projects and take the id of the one to audit. Projects are made in the app, or with POST /api/v1/projects.

curl -s "https://chyosi.com/api/v1/projects" \
  -H "Authorization: Bearer $CHYOSI_API_KEY"

Start the audit with a POST to the runs of the project, with the kind in the body: quick or full. Replace PROJECT_ID with the id. The Idempotency-Key header is optional, and explained below.

curl -s -X POST "https://chyosi.com/api/v1/projects/PROJECT_ID/runs" \
  -H "Authorization: Bearer $CHYOSI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ci-build-1234" \
  -d '{"kind":"quick"}'

Credits: a quick audit costs 1, a full audit costs 5.

A full audit needs a plan that includes full audits and a site you have verified in the app. A quick audit needs neither.

The answer is 201 with the run: its id, its status (queued at first), score, scores and summary (null until the audit ends) and creditsCharged. Keep the id: you need it to read the result.

A project runs one audit at a time. Starting another while one is queued or running gets the answer 409 with the code run_already_active, and details.runId is the id of the audit in progress. Not enough credits gets 402 with the code insufficient_credits.

To make a retry safe, send an Idempotency-Key header of 1 to 200 visible ASCII characters, with one value for each audit you mean to start, such as the number of the CI build. A repeat with the same key for the same project starts nothing and charges nothing: the answer is 200 with the run that the first request created.

Wait for the result

An audit runs in the background. Read the run with GET /api/v1/runs/{id} every 10 seconds until its status is no longer queued or running.

curl -s "https://chyosi.com/api/v1/runs/RUN_ID" \
  -H "Authorization: Bearer $CHYOSI_API_KEY"

The statuses:

  • queued: Waiting to start. Keep reading.
  • running: In progress. Keep reading.
  • succeeded: The audit is complete.
  • succeeded with partial set to true: The audit is complete, but some parts were skipped.
  • failed: The audit failed. Your credits were returned.
  • blocked: The site did not let the audit in. Your credits were returned.
  • cancelled: The audit was cancelled. Credits for this audit were used.

An audit has a time limit: a quick audit stops after 5 minutes and a full audit after 30 minutes. Give your script a limit of its own that is longer than that, since an audit can wait in the queue before it starts.

When the status is succeeded, score is a number from 0 to 100 and scores holds a score for each category, with null for a category that was not measured. summary has a headline, an overview and fixFirst, the list of what to fix first.

{
  "id": "run_01J9ZK3Q8X5V7N2M4T6W8Y0A1B",
  "projectId": "prj_01J9ZK2P7W4U6M1L3S5V7X9Z0C",
  "kind": "quick",
  "status": "succeeded",
  "trigger": "api",
  "partial": false,
  "score": 78,
  "scores": {
    "functional": null,
    "security": 70,
    "performance": 85,
    "seo": 80,
    "accessibility": 75
  },
  "summary": {
    "headline": "Two security headers are missing",
    "overview": "The pages load fast and read well. The security headers need work.",
    "fixFirst": [
      "Add a Content-Security-Policy header"
    ],
    "testedPages": 10,
    "upsell": null
  },
  "creditsCharged": 1,
  "modelTier": "standard",
  "errorCode": null,
  "queuePosition": null,
  "createdAt": 1800000000000,
  "startedAt": 1800000004000,
  "finishedAt": 1800000118000
}

To stop an audit, send a POST to POST /api/v1/runs/{id}/cancel. An audit that has already finished gets the answer 409 with the code run_not_cancellable.

Read the findings

GET /api/v1/runs/{id}/findings lists the findings of a run. Filter with the query parameters category (functional, security, performance, seo, accessibility) and severity (critical, high, medium, low, info), one value of each.

curl -s "https://chyosi.com/api/v1/runs/RUN_ID/findings?category=security&severity=high" \
  -H "Authorization: Bearer $CHYOSI_API_KEY"

GET /api/v1/runs/{id}/diff compares a run with an earlier run of the same project, named by the query parameter base, which is required. The answer lists the ids of the findings that are new, fixed and remaining. When the run is partial, a finding it did not see is listed under notSeen and not under fixed. Two runs of different projects get the answer 400.

curl -s "https://chyosi.com/api/v1/runs/RUN_ID/diff?base=EARLIER_RUN_ID" \
  -H "Authorization: Bearer $CHYOSI_API_KEY"

GET /api/v1/runs/{id}/scenarios lists the flows that a full audit walked through, each with its steps and its result. For a quick audit the list is empty.

POST /api/v1/runs/{id}/pdf makes the PDF of the report of an audit that succeeded. PDF export is a feature of the paid plans: on the Free plan the answer is 403 with the code plan_limit_reached. You can make at most 10 PDFs an hour.

curl -s -X POST "https://chyosi.com/api/v1/runs/RUN_ID/pdf" \
  -H "Authorization: Bearer $CHYOSI_API_KEY"

The answer has artifactId, url (the address of the file), bytes and pages. Download the file with GET /api/v1/artifacts/{id} and the same key. Replace ARTIFACT_ID with the artifactId of the answer.

curl -fsS "https://chyosi.com/api/v1/artifacts/ARTIFACT_ID" \
  -o report.pdf \
  -H "Authorization: Bearer $CHYOSI_API_KEY"

A PDF is the only file a key can download. A screenshot of a finding opens only in a signed-in browser: a key gets the answer 403 with the code forbidden.

An example for CI

This script starts a quick audit, reads it every 10 seconds, and fails when the audit does not end as succeeded or its score is under a threshold. It needs curl and jq and runs in any POSIX shell. Set CHYOSI_API_KEY and CHYOSI_PROJECT_ID as secrets of your CI. CHYOSI_MIN_SCORE sets the threshold and is 80 when it is not set.

#!/bin/sh
# Starts a quick audit, waits for it, and fails unless it passed.
# Needs curl and jq. Set CHYOSI_API_KEY and CHYOSI_PROJECT_ID.
set -eu

API="https://chyosi.com/api/v1"
MIN_SCORE="${CHYOSI_MIN_SCORE:-80}"
GIVE_UP_AT=$(( $(date +%s) + 900 ))
BODY=$(mktemp)
trap 'rm -f "$BODY"' EXIT

CODE=$(curl -sS -o "$BODY" -w '%{http_code}' -X POST \
  "$API/projects/$CHYOSI_PROJECT_ID/runs" \
  -H "Authorization: Bearer $CHYOSI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"kind":"quick"}')
if [ "$CODE" != "201" ]; then
  echo "The audit did not start (HTTP $CODE): $(cat "$BODY")" >&2
  exit 1
fi
RUN_ID=$(jq -r .id "$BODY")
echo "Started audit $RUN_ID"

while :; do
  RUN=$(curl -fsS "$API/runs/$RUN_ID" \
    -H "Authorization: Bearer $CHYOSI_API_KEY")
  STATUS=$(printf '%s' "$RUN" | jq -r .status)
  case "$STATUS" in
    queued|running) ;;
    *) break ;;
  esac
  if [ "$(date +%s)" -ge "$GIVE_UP_AT" ]; then
    echo "Gave up waiting for audit $RUN_ID, it is still $STATUS" >&2
    exit 1
  fi
  sleep 10
done

SCORE=$(printf '%s' "$RUN" | jq -r '.score // "none"')
echo "Audit $RUN_ID ended as $STATUS with score $SCORE"
[ "$STATUS" = "succeeded" ] || exit 1
if [ "$SCORE" = "none" ] || [ "$SCORE" -lt "$MIN_SCORE" ]; then
  echo "The score is under $MIN_SCORE" >&2
  exit 1
fi

The script exits with 0 when the audit succeeded with a score at or above the threshold, and with 1 in every other case, with the reason printed. It gives up after 15 minutes of waiting and leaves the audit running. Stop it with POST /api/v1/runs/{id}/cancel if you do not want it to finish.

What a key can call

A key can call these routes. Each of them also works with a signed-in browser.

  • GET /api/v1/me/usage

    Your plan, your credits and the limits of your plan.

  • GET /api/v1/projects

    Your projects, each with the latest score of its site.

  • POST /api/v1/projects

    Adds a project from the address of a site. The body has a url and an optional name. Your plan limits how many projects you can have.

  • GET /api/v1/projects/{id}

    One project, with its settings and whether its site is verified.

  • PATCH /api/v1/projects/{id}

    Changes the name or the settings of a project, or archives it or brings it back.

  • GET /api/v1/projects/{id}/runs

    The audits of one project, newest first. Use limit (up to 100) and pass nextCursor back as cursor to read the next page.

  • POST /api/v1/projects/{id}/runs

    Starts a quick or a full audit. The body has the kind. See Start an audit.

  • GET /api/v1/projects/{id}/schedule

    The schedule of a project. The answer has configured set to false when there is none.

  • GET /api/v1/runs

    The newest audits of all your projects, each with its project. Use limit (up to 50) and cursor like in the list above.

  • GET /api/v1/runs/{id}

    One audit: its status, score, scores and summary.

  • POST /api/v1/runs/{id}/cancel

    Stops an audit that has not finished.

  • GET /api/v1/runs/{id}/findings

    The findings of an audit. Filter by category and severity.

  • GET /api/v1/runs/{id}/findings/rejected

    What the reviewer decided was wrong in this audit. These are not findings, and they do not count in the score.

  • GET /api/v1/runs/{id}/scenarios

    The flows that a full audit walked through, with their steps and results.

  • GET /api/v1/runs/{id}/diff

    What is new, fixed and remaining compared with an earlier audit of the same project. The query parameter base is required.

  • POST /api/v1/runs/{id}/pdf

    Makes the PDF of the report of an audit that succeeded. Needs a paid plan.

  • GET /api/v1/artifacts/{id}

    Downloads the PDF of a report. Any other file, such as a screenshot, needs a signed-in browser.

A key cannot do what needs a signed-in browser: manage keys, billing and your account, project secrets, share links and webhook settings, delete a project, change a schedule or the status of a finding, verify a site, and open a screenshot or any stored file other than a PDF. Those routes get the answer 403 with the code forbidden.

Errors and limits

Every error has the same shape: a code to act on, a message for a person, and details that depend on the code. The HTTP status goes with the code.

{
  "error": {
    "code": "run_already_active",
    "message": "An audit is already running for this project",
    "details": {
      "runId": "run_01J9ZK3Q8X5V7N2M4T6W8Y0A1B"
    }
  }
}

The codes you are most likely to meet:

  • 401 unauthorized: The key is missing, wrong or revoked.
  • 403 forbidden: The route or the file needs a signed-in browser, not a key.
  • 400 validation_failed: The body or a query parameter is not valid. details says which.
  • 404 not_found: There is no such project or audit, or it belongs to another account.
  • 402 insufficient_credits: Not enough credits. details has need and have.
  • 403 plan_limit_reached: Your plan does not include this: a full audit, a PDF, or more projects.
  • 403 domain_not_verified: A full audit needs a site you have verified.
  • 403 email_not_verified: Confirm your email address in the app before you start an audit.
  • 409 conflict: The request does not fit the state of things, for example an archived project, or a PDF of an audit that did not succeed.
  • 409 run_already_active: The project already has an audit in progress. details.runId names it.
  • 409 run_not_cancellable: The audit has already finished.
  • 410 artifact_expired: The files of the audit were removed, so a PDF can no longer be made.
  • 429 rate_limited: A limit was reached. Wait the number of seconds in Retry-After.
  • 503 service_paused: Audits are paused or cannot be started right now. No credits were used. Try again later.

The limits:

  • An account can make 600 read requests (GET) and 60 write requests (POST and PATCH) a minute. A key and the signed-in browser of the same account share these numbers.
  • Every answer carries X-RateLimit-Limit and X-RateLimit-Remaining. When a limit is reached the answer is 429 with the code rate_limited and a Retry-After header with the seconds to wait.
  • Audit starts: at most 10 an hour.
  • On the Free plan, quick audits of one site are limited to 3 a day, counted over all free accounts together.
  • PDF reports: at most 10 an hour.

Full reference

Every route, parameter and answer is described in an OpenAPI 3.1 document. It is public: you do not need a key to read it.

The OpenAPI document, /api/v1/openapi.json