Coder Builds API
The Builds API from Coder — 9 operation(s) for builds.
The Builds API from Coder — 9 operation(s) for builds.
openapi: 3.0.3
info:
description: Coderd is the service created by running coder server. It is a thin API that connects workspaces, provisioners and users. coderd stores its state in Postgres and is the only service that communicates with Postgres.
title: Coder Agents Builds API
termsOfService: https://coder.com/legal/terms-of-service
contact:
name: API Support
url: https://coder.com
email: support@coder.com
license:
name: AGPL-3.0
url: https://github.com/coder/coder/blob/main/LICENSE
version: '2.0'
servers:
- url: https://{coderHost}/api/v2
description: Coder instance
variables:
coderHost:
default: coder.example.com
description: Your Coder deployment hostname
security:
- CoderSessionToken: []
tags:
- name: Builds
paths:
/api/v2/users/{user}/workspace/{workspacename}/builds/{buildnumber}:
get:
operationId: get-workspace-build-by-user-workspace-name-and-build-number
summary: Get workspace build by user, workspace name, and build number
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: user
in: path
required: true
description: User ID, name, or me
schema:
type: string
- name: workspacename
in: path
required: true
description: Workspace name
schema:
type: string
- name: buildnumber
in: path
required: true
description: Build number
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceBuild'
/api/v2/workspacebuilds/{workspacebuild}:
get:
operationId: get-workspace-build
summary: Get workspace build
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceBuild'
/api/v2/workspacebuilds/{workspacebuild}/cancel:
patch:
operationId: cancel-workspace-build
summary: Cancel workspace build
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
- name: expect_status
in: query
required: false
description: Expected status of the job. If expect_status is supplied, the request will be rejected with 412 Precondition Failed if the job doesn't match the state when performing the cancellation.
schema:
type: string
enum:
- running
- pending
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.Response'
/api/v2/workspacebuilds/{workspacebuild}/logs:
get:
operationId: get-workspace-build-logs
summary: Get workspace build logs
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
- name: before
in: query
required: false
description: Before log id
schema:
type: integer
- name: after
in: query
required: false
description: After log id
schema:
type: integer
- name: follow
in: query
required: false
description: Follow log stream
schema:
type: boolean
- name: format
in: query
required: false
description: 'Log output format. Accepted: ''json'' (default), ''text'' (plain text with RFC3339 timestamps and ANSI colors). Not supported with follow=true.'
schema:
type: string
enum:
- json
- text
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/codersdk.ProvisionerJobLog'
/api/v2/workspacebuilds/{workspacebuild}/parameters:
get:
operationId: get-build-parameters-for-workspace-build
summary: Get build parameters for workspace build
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceBuildParameter'
/api/v2/workspacebuilds/{workspacebuild}/resources:
get:
operationId: removed-get-workspace-resources-for-workspace-build
summary: 'Removed: Get workspace resources for workspace build'
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceResource'
/api/v2/workspacebuilds/{workspacebuild}/state:
get:
operationId: get-provisioner-state-for-workspace-build
summary: Get provisioner state for workspace build
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceBuild'
put:
operationId: update-workspace-build-state
summary: Update workspace build state
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.UpdateWorkspaceBuildStateRequest'
responses:
'204':
description: No Content
/api/v2/workspacebuilds/{workspacebuild}/timings:
get:
operationId: get-workspace-build-timings-by-id
summary: Get workspace build timings by ID
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspacebuild
in: path
required: true
description: Workspace build ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceBuildTimings'
/api/v2/workspaces/{workspace}/builds:
get:
operationId: get-workspace-builds-by-workspace-id
summary: Get workspace builds by workspace ID
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspace
in: path
required: true
description: Workspace ID
schema:
type: string
- name: after_id
in: query
required: false
description: After ID
schema:
type: string
- name: limit
in: query
required: false
description: Page limit
schema:
type: integer
- name: offset
in: query
required: false
description: Page offset
schema:
type: integer
- name: since
in: query
required: false
description: Since timestamp
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceBuild'
post:
operationId: create-workspace-build
summary: Create workspace build
tags:
- Builds
security:
- CoderSessionToken: []
parameters:
- name: workspace
in: path
required: true
description: Workspace ID
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.CreateWorkspaceBuildRequest'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceBuild'
components:
schemas:
codersdk.UpdateWorkspaceBuildStateRequest:
type: object
properties:
state:
type: array
items:
type: integer
codersdk.TimingStage:
type: string
enum:
- init
- plan
- graph
- apply
- start
- stop
- cron
- connect
codersdk.BuildReason:
type: string
enum:
- initiator
- autostart
- autostop
- dormancy
- dashboard
- cli
- ssh_connection
- vscode_connection
- jetbrains_connection
- task_auto_pause
- task_manual_pause
- task_resume
codersdk.AgentSubsystem:
type: string
enum:
- envbox
- envbuilder
- exectrace
codersdk.CreateWorkspaceBuildReason:
type: string
enum:
- dashboard
- cli
- ssh_connection
- vscode_connection
- jetbrains_connection
- task_manual_pause
- task_resume
codersdk.DisplayApp:
type: string
enum:
- vscode
- vscode_insiders
- web_terminal
- port_forwarding_helper
- ssh_helper
codersdk.WorkspaceAgentHealth:
type: object
properties:
healthy:
type: boolean
description: Healthy is true if the agent is healthy.
example: false
reason:
type: string
description: Reason is a human-readable explanation of the agent's health. It is empty if Healthy is true.
example: agent has lost connection
codersdk.WorkspaceBuild:
type: object
properties:
build_number:
type: integer
created_at:
type: string
format: date-time
daily_cost:
type: integer
deadline:
type: string
format: date-time
has_ai_task:
type: boolean
description: 'Deprecated: This field has been deprecated in favor of Task WorkspaceID.'
has_external_agent:
type: boolean
id:
type: string
format: uuid
initiator_id:
type: string
format: uuid
initiator_name:
type: string
job:
$ref: '#/components/schemas/codersdk.ProvisionerJob'
matched_provisioners:
$ref: '#/components/schemas/codersdk.MatchedProvisioners'
max_deadline:
type: string
format: date-time
reason:
enum:
- initiator
- autostart
- autostop
allOf:
- $ref: '#/components/schemas/codersdk.BuildReason'
resources:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceResource'
status:
enum:
- pending
- starting
- running
- stopping
- stopped
- failed
- canceling
- canceled
- deleting
- deleted
allOf:
- $ref: '#/components/schemas/codersdk.WorkspaceStatus'
template_version_id:
type: string
format: uuid
template_version_name:
type: string
template_version_preset_id:
type: string
format: uuid
transition:
enum:
- start
- stop
- delete
allOf:
- $ref: '#/components/schemas/codersdk.WorkspaceTransition'
updated_at:
type: string
format: date-time
workspace_id:
type: string
format: uuid
workspace_name:
type: string
workspace_owner_avatar_url:
type: string
workspace_owner_id:
type: string
format: uuid
workspace_owner_name:
type: string
description: WorkspaceOwnerName is the username of the owner of the workspace.
uuid.NullUUID:
type: object
properties:
uuid:
type: string
valid:
type: boolean
description: Valid is true if UUID is not NULL
codersdk.ProvisionerJobStatus:
type: string
enum:
- pending
- running
- succeeded
- canceling
- canceled
- failed
- unknown
codersdk.WorkspaceBuildParameter:
type: object
properties:
name:
type: string
value:
type: string
codersdk.WorkspaceBuildTimings:
type: object
properties:
agent_connection_timings:
type: array
items:
$ref: '#/components/schemas/codersdk.AgentConnectionTiming'
agent_script_timings:
type: array
description: 'TODO: Consolidate agent-related timing metrics into a single struct when
updating the API version'
items:
$ref: '#/components/schemas/codersdk.AgentScriptTiming'
provisioner_timings:
type: array
items:
$ref: '#/components/schemas/codersdk.ProvisionerTiming'
codersdk.DERPRegion:
type: object
properties:
latency_ms:
type: number
preferred:
type: boolean
codersdk.LogLevel:
type: string
enum:
- trace
- debug
- info
- warn
- error
codersdk.WorkspaceAgentScriptStatus:
type: string
enum:
- ok
- exit_failure
- timed_out
- pipes_left_open
codersdk.AgentScriptTiming:
type: object
properties:
display_name:
type: string
ended_at:
type: string
format: date-time
exit_code:
type: integer
stage:
$ref: '#/components/schemas/codersdk.TimingStage'
started_at:
type: string
format: date-time
status:
type: string
workspace_agent_id:
type: string
workspace_agent_name:
type: string
codersdk.ProvisionerJobType:
type: string
enum:
- template_version_import
- workspace_build
- template_version_dry_run
codersdk.WorkspaceAgentStartupScriptBehavior:
type: string
enum:
- blocking
- non-blocking
codersdk.ProvisionerJobLog:
type: object
properties:
created_at:
type: string
format: date-time
id:
type: integer
log_level:
enum:
- trace
- debug
- info
- warn
- error
allOf:
- $ref: '#/components/schemas/codersdk.LogLevel'
log_source:
$ref: '#/components/schemas/codersdk.LogSource'
output:
type: string
stage:
type: string
codersdk.WorkspaceApp:
type: object
properties:
command:
type: string
display_name:
type: string
description: DisplayName is a friendly name for the app.
external:
type: boolean
description: 'External specifies whether the URL should be opened externally on
the client or not.'
group:
type: string
health:
$ref: '#/components/schemas/codersdk.WorkspaceAppHealth'
healthcheck:
description: Healthcheck specifies the configuration for checking app health.
allOf:
- $ref: '#/components/schemas/codersdk.Healthcheck'
hidden:
type: boolean
icon:
type: string
description: 'Icon is a relative path or external URL that specifies
an icon to be displayed in the dashboard.'
id:
type: string
format: uuid
open_in:
$ref: '#/components/schemas/codersdk.WorkspaceAppOpenIn'
sharing_level:
enum:
- owner
- authenticated
- organization
- public
allOf:
- $ref: '#/components/schemas/codersdk.WorkspaceAppSharingLevel'
slug:
type: string
description: Slug is a unique identifier within the agent.
statuses:
type: array
description: Statuses is a list of statuses for the app.
items:
$ref: '#/components/schemas/codersdk.WorkspaceAppStatus'
subdomain:
type: boolean
description: 'Subdomain denotes whether the app should be accessed via a path on the
`coder server` or via a hostname-based dev URL. If this is set to true
and there is no app wildcard configured on the server, the app will not
be accessible in the UI.'
subdomain_name:
type: string
description: SubdomainName is the application domain exposed on the `coder server`.
tooltip:
type: string
description: 'Tooltip is an optional markdown supported field that is displayed
when hovering over workspace apps in the UI.'
url:
type: string
description: 'URL is the address being proxied to inside the workspace.
If external is specified, this will be opened on the client.'
codersdk.WorkspaceAgentLifecycle:
type: string
enum:
- created
- starting
- start_timeout
- start_error
- ready
- shutting_down
- shutdown_timeout
- shutdown_error
- 'off'
codersdk.WorkspaceAppStatusState:
type: string
enum:
- working
- idle
- complete
- failure
codersdk.WorkspaceAppStatus:
type: object
properties:
agent_id:
type: string
format: uuid
app_id:
type: string
format: uuid
created_at:
type: string
format: date-time
icon:
type: string
description: 'Deprecated: This field is unused and will be removed in a future version.
Icon is an external URL to an icon that will be rendered in the UI.'
id:
type: string
format: uuid
message:
type: string
needs_user_attention:
type: boolean
description: 'Deprecated: This field is unused and will be removed in a future version.
NeedsUserAttention specifies whether the status needs user attention.'
state:
$ref: '#/components/schemas/codersdk.WorkspaceAppStatusState'
uri:
type: string
description: 'URI is the URI of the resource that the status is for.
e.g. https://github.com/org/repo/pull/123
e.g. file:///path/to/file'
workspace_id:
type: string
format: uuid
codersdk.WorkspaceResource:
type: object
properties:
agents:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceAgent'
created_at:
type: string
format: date-time
daily_cost:
type: integer
hide:
type: boolean
icon:
type: string
id:
type: string
format: uuid
job_id:
type: string
format: uuid
metadata:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceResourceMetadata'
name:
type: string
type:
type: string
workspace_transition:
enum:
- start
- stop
- delete
allOf:
- $ref: '#/components/schemas/codersdk.WorkspaceTransition'
codersdk.WorkspaceStatus:
type: string
enum:
- pending
- starting
- running
- stopping
- stopped
- failed
- canceling
- canceled
- deleting
- deleted
codersdk.CreateWorkspaceBuildRequest:
type: object
properties:
dry_run:
type: boolean
log_level:
description: Log level changes the default logging verbosity of a provider ("info" if empty).
enum:
- debug
allOf:
- $ref: '#/components/schemas/codersdk.ProvisionerLogLevel'
orphan:
type: boolean
description: Orphan may be set for the Destroy transition.
reason:
description: Reason sets the reason for the workspace build.
enum:
- dashboard
- cli
- ssh_connection
- vscode_connection
- jetbrains_connection
- task_manual_pause
allOf:
- $ref: '#/components/schemas/codersdk.CreateWorkspaceBuildReason'
rich_parameter_values:
type: array
description: 'ParameterValues are optional. It will write params to the ''workspace'' scope.
This will overwrite any existing parameters with the same name.
This will not delete old params not included in this list.'
items:
$ref: '#/components/schemas/codersdk.WorkspaceBuildParameter'
state:
type: array
items:
type: integer
template_version_id:
type: string
format: uuid
template_version_preset_id:
type: string
format: uuid
description: TemplateVersionPresetID is the ID of the template version preset to use for the build.
transition:
enum:
- start
- stop
- delete
allOf:
- $ref: '#/components/schemas/codersdk.WorkspaceTransition'
required:
- transition
codersdk.LogSource:
type: string
enum:
- provisioner_daemon
- provisioner
codersdk.WorkspaceAgent:
type: object
properties:
api_version:
type: string
apps:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceApp'
architecture:
type: string
connection_timeout_seconds:
type: integer
created_at:
type: string
format: date-time
directory:
type: string
disconnected_at:
type: string
format: date-time
display_apps:
type: array
items:
$ref: '#/components/schemas/codersdk.DisplayApp'
environment_variables:
type: object
additionalProperties:
type: string
expanded_directory:
type: string
first_connected_at:
type: string
format: date-time
health:
description: Health reports the health of the agent.
allOf:
- $ref: '#/components/schemas/codersdk.WorkspaceAgentHealth'
id:
type: string
format: uuid
instance_id:
type: string
last_connected_at:
type: string
format: date-time
latency:
type: object
description: DERPLatency is mapped by region name (e.g. "New York City", "Seattle").
additionalProperties:
$ref: '#/components/schemas/codersdk.DERPRegion'
lifecycle_state:
$ref: '#/components/schemas/codersdk.WorkspaceAgentLifecycle'
log_sources:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceAgentLogSource'
logs_length:
type: integer
logs_overflowed:
type: boolean
name:
type: string
operating_system:
type: string
parent_id:
format: uuid
allOf:
- $ref: '#/components/schemas/uuid.NullUUID'
ready_at:
type: string
format: date-time
resource_id:
type: string
format: uuid
scripts:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceAgentScript'
started_at:
type: string
format: date-time
startup_script_behavior:
description: 'StartupScriptBehavior is a legacy field that is deprecated in favor
of the `coder_script` resource. It''s only referenced by old clients.
Deprecated: Remove in the future!'
allOf:
- $ref: '#/components/schemas/codersdk.WorkspaceAgentStartupScriptBehavior'
status:
$ref: '#/components/schemas/codersdk.WorkspaceAgentStatus'
subsystems:
type: array
items:
$ref: '#/components/schemas/codersdk.AgentSubsystem'
troubleshooting_url:
type: string
updated_at:
type: string
format: date-time
version:
type: string
codersdk.WorkspaceAppHealth:
type: string
enum:
- disabled
- initializing
- healthy
- unhealthy
codersdk.Response:
type: object
properties:
detail:
type: string
description: 'Detail is a debug message that provides further insight into why the
action failed. This information can be technical and a regular golang
err.Error() text.
- "database: too many open connections"
- "stat: too many open files"'
message:
type: string
description: 'Message is an actionable message that depicts actions the request took.
These messages should be fully formed sentences with proper punctuation.
Examples:
- "A user has been created."
- "Failed to create a user."'
validations:
type: array
description: 'Validations are form field-specific friendly error messages. They will be
shown on a form field in the UI. These can also be used to add additional
context if there is a set of errors in the primary ''Message''.'
items:
$ref: '#/components/schemas/codersdk.ValidationError'
codersdk.AgentConnectionTiming:
type: object
properties:
ended_at:
type: string
format: date-time
stage:
$ref: '#/components/schemas/codersdk.TimingStage'
started_at:
type: string
format: date-time
workspace_agent_id:
type: string
workspace_agent_name:
type: string
codersdk.ProvisionerJob:
type: object
properties:
available_workers:
type: array
items:
type: string
format: uuid
canceled_at:
type: string
format: date-time
completed_at:
type: string
format: date-time
created_at:
type: string
format: date-time
error:
type: string
error_code:
enum:
- REQUIRED_TEMPLATE_VARIABLES
- INSUFFICIENT_QUOTA
allOf:
- $ref: '#/components/schemas/codersdk.JobErrorCode'
file_id:
type: string
format: uuid
id:
type: string
format: uuid
initiator_id:
type: string
format: uuid
input:
$ref: '#/components/schemas/codersdk.ProvisionerJobInput'
logs_overflowed:
type: boolean
metadata:
$ref: '#/components/schemas/codersdk.ProvisionerJobMetadata'
organization_id:
type: string
format: uuid
queue_position:
type: integer
queue_size:
type: integer
started_at:
type: string
format: date-time
status:
enum:
- pending
- running
- succeeded
- canceling
- canceled
- failed
allOf:
- $ref: '#/components/schemas/codersdk.ProvisionerJobStatus'
tags:
type: object
additionalProperties:
type: string
type:
$ref: '#/components/schemas/codersdk.ProvisionerJobType'
worker_id:
type: string
format: uuid
worker_name:
type: string
codersdk.JobErrorCode:
type: string
enum:
- REQUIRED_TEMPLATE_VARIABLES
- INSUFFICIENT_QUOTA
codersdk.WorkspaceAgentScript:
type: object
properties:
cron:
type: string
display_name:
type: string
exit_code:
type: integer
id:
type: string
format: uuid
log_path:
type: string
log_source_id:
type: string
format: uuid
run_on_start:
type: boolean
run_on_stop:
type: boolean
script:
type: string
start_blocks_login:
type: boolean
status:
$ref: '#/components/schemas/codersdk.WorkspaceAgentScriptStatus'
timeout:
type: integer
codersdk.WorkspaceResourceMetadata:
type: object
properties:
key:
type: string
sensitive:
type: boolean
value:
type: string
codersdk.ProvisionerTiming:
type: object
properties:
action:
type: string
ended_at:
type: string
format: date-time
job_id:
type: string
format: uuid
resource:
type: string
source:
type: string
stage:
$ref: '#/components/schemas/codersdk.TimingStage'
started_at:
type: string
format: date-time
codersdk.ProvisionerJobInput:
type: object
properties:
error:
type: string
template_version_id:
type: string
format: uuid
workspace_build_id:
type: string
format: uuid
codersdk.WorkspaceAgentStatus:
type: string
enum:
- connecting
- connected
- disconnected
- timeout
codersdk.WorkspaceAppSharingLevel:
type: string
enum:
- owner
- authenticated
- organization
- public
codersdk.WorkspaceAppOpenIn:
type: string
enum:
- slim-window
- tab
codersdk.ProvisionerJobMetadata:
type: object
properties:
template_display_name:
type: string
template_icon:
type: string
template_id:
type: string
format: uuid
template_name:
type: string
template_version_name:
type: string
workspace_build_transition:
$ref: '#/components/schemas/codersdk.WorkspaceTransition'
workspace_id:
type: string
format: uuid
workspace_name:
type: string
codersdk.WorkspaceAgentLogSource:
type: object
properties:
created_at:
type: str
# --- truncated at 32 KB (33 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/coder/refs/heads/main/openapi/coder-builds-api-openapi.yml