Coder Agents API
The Agents API from Coder — 28 operation(s) for agents.
The Agents API from Coder — 28 operation(s) for agents.
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 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: Agents
paths:
/api/v2/debug/{user}/debug-link:
get:
operationId: debug-oidc-context-for-a-user
summary: Debug OIDC context for a user
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: user
in: path
required: true
description: User ID, name, or me
schema:
type: string
responses:
'200':
description: Success
/api/v2/derp-map:
get:
operationId: get-derp-map-updates
summary: Get DERP map updates
tags:
- Agents
security:
- CoderSessionToken: []
responses:
'101':
description: Switching Protocols
/api/v2/tailnet:
get:
operationId: user-scoped-tailnet-rpc-connection
summary: User-scoped tailnet RPC connection
tags:
- Agents
security:
- CoderSessionToken: []
responses:
'101':
description: Switching Protocols
/api/v2/workspaceagents/aws-instance-identity:
post:
operationId: authenticate-agent-on-aws-instance
summary: Authenticate agent on AWS instance
tags:
- Agents
security:
- CoderSessionToken: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.AWSInstanceIdentityToken'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.AuthenticateResponse'
/api/v2/workspaceagents/azure-instance-identity:
post:
operationId: authenticate-agent-on-azure-instance
summary: Authenticate agent on Azure instance
tags:
- Agents
security:
- CoderSessionToken: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.AzureInstanceIdentityToken'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.AuthenticateResponse'
/api/v2/workspaceagents/connection:
get:
operationId: get-connection-info-for-workspace-agent-generic
summary: Get connection info for workspace agent generic
tags:
- Agents
security:
- CoderSessionToken: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/workspacesdk.AgentConnectionInfo'
/api/v2/workspaceagents/google-instance-identity:
post:
operationId: authenticate-agent-on-google-cloud-instance
summary: Authenticate agent on Google Cloud instance
tags:
- Agents
security:
- CoderSessionToken: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.GoogleInstanceIdentityToken'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.AuthenticateResponse'
/api/v2/workspaceagents/me/app-status:
patch:
operationId: patch-workspace-agent-app-status
summary: Patch workspace agent app status
tags:
- Agents
security:
- CoderSessionToken: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.PatchAppStatus'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.Response'
/api/v2/workspaceagents/me/external-auth:
get:
operationId: get-workspace-agent-external-auth
summary: Get workspace agent external auth
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: match
in: query
required: true
description: Match
schema:
type: string
- name: id
in: query
required: true
description: Provider ID
schema:
type: string
- name: listen
in: query
required: false
description: Wait for a new token to be issued
schema:
type: boolean
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.ExternalAuthResponse'
/api/v2/workspaceagents/me/gitauth:
get:
operationId: removed-get-workspace-agent-git-auth
summary: 'Removed: Get workspace agent git auth'
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: match
in: query
required: true
description: Match
schema:
type: string
- name: id
in: query
required: true
description: Provider ID
schema:
type: string
- name: listen
in: query
required: false
description: Wait for a new token to be issued
schema:
type: boolean
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.ExternalAuthResponse'
/api/v2/workspaceagents/me/gitsshkey:
get:
operationId: get-workspace-agent-git-ssh-key
summary: Get workspace agent Git SSH key
tags:
- Agents
security:
- CoderSessionToken: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.GitSSHKey'
/api/v2/workspaceagents/me/log-source:
post:
operationId: post-workspace-agent-log-source
summary: Post workspace agent log source
tags:
- Agents
security:
- CoderSessionToken: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.PostLogSourceRequest'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceAgentLogSource'
/api/v2/workspaceagents/me/logs:
patch:
operationId: patch-workspace-agent-logs
summary: Patch workspace agent logs
tags:
- Agents
security:
- CoderSessionToken: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.PatchLogs'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.Response'
/api/v2/workspaceagents/me/reinit:
get:
operationId: get-workspace-agent-reinitialization
summary: Get workspace agent reinitialization
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: wait
in: query
required: false
description: Opt in to durable reinit checks
schema:
type: boolean
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/agentsdk.ReinitializationEvent'
'409':
description: Conflict
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.Response'
/api/v2/workspaceagents/me/rpc:
get:
operationId: workspace-agent-rpc-api
summary: Workspace agent RPC API
tags:
- Agents
security:
- CoderSessionToken: []
responses:
'101':
description: Switching Protocols
/api/v2/workspaceagents/{workspaceagent}:
get:
operationId: get-workspace-agent-by-id
summary: Get workspace agent by ID
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceAgent'
/api/v2/workspaceagents/{workspaceagent}/connection:
get:
operationId: get-connection-info-for-workspace-agent
summary: Get connection info for workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/workspacesdk.AgentConnectionInfo'
/api/v2/workspaceagents/{workspaceagent}/containers:
get:
operationId: get-running-containers-for-workspace-agent
summary: Get running containers for workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
- name: label
in: query
required: true
description: Labels
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceAgentListContainersResponse'
/api/v2/workspaceagents/{workspaceagent}/containers/devcontainers/{devcontainer}:
delete:
operationId: delete-devcontainer-for-workspace-agent
summary: Delete devcontainer for workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
- name: devcontainer
in: path
required: true
description: Devcontainer ID
schema:
type: string
responses:
'204':
description: No Content
/api/v2/workspaceagents/{workspaceagent}/containers/devcontainers/{devcontainer}/recreate:
post:
operationId: recreate-devcontainer-for-workspace-agent
summary: Recreate devcontainer for workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
- name: devcontainer
in: path
required: true
description: Devcontainer ID
schema:
type: string
responses:
'202':
description: Accepted
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.Response'
/api/v2/workspaceagents/{workspaceagent}/containers/watch:
get:
operationId: watch-workspace-agent-for-container-updates
summary: Watch workspace agent for container updates.
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceAgentListContainersResponse'
/api/v2/workspaceagents/{workspaceagent}/coordinate:
get:
operationId: coordinate-workspace-agent
summary: Coordinate workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'101':
description: Switching Protocols
/api/v2/workspaceagents/{workspaceagent}/listening-ports:
get:
operationId: get-listening-ports-for-workspace-agent
summary: Get listening ports for workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.WorkspaceAgentListeningPortsResponse'
/api/v2/workspaceagents/{workspaceagent}/logs:
get:
operationId: get-logs-by-workspace-agent
summary: Get logs by workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent 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: no_compression
in: query
required: false
description: Disable compression for WebSocket connection
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.WorkspaceAgentLog'
/api/v2/workspaceagents/{workspaceagent}/pty:
get:
operationId: open-pty-to-workspace-agent
summary: Open PTY to workspace agent
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'101':
description: Switching Protocols
/api/v2/workspaceagents/{workspaceagent}/startup-logs:
get:
operationId: removed-get-logs-by-workspace-agent
summary: 'Removed: Get logs by workspace agent'
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent 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: no_compression
in: query
required: false
description: Disable compression for WebSocket connection
schema:
type: boolean
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/codersdk.WorkspaceAgentLog'
/api/v2/workspaceagents/{workspaceagent}/watch-metadata:
get:
operationId: watch-for-workspace-agent-metadata-updates
summary: Watch for workspace agent metadata updates
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'200':
description: Success
/api/v2/workspaceagents/{workspaceagent}/watch-metadata-ws:
get:
operationId: watch-for-workspace-agent-metadata-updates-via-websockets
summary: Watch for workspace agent metadata updates via WebSockets
tags:
- Agents
security:
- CoderSessionToken: []
parameters:
- name: workspaceagent
in: path
required: true
description: Workspace agent ID
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/codersdk.ServerSentEvent'
components:
schemas:
codersdk.WorkspaceAgentLog:
type: object
properties:
created_at:
type: string
format: date-time
id:
type: integer
level:
$ref: '#/components/schemas/codersdk.LogLevel'
output:
type: string
source_id:
type: string
format: uuid
agentsdk.AuthenticateResponse:
type: object
properties:
session_token:
type: string
codersdk.WorkspaceAgentListeningPort:
type: object
properties:
network:
type: string
description: only "tcp" at the moment
port:
type: integer
process_name:
type: string
description: may be empty
codersdk.AgentSubsystem:
type: string
enum:
- envbox
- envbuilder
- exectrace
codersdk.WorkspaceAgentListContainersResponse:
type: object
properties:
containers:
type: array
description: Containers is a list of containers visible to the workspace agent.
items:
$ref: '#/components/schemas/codersdk.WorkspaceAgentContainer'
devcontainers:
type: array
description: Devcontainers is a list of devcontainers visible to the workspace agent.
items:
$ref: '#/components/schemas/codersdk.WorkspaceAgentDevcontainer'
warnings:
type: array
description: 'Warnings is a list of warnings that may have occurred during the
process of listing containers. This should not include fatal errors.'
items:
type: string
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
agentsdk.GitSSHKey:
type: object
properties:
private_key:
type: string
public_key:
type: string
uuid.NullUUID:
type: object
properties:
uuid:
type: string
valid:
type: boolean
description: Valid is true if UUID is not NULL
codersdk.ServerSentEvent:
type: object
properties:
data: {}
type:
$ref: '#/components/schemas/codersdk.ServerSentEventType'
agentsdk.PatchAppStatus:
type: object
properties:
app_slug:
type: string
icon:
type: string
description: 'Deprecated: this field is unused and will be removed in a future version.'
message:
type: string
needs_user_attention:
type: boolean
description: 'Deprecated: this field is unused and will be removed in a future version.'
state:
$ref: '#/components/schemas/codersdk.WorkspaceAppStatusState'
uri:
type: string
codersdk.DERPRegion:
type: object
properties:
latency_ms:
type: number
preferred:
type: boolean
agentsdk.PatchLogs:
type: object
properties:
log_source_id:
type: string
logs:
type: array
items:
$ref: '#/components/schemas/agentsdk.Log'
codersdk.LogLevel:
type: string
enum:
- trace
- debug
- info
- warn
- error
codersdk.WorkspaceAgentDevcontainerStatus:
type: string
enum:
- running
- stopped
- starting
- stopping
- deleting
- error
tailcfg.DERPHomeParams:
type: object
properties:
regionScore:
type: object
description: 'RegionScore scales latencies of DERP regions by a given scaling
factor when determining which region to use as the home
("preferred") DERP. Scores in the range (0, 1) will cause this
region to be proportionally more preferred, and scores in the range
(1, ∞) will penalize a region.
If a region is not present in this map, it is treated as having a
score of 1.0.
Scores should not be 0 or negative; such scores will be ignored.
A nil map means no change from the previous value (if any); an empty
non-nil map can be sent to reset all scores back to 1.0.'
additionalProperties:
type: number
format: float64
tailcfg.DERPMap:
type: object
properties:
homeParams:
description: 'HomeParams, if non-nil, is a change in home parameters.
The rest of the DEPRMap fields, if zero, means unchanged.'
allOf:
- $ref: '#/components/schemas/tailcfg.DERPHomeParams'
omitDefaultRegions:
type: boolean
description: 'OmitDefaultRegions specifies to not use Tailscale''s DERP servers, and only use those
specified in this DERPMap. If there are none set outside of the defaults, this is a noop.
This field is only meaningful if the Regions map is non-nil (indicating a change).'
regions:
type: object
description: 'Regions is the set of geographic regions running DERP node(s).
It''s keyed by the DERPRegion.RegionID.
The numbers are not necessarily contiguous.'
additionalProperties:
$ref: '#/components/schemas/tailcfg.DERPRegion'
codersdk.WorkspaceAgentScriptStatus:
type: string
enum:
- ok
- exit_failure
- timed_out
- pipes_left_open
codersdk.WorkspaceAgentStartupScriptBehavior:
type: string
enum:
- blocking
- non-blocking
workspacesdk.AgentConnectionInfo:
type: object
properties:
derp_force_websockets:
type: boolean
derp_map:
$ref: '#/components/schemas/tailcfg.DERPMap'
disable_direct_connections:
type: boolean
hostname_suffix:
type: string
codersdk.WorkspaceAgentDevcontainerAgent:
type: object
properties:
directory:
type: string
id:
type: string
format: uuid
name:
type: string
agentsdk.AzureInstanceIdentityToken:
type: object
properties:
agent_name:
type: string
description: 'AgentName optionally selects a specific agent when multiple
agents share the same instance identity. An empty string is
treated as unspecified.'
encoding:
type: string
signature:
type: string
required:
- encoding
- signature
agentsdk.ExternalAuthResponse:
type: object
properties:
access_token:
type: string
password:
type: string
token_extra:
type: object
additionalProperties: true
type:
type: string
url:
type: string
username:
type: string
description: 'Deprecated: Only supported on `/workspaceagents/me/gitauth`
for backwards compatibility.'
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.WorkspaceAgentContainerPort:
type: object
properties:
host_ip:
type: string
description: 'HostIP is the IP address of the host interface to which the port is
bound. Note that this can be an IPv4 or IPv6 address.'
host_port:
type: integer
description: HostPort is the port number *outside* the container.
network:
type: string
description: Network is the network protocol used by the port (tcp, udp, etc).
port:
type: integer
description: Port is the port number *inside* the container.
agentsdk.Log:
type: object
properties:
created_at:
type: string
level:
$ref: '#/components/schemas/codersdk.LogLevel'
output:
type: string
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.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-tim
# --- truncated at 32 KB (46 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/coder/refs/heads/main/openapi/coder-agents-api-openapi.yml