Templates
Run templates of an organization or project, their versions and the runs started from them.
Every path is under /api/v1; see the API for authenticating, errors and rate
limits, and the schemas for the bodies.
The organization's own templates by name (any member)
GET /api/v1/orgs/{org}/templates
Every project of the organization can launch them as "@org/NAME".
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
templates |
array of TemplateSummary, required |
Errors: 404 (how errors look).
Save a new organization template as version 1 (template:write on the organization)
POST /api/v1/orgs/{org}/templates
Checked as a project's template; an organization has at most 200 of its own.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): TemplateInput.
Answers:
201: Created, Template
Errors: 400, 403, 404, 409, 422 (how errors look).
The project's templates by name (project:read)
GET /api/v1/projects/{project}/templates
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
include |
query | one of org: org: also its organization's templates, after the project's, as the project can launch them. |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
templates |
array of TemplateSummary, required |
Errors: 403, 404 (how errors look).
Save a new template as version 1 (template:write)
POST /api/v1/projects/{project}/templates
The spec is checked with sample values for the parameters (defaults, else a value of the parameter's type), so a saved template can be launched. A project has at most 200.
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
Body (application/json): TemplateInput.
Answers:
201: Created, Template
Errors: 400, 403, 404, 409, 422 (how errors look).
A template at its latest or a given version (project:read; an organization template org:read)
GET /api/v1/templates/{template}
| Parameter | In | Description |
|---|---|---|
template |
path | ID |
version |
query | integer |
project_id |
query | ID: Read it as this project uses it (project:read there): its own template, or an organization template at its newest allowed version, or the version asked if allowed. |
Answers:
200: OK, Template
Errors: 400, 404 (how errors look).
Save a template again (template:write)
PUT /api/v1/templates/{template}
A changed description, spec or parameter list adds a version; versions never change. A changed name only renames. Saving the same content changes nothing.
| Parameter | In | Description |
|---|---|---|
template |
path | ID |
Body (application/json): TemplateInput.
Answers:
200: The template at its (new) latest version, Template
Errors: 400, 403, 404, 409, 422 (how errors look).
Delete a template and its versions; its runs keep what they recorded (template:write)
DELETE /api/v1/templates/{template}
| Parameter | In | Description |
|---|---|---|
template |
path | ID |
Answers:
204: Deleted
Errors: 403, 404 (how errors look).
Restrict which versions of an organization template its projects may run (template:write on the organization)
PUT /api/v1/templates/{template}/allowed-versions
An empty list allows every version. "@org/NAME" runs the newest allowed version; a step or launch that pins another is refused.
| Parameter | In | Description |
|---|---|---|
template |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
versions |
array of integer, required |
Answers:
200: The template with its allowed versions, Template
Errors: 400, 403, 404, 422 (how errors look).
Where an organization template is used (template:write on the organization)
GET /api/v1/templates/{template}/usage
Per project of the organization: its runs of each version in the last days
days, and its schedules and triggers of the template. Projects that use it in none of
these ways aren't listed.
| Parameter | In | Description |
|---|---|---|
template |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
days |
integer, required | |
projects |
array of object, required |
Errors: 403, 404, 422 (how errors look).
A template's versions, newest first (project:read)
GET /api/v1/templates/{template}/versions
| Parameter | In | Description |
|---|---|---|
template |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
versions |
array of TemplateVersion, required |
Errors: 404 (how errors look).
Queue a run from a template (run:create)
POST /api/v1/templates/{template}/runs
The parameters are checked and filled in (defaults for those not given); the run records the template, version and values. Variables and secrets resolve as for any run.
| Parameter | In | Description |
|---|---|---|
template |
path | ID |
Idempotency-Key |
header | string: As for createRun; the version and parameter values are part of the request. |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
env |
map of string | The run's own env (level run): it overrides the template's, except its locked entries. |
name |
string | The run's name; the template's name if empty. |
params |
map of any | Values by parameter name; numbers and booleans may be JSON numbers and booleans or text. |
project_id |
any | The project the run is in; required for an organization template. |
version |
integer | The version to launch; 0 or absent: the latest. |
Answers:
Errors: 400, 403, 404, 409, 422, 429 (how errors look).