CoderHelm Docs
API

Errors

Every error the API returns has a status code and a JSON body with a message and a machine-readable code.

A failed request answers with a 4xx or 5xx status and a JSON body:

{
  "error": "This API key doesn't have the \"runs\" scope (Retry, re-run, re-review, cancel, close or reopen runs).",
  "code": "missing_scope",
  "scope": "runs"
}
FieldTypeDescription
errorstringA sentence to show a person. Its wording can change.
codestringWhat went wrong, for programs. Branch on this, not on error.
scopestringOnly with missing_scope: the scope the key would need.

Codes

StatuscodeMeaningRetry?
400bad_requestThe request is malformed: bad JSON, a missing field, or an action the resource's state doesn't allow (retrying a run that didn't fail, cancelling one that isn't running).No. Fix the request.
401invalid_api_keyNo key, a malformed key, or an unknown one.No.
401api_key_revokedThe key was revoked.No.
401api_key_expiredThe key expired.No.
401api_key_owner_leftThe key's maker left the team.No.
401unauthorizedA CI token or webhook signature didn't verify.No.
403missing_scopeThe key lacks the scope the endpoint needs.No.
403not_available_to_api_keysThe route is for the dashboard only.No.
403forbiddenNot allowed for another reason, such as a repository that isn't connected.No.
404not_foundNot found in your team. Another team's ids look the same as missing ones.No.
409conflictThe change conflicts with the current state.After re-reading the resource.
413payload_too_largeA CI report is empty or over 6 MB.No.
429rate_limitedOver the key's rate limit.Yes, after Retry-After seconds.
429token_limit_reachedThe team reached its monthly token limit, so no new work starts.When the month turns or an admin raises the limit.
500internal_errorSomething failed on CoderHelm's side.Reads, yes, with backoff.
503unavailableCoderHelm couldn't check the key just now.Yes, with backoff.

New codes can be added. Treat an unknown code by its status.

Handling errors

async function coderhelm(path: string, init: RequestInit = {}) {
  const res = await fetch(`https://api.coderhelm.com${path}`, {
    ...init,
    headers: {
      Authorization: `Bearer ${process.env.CODERHELM_API_KEY}`,
      'Content-Type': 'application/json',
      ...init.headers,
    },
  });
  if (res.ok) return res.json();
  const { error, code } = await res.json();
  throw Object.assign(new Error(error), { status: res.status, code });
}
Edit on GitHub

On this page