@@ -740,9 +740,10 @@ func (c *controllerV1) handleGetWorkspaceAgent(w http.ResponseWriter, r *http.Re
740740// @Accept json
741741// @Param id path string true "Workspace ID"
742742// @Param request body proto.AgentMessage true "Agent message"
743−// @Success 200
743+// @Success 202
744744// @Failure 400 {object} proto.Error
745745// @Failure 404 {object} proto.Error
746+// @Failure 409 {object} proto.Error
746747// @Failure 500 {object} proto.Error
747748// @Router /workspaces/{id}/agent [post]
748749func (c *controllerV1) handlePostWorkspaceAgent(w http.ResponseWriter, r *http.Request) {
@@ -767,7 +768,7 @@ func (c *controllerV1) handlePostWorkspaceAgent(w http.ResponseWriter, r *http.R
767768 c.handleError(w, r, err)
768769 return
769770 }
770− w.WriteHeader(http.StatusOK)
771+ w.WriteHeader(http.StatusAccepted)
771772}
772773
773774// handlePostWorkspaceAgentInit initializes the agent for a workspace.
@@ -1061,6 +1062,8 @@ func (c *controllerV1) handleError(w http.ResponseWriter, r *http.Request, err e
10611062 status = http.StatusBadRequest
10621063 case errors.Is(err, backend.ErrClientNotAttached):
10631064 status = http.StatusNotFound
1065+ case errors.Is(err, backend.ErrWorkspaceClosing):
1066+ status = http.StatusConflict
10641067 }
10651068 c.server.logError(r, err.Error())
10661069 jsonError(w, status, err.Error())