Skip to main content

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 of DEBUG_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 from debugctl login.

Routes​

MethodPathAuthSummary
GET/health/checkNoHealth check.
POST/v1/auth/loginNoStart a login.
GET/v1/auth/callbackNoOAuth callback.
GET/v1/auth/login/{session_id}NoPoll a login that POST /v1/auth/login started.
POST/v1/auth/logoutNoRecord a logout.
POST/v1/auth/refreshNoGet a new access token with a refresh token.
POST/v1/debug/initYesStart a debug session.
GET/v1/debug/statusYesList the debug sessions that debugd knows, with their status.
GET/v1/debug/logsYesGet the Delve log of a session from its debug container.
POST/v1/debug/stopYesStop a debug session.

GET /health/check​

Health check. Use it to see if debugd runs.

Status codes

CodeMeaning
200 OKdebugd 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

CodeMeaning
200 OKThe login started.
500 Internal Server Errordebugd 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

NameInDescription
statequeryThe login session, from the authorization request.
codequeryThe authorization code.

Response body: An HTML page that tells the user that the login is complete, or that it failed.

Status codes

CodeMeaning
200 OKThe login is complete.
400 Bad RequestThe login session is not valid, or the code is missing.
502 Bad GatewayThe 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

NameInDescription
session_idpathThe session_id from POST /v1/auth/login.

Response body: LoginPollResponse

Status codes

CodeMeaning
200 OKThe current status of the login.
404 Not FoundThe 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

CodeMeaning
200 OKDone.

POST /v1/auth/refresh​

Get a new access token with a refresh token.

Request body: RefreshRequest

Response body: RefreshResponse

Status codes

CodeMeaning
200 OKNew tokens.
400 Bad RequestThe body is not valid, or refresh_token is empty.
401 UnauthorizedThe token exchange failed: the refresh token is not valid or expired, or debugd cannot reach the identity provider.
500 Internal Server Errordebugd 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

CodeMeaning
200 OKThe session is accepted and starts in the background.
400 Bad RequestThe body is not valid JSON, or a required field is empty.
401 UnauthorizedThe access token is missing, not valid, or expired.
429 Too Many RequestsYour 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

CodeMeaning
200 OKA JSON array of sessions. The array is empty when there are no sessions.
401 UnauthorizedThe access token is missing, not valid, or expired.
500 Internal Server Errordebugd 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

NameInDescription
sessionqueryRequired. The session ID.
sourcequerydlv (default): the Delve log file. dlv-stdio: the Delve stdout and stderr.
followquerytrue streams new lines until the client closes the connection.
tailqueryThe 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

CodeMeaning
200 OKThe log.
400 Bad Requestsession is missing or not an integer.
401 UnauthorizedThe access token is missing, not valid, or expired.
404 Not FoundThere is no session with this ID.
501 Not ImplementedThe debug image of this session cannot serve logs.
502 Bad GatewayThe debug container did not answer.
503 Service UnavailableThe 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

CodeMeaning
200 OKThe session is stopped, or it was already COMPLETED, FAILED or EXPIRED (the call changes nothing then).
400 Bad RequestThe body is not valid JSON, or session_id is missing.
401 UnauthorizedThe access token is missing, not valid, or expired.
404 Not FoundThere is no session with this ID.
409 ConflictThe session is still starting (PENDING). Try again.
502 Bad GatewayThe debug container did not answer. The session does not change. Try again. If the problem continues, restart the pod.

Types​

DebugInitRequest​

FieldTypeDescription
versionstringThe version of the client protocol. Required.
languagestringRequired. Use go.
debuggerstringRequired. Use delve.
sessionDebugInitSessionThe target of the session. See DebugInitSession.

DebugInitSession​

FieldTypeDescription
pod_labelsstringRequired. A label selector, for example app=checkout. debugd uses the first pod that matches.
namespacestringThe namespace of the pod. Default: default.
app_portstringAn application port to forward to the same port on localhost. Empty: no forward.
kubeconfigstringThe 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_namestringThe target container. Empty: the first container of the pod.
match_process_namestringA string to find the target process in the process list. Empty: PID 1.

DebugSessionResponse​

FieldTypeDescription
idintegerThe session ID.
languagestring
debuggerstring
pod_labelsstring
pod_namestringThe pod that debugd selected.
namespacestring
kube_cfg_pathstringThe kubeconfig value from the request (a path or a path list).
app_portstring
app_process_cmdstringThe command line of the target process.
ephemeral_container_namestringThe name of the debug container in the pod.
substitute_binary_pathstringThe build directory of the binary. Map your local source root to this path (Delve substitutePath).
debugger_portintegerThe local port that forwards to Delve. Connect the IDE to 127.0.0.1:<debugger_port>.
ephemeral_server_portintegerThe local port that forwards to the server in the debug container.
dlv_pidintegerThe PID of Delve in the debug container, when debugd knows it.
expiredbooleantrue when the session expired.
statusstringPENDING, READY, UNRESPONSIVE, UNREACHABLE, COMPLETED, EXPIRED or FAILED.
last_errorsarray of stringThe last errors of the session, newest last.
last_checkedstring (RFC 3339 time)The time of the last health check of Delve.
stop_reasonstringstopped_by_user when a user stopped the session with POST /v1/debug/stop. Empty otherwise.

DebugStopRequest​

FieldTypeDescription
session_idintegerRequired. The session ID.

DebugStopResponse​

FieldTypeDescription
session_idintegerThe session ID.
statusstringThe status of the session after the stop, usually COMPLETED.
detachedbooleantrue 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_terminatedbooleantrue when Kubernetes reported the debug container as terminated in time.

LoginPollResponse​

FieldTypeDescription
statusstringpending, complete, failed or expired.
errorstringThe reason, when status is failed.
access_tokenstringWhen status is complete: the access token (JWT).
refresh_tokenstringWhen status is complete: the refresh token.
user_idstringWhen status is complete: the user ID.
emailstringWhen status is complete: the email address of the user.

LoginStartResponse​

FieldTypeDescription
auth_urlstringOpen this URL in a browser to log in.
session_idstringUse it to poll GET /v1/auth/login/{session_id}.
expires_inintegerSeconds until the login session expires.

RefreshRequest​

FieldTypeDescription
refresh_tokenstringThe refresh token.

RefreshResponse​

FieldTypeDescription
access_tokenstringThe new access token.
refresh_tokenstringThe new refresh token. Store it. It replaces the old one.
expires_inintegerSeconds until the access token expires.