# Upload a test report

Source: https://docs.coderhelm.com/api/reference/ci/upload-test-results

`POST /webhooks/ci/tests/results`

Takes one test report from a CI job whose results never reach GitHub (a device farm, say), signed with the job's GitHub Actions OIDC token instead of a CoderHelm secret. Request the token with the audience `coderhelm`. CoderHelm checks it was issued for a workflow run of a repository connected to your team with E2E results turned on, then reads the report like one from GitHub: flaky tests, failure groups and quarantine.

## Authentication

A GitHub Actions OIDC token requested with the audience `coderhelm`, as `Authorization: Bearer <token>`. See [Authentication](https://docs.coderhelm.com/api/authentication#ci-jobs).

## Parameters

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | The report's file name. Must end in `.json` (Playwright or Cucumber JSON) or `.xml` (JUnit XML). Default `report.json`. |

## Request body

`application/octet-stream`: The report file, at most 6 MB.

## Responses

### 200

The report is stored and queued.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `ok` | boolean | yes | Always true: the report is stored and queued for reading. |

### 400

Not a report CoderHelm can read, or it has no tests.

### 401

The token is not a valid GitHub Actions OIDC token for CoderHelm.

### 403

The repository is not connected, or E2E results are off.

### 413

Empty, or larger than 6 MB.

## Example request

cURL:

```bash
curl -X POST 'https://api.coderhelm.com/webhooks/ci/tests/results' \
  -H "Authorization: Bearer $OIDC_TOKEN"
```

TypeScript:

```ts
const res = await fetch("https://api.coderhelm.com/webhooks/ci/tests/results", {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.OIDC_TOKEN}`,
  },
});
if (!res.ok) {
  const { error, code } = await res.json();
  throw new Error(`${res.status} ${code}: ${error}`);
}
const data = await res.json();
```

Python:

```python
import os
import requests

headers = {
    "Authorization": f"Bearer {os.environ['OIDC_TOKEN']}",
}
res = requests.request("POST", "https://api.coderhelm.com/webhooks/ci/tests/results", headers=headers)
if not res.ok:
    raise RuntimeError(f"{res.status_code}: {res.json().get('error')}")
data = res.json()
```

## Example response

```json
{
  "ok": true
}
```
