debugd HTTP API
The IDE plugins and debugctl use this API to talk to debugd. Use it for scripts and new integrations.
- Base URL:
http://localhost:58090. The port is the value ofDEBUG_DAEMON_PORT. - Request and response bodies are JSON, unless a route says something else.
- Routes under
/v1/debug/need an access token:Authorization: Bearer <access token>. Get the token with the login routes, or fromdebugctl login.
Routes
| Method | Path | Auth | Summary |
|---|---|---|---|
GET | /health/check | No | Health check. |
POST | /v1/auth/login | No | Start a login. |
GET | /v1/auth/callback | No | OAuth callback. |
GET | /v1/auth/login/{session_id} | No | Poll a login that POST /v1/auth/login started. |
POST | /v1/auth/logout | No | Record a logout. |
POST | /v1/auth/refresh | No | Get a new access token with a refresh token. |
POST | /v1/debug/init | Yes | Start a debug session. |
GET | /v1/debug/status | Yes | List the debug sessions that debugd knows, with their status. |
GET | /v1/debug/logs | Yes | Get the Delve log of a session from its debug container. |
POST | /v1/debug/stop | Yes | Stop a debug session. |
GET /health/check
Health check. Use it to see if debugd runs.
Status codes
| Code | Meaning |
|---|---|
200 OK | debugd runs. |
POST /v1/auth/login
Start a login. Open auth_url in a browser, then poll GET /v1/auth/login/{session_id}.
Response body: LoginStartResponse
Status codes
| Code | Meaning |
|---|---|
200 OK | The login started. |
500 Internal Server Error | debugd cannot start a login (for example, the login settings are missing). |
GET /v1/auth/callback
OAuth callback. The identity provider redirects the browser to this route. Clients do not call it.
Parameters
| Name | In | Description |
|---|---|---|
state | query | The login session, from the authorization request. |
code | query | The authorization code. |
Response body: An HTML page that tells the user that the login is complete, or that it failed.
Status codes
| Code | Meaning |
|---|---|
200 OK | The login is complete. |
400 Bad Request | The login session is not valid, or the code is missing. |
502 Bad Gateway | The code exchange or the user profile request failed. |
GET /v1/auth/login/{session_id}
Poll a login that POST /v1/auth/login started. When status is complete, the response contains the tokens.
Parameters
| Name | In | Description |
|---|---|---|
session_id | path | The session_id from POST /v1/auth/login. |
Response body: LoginPollResponse
Status codes
| Code | Meaning |
|---|---|
200 OK | The current status of the login. |
404 Not Found | The login session is unknown or expired (status is expired). |
POST /v1/auth/logout
Record a logout. The client deletes its stored tokens. debugd does not revoke the token.
Status codes
| Code | Meaning |
|---|---|
200 OK | Done. |
POST /v1/auth/refresh
Get a new access token with a refresh token.
Request body: RefreshRequest
Response body: RefreshResponse
Status codes
| Code | Meaning |
|---|---|
200 OK | New tokens. |
400 Bad Request | The body is not valid, or refresh_token is empty. |
401 Unauthorized | The token exchange failed: the refresh token is not valid or expired, or debugd cannot reach the identity provider. |
500 Internal Server Error | debugd cannot encode the response. |
POST /v1/debug/init
Start a debug session. The session starts in the background. To get its ID and status, call GET /v1/debug/status.
Needs Authorization: Bearer <access token>.
Request body: DebugInitRequest
Response body: On success, the response body repeats the request body. It does not contain the session ID.
Status codes
| Code | Meaning |
|---|---|
200 OK | The session is accepted and starts in the background. |
400 Bad Request | The body is not valid JSON, or a required field is empty. |
401 Unauthorized | The access token is missing, not valid, or expired. |
429 Too Many Requests | Your plan does not allow another session now. The body is {"error": "...", "plan": "..."}. |
GET /v1/debug/status
List the debug sessions that debugd knows, with their status.
Needs Authorization: Bearer <access token>.
Response body: array of DebugSessionResponse
Status codes
| Code | Meaning |
|---|---|
200 OK | A JSON array of sessions. The array is empty when there are no sessions. |
401 Unauthorized | The access token is missing, not valid, or expired. |
500 Internal Server Error | debugd cannot encode the response. |
GET /v1/debug/logs
Get the Delve log of a session from its debug container.
Needs Authorization: Bearer <access token>.
Parameters
| Name | In | Description |
|---|---|---|
session | query | Required. The session ID. |
source | query | dlv (default): the Delve log file. dlv-stdio: the Delve stdout and stderr. |
follow | query | true streams new lines until the client closes the connection. |
tail | query | The number of last lines. 0 returns the whole log. The default is a limit that the debug container sets. |
Response body: Plain text (text/plain; charset=utf-8).
Status codes
| Code | Meaning |
|---|---|
200 OK | The log. |
400 Bad Request | session is missing or not an integer. |
401 Unauthorized | The access token is missing, not valid, or expired. |
404 Not Found | There is no session with this ID. |
501 Not Implemented | The debug image of this session cannot serve logs. |
502 Bad Gateway | The debug container did not answer. |
503 Service Unavailable | The session is not ready yet. |
POST /v1/debug/stop
Stop a debug session. Delve detaches from the target process, which continues to run. The debug container exits, and the session becomes COMPLETED with stop_reason stopped_by_user. The call waits until the debug container exits (up to 30 s).
Needs Authorization: Bearer <access token>.
Request body: DebugStopRequest
Response body: DebugStopResponse
Status codes
| Code | Meaning |
|---|---|
200 OK | The session is stopped, or it was already COMPLETED, FAILED or EXPIRED (the call changes nothing then). |
400 Bad Request | The body is not valid JSON, or session_id is missing. |
401 Unauthorized | The access token is missing, not valid, or expired. |
404 Not Found | There is no session with this ID. |
409 Conflict | The session is still starting (PENDING). Try again. |
502 Bad Gateway | The debug container did not answer. The session does not change. Try again. If the problem continues, restart the pod. |
Types
DebugInitRequest
| Field | Type | Description |
|---|---|---|
version | string | The version of the client protocol. Required. |
language | string | Required. Use go. |
debugger | string | Required. Use delve. |
session | DebugInitSession | The target of the session. See DebugInitSession. |
DebugInitSession
| Field | Type | Description |
|---|---|---|
pod_labels | string | Required. A label selector, for example app=checkout. debugd uses the first pod that matches. |
namespace | string | The namespace of the pod. Default: default. |
app_port | string | An application port to forward to the same port on localhost. Empty: no forward. |
kubeconfig | string | The kubeconfig path, or a path list in the KUBECONFIG format (: on Linux and macOS). The files in a list are merged, the same as kubectl does. A leading ~ is expanded in each path. The current context is used. Clients send the user value, else KUBECONFIG of the client environment. Empty: KUBECONFIG of debugd, then ~/.kube/config. |
container_name | string | The target container. Empty: the first container of the pod. |
match_process_name | string | A string to find the target process in the process list. Empty: PID 1. |
DebugSessionResponse
| Field | Type | Description |
|---|---|---|
id | integer | The session ID. |
language | string | |
debugger | string | |
pod_labels | string | |
pod_name | string | The pod that debugd selected. |
namespace | string | |
kube_cfg_path | string | The kubeconfig value from the request (a path or a path list). |
app_port | string | |
app_process_cmd | string | The command line of the target process. |
ephemeral_container_name | string | The name of the debug container in the pod. |
substitute_binary_path | string | The build directory of the binary. Map your local source root to this path (Delve substitutePath). |
debugger_port | integer | The local port that forwards to Delve. Connect the IDE to 127.0.0.1:<debugger_port>. |
ephemeral_server_port | integer | The local port that forwards to the server in the debug container. |
dlv_pid | integer | The PID of Delve in the debug container, when debugd knows it. |
expired | boolean | true when the session expired. |
status | string | PENDING, READY, UNRESPONSIVE, UNREACHABLE, COMPLETED, EXPIRED or FAILED. |
last_errors | array of string | The last errors of the session, newest last. |
last_checked | string (RFC 3339 time) | The time of the last health check of Delve. |
stop_reason | string | stopped_by_user when a user stopped the session with POST /v1/debug/stop. Empty otherwise. |
DebugStopRequest
| Field | Type | Description |
|---|---|---|
session_id | integer | Required. The session ID. |
DebugStopResponse
| Field | Type | Description |
|---|---|---|
session_id | integer | The session ID. |
status | string | The status of the session after the stop, usually COMPLETED. |
detached | boolean | true when Delve detached through its API and removed its breakpoints. false when the debug container stopped Delve with a signal, or when the session was already terminal. |
container_terminated | boolean | true when Kubernetes reported the debug container as terminated in time. |
LoginPollResponse
| Field | Type | Description |
|---|---|---|
status | string | pending, complete, failed or expired. |
error | string | The reason, when status is failed. |
access_token | string | When status is complete: the access token (JWT). |
refresh_token | string | When status is complete: the refresh token. |
user_id | string | When status is complete: the user ID. |
email | string | When status is complete: the email address of the user. |
LoginStartResponse
| Field | Type | Description |
|---|---|---|
auth_url | string | Open this URL in a browser to log in. |
session_id | string | Use it to poll GET /v1/auth/login/{session_id}. |
expires_in | integer | Seconds until the login session expires. |
RefreshRequest
| Field | Type | Description |
|---|---|---|
refresh_token | string | The refresh token. |
RefreshResponse
| Field | Type | Description |
|---|---|---|
access_token | string | The new access token. |
refresh_token | string | The new refresh token. Store it. It replaces the old one. |
expires_in | integer | Seconds until the access token expires. |