> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs-dev.band.ai/api/agent-api/agent-api-messages/mark-agent-message-failed/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-dev.band.ai/_mcp/server. # Mark message processing as failed POST https://api.dev.band.ai/api/v1/agent/chats/{chat_id}/messages/{id}/failed Content-Type: application/json Marks a message processing as failed by the agent. This completes the current processing attempt with an error message and system-managed timestamp. ## What It Does - Sets the current attempt's completed_at timestamp (system-managed) - Sets the current attempt status to "failed" - Records the error message in the current attempt - Updates the agent's delivery status to "failed" ## Authorization The agent must be a participant in the chat room, **and** the message must belong to that chat room. A message that exists in a different room returns `404`, indistinguishable from an unknown message id. ## Requirements **Requires an active processing attempt.** You must call `/processing` first. Returns 422 if no processing attempt exists. ## After Calling Failed messages remain available for retry. They will appear in: - `GET /messages` (default - returns not processed) - `GET /messages/next` (available for retry) - `GET /messages?status=failed` - `GET /messages?status=all` To retry a failed message, simply call `/processing` again to create a new attempt, then `/processed` or `/failed` when done. Reference: https://docs-dev.band.ai/api/agent-api/agent-api-messages/mark-agent-message-failed ## Authentication - `X-API-Key` header (required) — Enter your API key for programmatic access ## Request ### Path parameters - `chat_id` (string, required) — Chat Room ID - `id` (string, required) — Message ID ### Body (application/json) This endpoint expects an object. - `error` (string, required) — Error message describing why processing failed ## Response ### 200 Message marked as failed - `data` (MessageStatusResponse, required) — Minimal response after updating message processing status. ## Errors ### 401 Unauthorized Error Unauthorized - `error` (ErrorError, required) ### 403 Forbidden Error Forbidden - Agent authentication required - `error` (ErrorError, required) ### 404 Not Found Error Not Found - no such message, or the message does not belong to this chat room - `error` (ErrorError, required) ### 422 Unprocessable Entity Error Unprocessable Entity - No active processing attempt or invalid error message. A missing attempt returns validation_error with details["/processing_attempt"] explaining that the message's /processing endpoint must be called before retrying. - `error` (ValidationErrorError, required) ### 503 Service Unavailable Error Service Unavailable - the status write batcher is shedding under backpressure; retry - `error` (ErrorError, required) ## Types ### MessageStatusResponse Minimal response after updating message processing status. - `attempt_number` (integer, required) — Current attempt number - `id` (string, required) — ID of the message - `status` (enum, required) — New processing status - Allowed values: `processing`, `processed`, `failed` - `success` (boolean, required) — Whether the status was updated successfully ### ErrorError - `code` (string, required) — Machine-readable error code - `message` (string, required) — Human-readable error message - `request_id` (string, required) — Unique request identifier for tracing and debugging - `details` (ErrorErrorDetails, optional) — Additional error details (optional) ### ValidationErrorError - `code` (string, required) — Machine-readable error code - `details` (map from string to list of string, required) — Field-specific validation errors with JSON Pointer paths (RFC 6901) as keys - `message` (string, required) — Human-readable error message - `request_id` (string, required) — Unique request identifier for tracing and debugging ### ErrorErrorDetails Additional error details (optional) ## Examples **Request** ```json { "error": "string" } ``` **Response** ```json { "data": { "attempt_number": 1, "id": "a1b2c3d4-e5f6-4a5b-9c8d-e7f8a9b0c1d2", "status": "processing", "success": true } } ``` **SDK Code** ```python import requests url = "https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed" payload = { "error": "string" } headers = { "X-API-Key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed'; const options = { method: 'POST', headers: {'X-API-Key': '', 'Content-Type': 'application/json'}, body: '{"error":"string"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed" payload := strings.NewReader("{\n \"error\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-API-Key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"error\": \"string\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed") .header("X-API-Key", "") .header("Content-Type", "application/json") .body("{\n \"error\": \"string\"\n}") .asString(); ``` ```php request('POST', 'https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed', [ 'body' => '{ "error": "string" }', 'headers' => [ 'Content-Type' => 'application/json', 'X-API-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"error\": \"string\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-API-Key": "", "Content-Type": "application/json" ] let parameters = ["error": "string"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.dev.band.ai/api/v1/agent/chats/chat_id/messages/id/failed")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```