# Pipelines

11 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## Pipeline runs, newest first[#]

GET`/v1/pipelines/runs`scope sandboxes:read

Parameters

`state`query · string

—

`limit`query · integer

—

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/pipelines/runs \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Run a repository's .kosa8/pipeline.yml, or its .github/workflows through act[#]

POST`/v1/pipelines/runs`scope sandboxes:write

Each job runs in a sized sandbox made as this organization, billed and limited as any sandbox. See docs/guides/cloud-pipelines.

JSON body

`repo_url`requiredstring

https:// clone URL, no credentials, such as https://github.com/acme/app.git

`ref`string

Branch, tag, SHA or refs/… (default main)

`event`"push" | "pull_request" | "workflow_dispatch" | "schedule"

Default workflow_dispatch

`workflow`string

act runs: one file in .github/workflows (default all)

`job`string

act runs: one job id

`inputs`object

workflow_dispatch inputs

`size`string

act runs: the sandbox size (default 4x8). Native runs size each job in the file

`secrets`array of string

kosa8 secret names (each made with pipelines: true); a job gets each as NAME_IN_CAPS

`token_secret`string

A secret holding a token that can read the repository (private repositories)

`status_secret`string

A secret holding a GitHub token with commit status write: the run sets kosa8/pipelines on the commit

`timeout_s`integer

Default 3600 Min 60. Max 21600.

Responses

201400401403404429

```
curl -s -X POST https://api.kosa8.com/v1/pipelines/runs \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## A run and its jobs (a live run's jobs are read first)[#]

GET`/v1/pipelines/runs/{id}`scope sandboxes:read

Parameters

`id`requiredpath · string

Pipeline run id (prun_…)

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/pipelines/runs/$SBX \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## A run's logs by job, secrets replaced with ***[#]

GET`/v1/pipelines/runs/{id}/logs`scope sandboxes:read

Parameters

`id`requiredpath · string

Pipeline run id (prun_…)

`job`query · string

—

`after`query · integer

Only chunks after this one (next from the last call)

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/pipelines/runs/$SBX/logs \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Cancel a run: its sandboxes are deleted[#]

POST`/v1/pipelines/runs/{id}/cancel`scope sandboxes:write

Parameters

`id`requiredpath · string

Pipeline run id (prun_…)

Responses

200401403404

```
curl -s -X POST https://api.kosa8.com/v1/pipelines/runs/$SBX/cancel \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Files a native job kept (artifacts:)[#]

GET`/v1/pipelines/runs/{id}/artifacts`scope sandboxes:read

Parameters

`id`requiredpath · string

Pipeline run id (prun_…)

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/pipelines/runs/$SBX/artifacts \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Download an artifact as .tar.gz[#]

GET`/v1/pipelines/runs/{id}/artifacts/{job}/{idx}`scope sandboxes:read

Parameters

`id`requiredpath · string

Pipeline run id (prun_…)

`job`requiredpath · string

Job name

`idx`requiredpath · string

The artifact's index in the job's artifacts:

Responses

200401403404

```
curl -s -X GET https://api.kosa8.com/v1/pipelines/runs/$SBX/artifacts/$JOB/$IDX \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Webhook and schedule triggers (no secrets)[#]

GET`/v1/pipelines/hooks`scope sandboxes:read

Responses

200401403

```
curl -s -X GET https://api.kosa8.com/v1/pipelines/hooks \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Make a webhook URL for a repository's pushes and pull requests, and optionally a cron schedule[#]

POST`/v1/pipelines/hooks`scope admin

JSON body

`repo_url`requiredstring

—

`provider`"github" | "gitlab"

Default from repo_url's host

`name`string

—

`secret`string

Default: one is made and returned once

`size`string

—

`secrets`array of string

kosa8 secret names (each made with pipelines: true); a job gets each as NAME_IN_CAPS

`token_secret`string

—

`status_secret`string

—

`workflow`string

—

`timeout_s`integer

Min 60. Max 21600.

`cron`string

m h dom mon dow (UTC): also run on this schedule

`cron_ref`string

The branch scheduled runs use (default main)

Responses

201400401403404409

```
curl -s -X POST https://api.kosa8.com/v1/pipelines/hooks \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## A git host's webhook delivery (no API key: GitHub's X-Hub-Signature-256 or GitLab's X-Gitlab-Token)[#]

POST`/v1/pipelines/hooks/{id}`public

GitHub: push, pull_request (opened, synchronize, reopened) and ping. GitLab: Push Hook. Deliveries are deduplicated by X-GitHub-Delivery.

Parameters

`id`requiredpath · string

Hook id (phk_…)

Responses

200202400401404

```
curl -s -X POST https://api.kosa8.com/v1/pipelines/hooks/$SBX \
  -H 'Content-Type: application/json' -d @body.json
```

## Delete a hook; its URL stops working[#]

DELETE`/v1/pipelines/hooks/{id}`scope admin

Parameters

`id`requiredpath · string

Hook id (phk_…)

Responses

200401403404

```
curl -s -X DELETE https://api.kosa8.com/v1/pipelines/hooks/$SBX \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

---
Source: https://docs.kosa8.com/api/pipelines/
