Acknowledge a delivered WorkItem
Confirms receipt of a delivered WorkItem and moves it from queued to
starting. The call sets acknowledged_at. If the worker does not ack
within the fixed 5000ms window, the background sweeper returns the item
to the queue. Ack immediately after delivery, before starting a slow
executor. A stale token returns 412 failed_precondition_error. If the
path names a different Environment, the call returns 404 and omits lease
state from the response.
curl --request POST \
--url https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"worker_id": "worker-1",
"generation": 1
}
'import requests
url = "https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack"
payload = {
"worker_id": "worker-1",
"generation": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({worker_id: 'worker-1', generation: 1})
};
fetch('https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'worker_id' => 'worker-1',
'generation' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack"
payload := strings.NewReader("{\n \"worker_id\": \"worker-1\",\n \"generation\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"worker_id\": \"worker-1\",\n \"generation\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"worker_id\": \"worker-1\",\n \"generation\": 1\n}"
response = http.request(request)
puts response.read_body{
"id": "work_01h455vb4pex5vsknk084sn02q",
"session_id": "sesn_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"status": "starting",
"generation": 1,
"worker_id": "worker-1",
"lease_ttl_ms": 300000,
"created_at": "2026-09-20T12:00:00Z",
"claimed_at": "2026-09-20T12:00:00Z",
"acknowledged_at": "2026-09-20T12:01:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "failed_precondition_error",
"message": "The resource state does not permit this operation.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}Headers
API version for this request, in YYYY-MM-DD form. Send 2026-09-01-beta
for the version documented here. Required outside /v1/files*: a missing
header there is rejected with 400 invalid_request_error; on /v1/files*
its absence selects the compatibility behavior. An unknown value is
rejected with 400 invalid_request_error on every endpoint.
API versions served by the platform. New dated versions are added as they
ship; a version is removed after its announced Sunset date.
2026-09-01-beta Path Parameters
Body
Worker ID and generation returned with the WorkItem.
Response
The confirmed WorkItem, now starting.
One row of the self-hosted work queue: a Session whose sandbox tool calls
execute on the environment owner's workers. GET /v1/environments/{environment_id}/work/poll
delivers the item (still queued until acked); the generation it
carries is the fencing token every later ack, heartbeat, and stop must
present.
user.tool_result writes need no explicit token: the session work token
in secret carries the generation binding and the platform derives the
fence from it.
The work item's session-scoped fencing token. Starts at 1 and increases;
a normal release, a platform reclaim, or cancelling a live item also
raises it. Use the value returned by poll for heartbeat, ack, and stop.
A stale value is rejected with 412 failed_precondition_error.
x >= 11
Credential bundle for the Session that owns this WorkItem. Only the poll
response that leases the item includes it. The bundle is a base64url-
encoded JSON object. Decode it and send its sessions_token as
Authorization: Bearer for Session write endpoints (for example,
POST /v1/sessions/{id}/events) and this WorkItem's ack, heartbeat, and
stop requests. The token is scoped to that Session. Other bundle members
are reserved; leave them unchanged. The credential expires when the item
is settled or reclaimed. A reclaim gives the item to another worker with
a new credential and invalidates this one. No other endpoint returns it.
Treat the bundle as a secret. Do not log or persist it.
"eyJzZXNzaW9uc190b2tlbiI6InN3dC1hYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODlBQkNERUZHIn0"
Was this page helpful?
curl --request POST \
--url https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"worker_id": "worker-1",
"generation": 1
}
'import requests
url = "https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack"
payload = {
"worker_id": "worker-1",
"generation": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({worker_id: 'worker-1', generation: 1})
};
fetch('https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'worker_id' => 'worker-1',
'generation' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack"
payload := strings.NewReader("{\n \"worker_id\": \"worker-1\",\n \"generation\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"worker_id\": \"worker-1\",\n \"generation\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.ai/v1/environments/{environment_id}/work/{id}/ack")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"worker_id\": \"worker-1\",\n \"generation\": 1\n}"
response = http.request(request)
puts response.read_body{
"id": "work_01h455vb4pex5vsknk084sn02q",
"session_id": "sesn_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"status": "starting",
"generation": 1,
"worker_id": "worker-1",
"lease_ttl_ms": 300000,
"created_at": "2026-09-20T12:00:00Z",
"claimed_at": "2026-09-20T12:00:00Z",
"acknowledged_at": "2026-09-20T12:01:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "failed_precondition_error",
"message": "The resource state does not permit this operation.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}