Annotation API
By default, each user can submit up to 10 jobs concurrently. This limit applies across all API tokens on your account for model inference, video annotation and standalone 3D Hand Pose. Each accepted video in a batch uses one slot, including while it waits to run. Contact us for higher concurrency or faster processing.
Annotation: $6/video-hour without 3D Pose; $9/video-hour with 3D Pose.
Standalone 3D Hand Pose costs $3 per original video hour.
Submit videos in a batch · Hand 3D Pose example
Video input requirements
Upload MP4, MOV or WebM up to 50,000,000 bytes, with no fixed duration limit. The worker accepts 29.97 fps and variable frame rates and converts them to 30 fps for processing. Annotation times are measured from the first displayed frame of the original video track. Billing uses that track’s measured duration. Use the original file size and SHA-256 when requesting an upload session.
The file must contain a video track with readable dimensions. Width and height must each be at most 4096 pixels, and width × height must be at most 8,294,400 pixels. 3840 × 2160 meets the resolution limit. 4096 × 2160 exceeds the total pixel limit.
Upload confirmation only verifies that the file is stored. For single-video submission, call POST /api/v1/annotations/{id}/process once before polling, even if the job already reports processing_mode=automatic. Use the original UUID to resume the job.
Annotation provides fine-grained video segments and sub-second action annotations. Events include start and end times on the source timeline, English action and Chinese action_zh. It shares an account API token with RoboRouter.
The public API base is https://datumwell.io/api/v1. Use a project API token to request an upload form, process the job and read its results as shown below.
Create and save a job UUID. POST /api/v1/annotations/{id}/upload-session with filename, size_bytes, the lowercase hexadecimal SHA-256 digest sha256, and optional language (en or zh). Send every upload.fields entry followed by the file field as a multipart form to upload.url. On success, POST upload.generation to /api/v1/annotations/{id}/upload-complete. Send your project token only to the Datumwell API.
After confirming the upload, call POST /api/v1/annotations/{id}/process once. If the response includes processing_mode=automatic, the server processes the remaining stages. Poll GET /api/v1/annotations/{id} until completed, failed, cancelled or uncertain. The original UUID is safe to reuse if the submission response is lost. During rollout, a 202 without processing_mode uses the older per-stage flow and still needs POST /process with that UUID.
The file goes directly to private TOS. Each upload form is scoped to one object and the declared file size. After a connection interruption, check the existing task and upload state before proceeding.
Full details are in result.hands. Each segment has description, description_zh and independent anatomical left[] and right[] events. When result_paged is true, start at GET /api/v1/annotations/{id}/result?offset=0 and append pages in next_offset order until it is null.
The success rate without 3D Pose is $6 per video hour. Each job settles once at its reserved rate version. POST /api/v1/annotations/{id}/cancel cancels an idle job and releases its hold. Unfinished jobs can expire after 24 hours idle. Review timestamps and make sure you may share the video and annotation text with processing services.
The example uses Python 3 and curl. Replace the token and clip.mp4 with your own credentials and file. Keep the generated .request-id file to resume that job. If a connection drops or the outcome is unclear, check the saved job ID before continuing.
A successful GET can return status=failed. Read error_code from the job body. When error_code is annotation_preprocessing_failed, failure.message explains the server-side error, failure.task_id is the UUID to provide to support, and failure.no_charge=true confirms that no credits were charged or held.
Uploading a video, polling status and reading results do not use an execution slot.
Capacity responses: 429 account_concurrency_exceeded means the account has no free slots. 503 service_capacity_exceeded means the service cannot accept new work right now. 503 capacity_busy means admission is temporarily busy. These responses do not queue work, start an upstream call, or place a new credit hold.
Retry these three capacity errors after the time in Retry-After (in seconds, currently 5). Add a small random delay and cap retries. Reuse the same request_key and payload for inference, or the same job UUID for annotation. For other 503 responses or network timeouts, check the original request status before retrying.
If a staged hand timeline has a gap, overlap or invalid boundary, the service may re-observe that video segment up to twice, replacing only the invalid hand output. Valid hand output is reused and prior call records are retained. Missing time is not filled with invented actions. These internal attempts do not create a second customer charge. If validation still fails, query the original UUID and contact support; do not create a replacement request to retry a confirmed failed job.
New automatic jobs expose recovery.automatic=true. After an interrupted call or Worker failure, the server reuses the original UUID, successful checkpoints and credit reservation for at most two recovery rounds after the initial run. No cumulative processing-duration cutoff is added. Poll GET with the same UUID while status is processing and recovery.retrying is true; retries_used, max_retries and next_retry_at describe recovery progress. Lost-response stages may be sent again, but the customer settles once at the original reserved rate. After the recovery budget is exhausted the job ends as failed with annotation_retry_exhausted and the existing failure billing rules apply. Do not create a replacement job or call /recover for automatic recovery.
Connection failures confirmed before any HTTP request is sent may be retried once within the stage deadline. The same job UUID, saved checkpoints and credit reservation are reused. Exhausted connection attempts end the job as failed with annotation_provider_connect_failed instead of leaving it pending. If all processing attempts fail before sending, no model-processing failure fee applies. For older jobs without recovery.automatic=true, a possibly sent request with a lost response remains uncertain and needs review.
Older uncertain jobs retain their original media, attempts and credit hold for review; idle expiry does not cancel or refund them. After the 10-minute safety window, an inactive uncertain job stops occupying an upload slot. Ordinary GET and POST /process never resend an uncertain call.
For an older staged job without automatic recovery or 3D Pose, explicitly recover only after reviewing the uncertain outcome. POST /api/v1/annotations/{id}/recover with {"recovery_key":"a new UUID saved for this recovery","acknowledge_possible_duplicate_upstream":true}. Wait at least 10 minutes after the job and its unresolved attempts stop updating. This acknowledges that the upstream may already have processed the lost call. Then POST /process once and poll the original job UUID. Successful checkpoints and the original reservation are reused; the customer is not charged a second reservation. Save and reuse recovery_key when retrying this recovery request. At most two recoveries are accepted per job; Pose, missing media, exhausted recoveries or settled reservations need support review.
Optional 3D hand Pose: explicitly send pose3d: true and pose3d_scope: "egocentric_single_wearer" in upload-session. This supports only first-person videos of one camera wearer’s two hands, up to 120 seconds and 50,000,000 bytes. Multi-person and third-person hand tracking are not supported. Declare this scope only when the video meets it; the service does not automatically verify the scene. Pose is off by default.
After completed, read private keypoints from result.pose3d.result_endpoint and follow next_offset through every page. Each hand’s track_id stays consistent within the task across pages, retries and forward/backward seeks. detected_is_right is the original side prediction; is_right is the anatomical side stabilized over the full track. Brief missing observations retain identity but may leave hands empty; a newly confirmed track after a long absence gets a new ID. IDs do not identify the same hand across different jobs.
Tracking runs on the complete ordered result and is persisted before paging; pages never generate new identities. Association and duplicate suppression do not correct joint geometry or guarantee every detection. 3D coordinates use default camera intrinsics and are estimates. Raw predictions and the processing version remain internal. Video is sent over HTTPS to GPU processing in Canada; private results require authorization from the original project.
The success rate with 3D Pose is $9/video-hour; without it, the rate remains $6/video-hour. Both branches finish before one settlement using the original UUID and reserved rate. Repeated reads do not repeat inference or settlement. Automatic recovery may rerun stages with lost results, with one customer settlement. Uncertain outcomes keep their hold for reconciliation.
export ROBOROUTER_TOKEN='YOUR_API_TOKEN'
python3 - <<'PY'
import hashlib, json, os, sys, time, uuid
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
video = Path("clip.mp4")
data = video.read_bytes()
key_file = video.with_suffix(video.suffix + ".request-id")
try:
with key_file.open("x", encoding="ascii") as saved:
saved.write(str(uuid.uuid4()))
except FileExistsError:
pass
job_id = str(uuid.UUID(key_file.read_text(encoding="ascii").strip()))
base = "https://datumwell.io/api/v1/annotations/" + job_id
headers = {"Authorization": "Bearer " + os.environ["ROBOROUTER_TOKEN"]}
print("Request ID:", job_id, file=sys.stderr)
def request(path, method="GET", data=None, content_type=None):
fields = dict(headers)
if content_type:
fields["Content-Type"] = content_type
try:
with urlopen(Request(base + path, data, fields, method=method),
timeout=300) as response:
return json.load(response)
except HTTPError as error:
print(error.read().decode("utf-8", errors="replace"), file=sys.stderr)
if error.headers.get("Retry-After"):
print("Retry-After:", error.headers["Retry-After"], file=sys.stderr)
sys.exit("Check the original request ID before continuing.")
except (URLError, TimeoutError):
sys.exit("Connection interrupted. Check the original request ID.")
metadata = json.dumps({
"filename": video.name, "size_bytes": len(data),
"sha256": hashlib.sha256(data).hexdigest(), "language": "en",
}).encode()
session = request("/upload-session", "POST", metadata, "application/json")
if session.get("upload"):
import subprocess
upload = session["upload"]
if not upload["url"].startswith("https://"):
sys.exit("Expected an HTTPS object storage URL.")
fields = [arg for key, value in upload["fields"].items()
for arg in ("--form-string", f"{key}={value}")]
subprocess.run(["curl", "--fail", "--silent", "--show-error",
"--max-time", "120", *fields,
"--form", f"file=@{video}", upload["url"]], check=True)
complete = json.dumps({"generation": upload["generation"]}).encode()
request("/upload-complete", "POST", complete, "application/json")
job = request("")
active = {"uploading", "processing", "translation_pending"}
retryable = {"annotation_recognition_retry", "annotation_translation_retry"}
# Upload confirmation alone does not start annotation. Submit once even when
# an unsubmitted job already advertises automatic processing.
if job["status"] in active and not job.get("worker_active"):
if not job.get("error_code") or job["error_code"] in retryable:
job = request("/process", "POST")
while job["status"] in active:
if job.get("processing_mode") == "automatic" or job.get("worker_active"):
time.sleep(5)
job = request("")
elif not job.get("error_code") or job["error_code"] in retryable:
job = request("/process", "POST")
if job["status"] in active:
time.sleep(1)
else:
break
if job["status"] == "completed" and job.get("result_paged"):
result = job["result"]
result["segments"] = []
offset = 0
while offset is not None:
page = request(f"/result?offset={offset}")
result["segments"].extend(page["segments"])
if offset == 0:
result["hands"] = page["hands"]
else:
result["hands"]["segments"].extend(page["hands"]["segments"])
result["hands"]["audit"].extend(page["hands"]["audit"])
next_offset = page["next_offset"]
if next_offset is not None and next_offset <= offset:
sys.exit("Invalid result cursor. Check the saved job ID.")
offset = next_offset
job["result_paged"] = False
print(json.dumps(job, ensure_ascii=False, indent=2))
if job["status"] != "completed":
sys.exit(1)
PYSubmit videos in a batch
Batch uses the production API. Save each video’s job UUID, create its upload-session, upload the file, and call upload-complete. To include 3D Pose, set pose3d: true and pose3d_scope: egocentric_single_wearer in that video’s upload-session. Submit 1–10 confirmed upload UUIDs in one request.
Set ROBOROUTER_TOKEN, use a new UUID as the Idempotency-Key, and save it with the request body. If the submission outcome is unclear, replay the same key and body.
BATCH_REQUEST_UUID='YOUR_SAVED_REQUEST_UUID'
FIRST_JOB_UUID='FIRST_CONFIRMED_UPLOAD_UUID'
SECOND_JOB_UUID='SECOND_CONFIRMED_UPLOAD_UUID'
curl -siS https://datumwell.io/api/v1/annotation-batches \
-H "Authorization: Bearer $ROBOROUTER_TOKEN" \
-H "Idempotency-Key: $BATCH_REQUEST_UUID" \
-H 'Content-Type: application/json' \
--data-binary "{\"items\":[{\"job_id\":\"$FIRST_JOB_UUID\"},{\"job_id\":\"$SECOND_JOB_UUID\"}]}"HTTP 202 returns a batch_id and an admission value for each video. Unaccepted items include a reason code. Batch submission starts accepted jobs. Read the summary at GET /api/v1/annotation-batches/{batch_id}, or poll each accepted status_url using poll_after_seconds. A phase of queued or waiting_for_gpu means the job is waiting for capacity. After completed, use the original job UUID to read annotations and optional Pose pages.
When slots free up, use a new idempotency key with POST /api/v1/annotation-batches/{batch_id}/items to add videos or submit unaccepted items. On HTTP 429, wait for Retry-After. If no batch was created, submit to the create endpoint. Batch uses the same rates as single-job submission and settles each video by its duration.
POST /api/v1/annotation-batches/{batch_id}/cancel closes the batch and cancels items that have yet to start. Items already in processing continue.
Hand 3D Pose: complete example
This example explicitly enables Pose. Prepare a video within the scope above, replace the token and clip.mp4, then paste the entire block into a terminal with Python 3 and curl. Successful tasks cost $9 per video hour. It uploads the video, submits processing once, polls for completion, and reads all action annotation and Pose pages.
The example saves action results to clip.mp4.annotation.json and keypoints to clip.mp4.pose3d.json, preserving original timestamps and track_id. The task UUID is saved separately in clip.mp4.pose3d.request-id. Keep this file and use the same video when retrying or resuming; do not reuse a non-Pose task UUID.
export ROBOROUTER_TOKEN='YOUR_API_TOKEN'
python3 - <<'PY'
import hashlib, json, os, sys, time, uuid
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
video = Path("clip.mp4")
data = video.read_bytes()
key_file = video.with_suffix(video.suffix + ".pose3d.request-id")
try:
with key_file.open("x", encoding="ascii") as saved:
saved.write(str(uuid.uuid4()))
except FileExistsError:
pass
job_id = str(uuid.UUID(key_file.read_text(encoding="ascii").strip()))
base = "https://datumwell.io/api/v1/annotations/" + job_id
headers = {"Authorization": "Bearer " + os.environ["ROBOROUTER_TOKEN"]}
print("Request ID:", job_id, file=sys.stderr)
def request(path, method="GET", data=None, content_type=None):
fields = dict(headers)
if content_type:
fields["Content-Type"] = content_type
try:
with urlopen(Request(base + path, data, fields, method=method),
timeout=300) as response:
return json.load(response)
except HTTPError as error:
print(error.read().decode("utf-8", errors="replace"), file=sys.stderr)
if error.headers.get("Retry-After"):
print("Retry-After:", error.headers["Retry-After"], file=sys.stderr)
sys.exit("Check the original request ID before continuing.")
except (URLError, TimeoutError):
sys.exit("Connection interrupted. Check the original request ID.")
metadata = json.dumps({
"filename": video.name, "size_bytes": len(data),
"sha256": hashlib.sha256(data).hexdigest(), "language": "en",
"pose3d": True, "pose3d_scope": "egocentric_single_wearer",
}).encode()
session = request("/upload-session", "POST", metadata, "application/json")
if session.get("upload"):
import subprocess
upload = session["upload"]
if not upload["url"].startswith("https://"):
sys.exit("Expected an HTTPS object storage URL.")
fields = [arg for key, value in upload["fields"].items()
for arg in ("--form-string", f"{key}={value}")]
subprocess.run(["curl", "--fail", "--silent", "--show-error",
"--max-time", "120", *fields,
"--form", f"file=@{video}", upload["url"]], check=True)
complete = json.dumps({"generation": upload["generation"]}).encode()
request("/upload-complete", "POST", complete, "application/json")
job = request("")
active = {"uploading", "processing", "translation_pending"}
retryable = {"annotation_recognition_retry", "annotation_translation_retry"}
# Upload confirmation alone does not start annotation. Submit once even when
# an unsubmitted job already advertises automatic processing.
if job["status"] in active and not job.get("worker_active"):
if not job.get("error_code") or job["error_code"] in retryable:
job = request("/process", "POST")
while job["status"] in active:
if job.get("processing_mode") == "automatic" or job.get("worker_active"):
time.sleep(5)
job = request("")
elif not job.get("error_code") or job["error_code"] in retryable:
job = request("/process", "POST")
if job["status"] in active:
time.sleep(1)
else:
break
if job["status"] == "completed" and job.get("result_paged"):
result = job["result"]
result["segments"] = []
offset = 0
while offset is not None:
page = request(f"/result?offset={offset}")
result["segments"].extend(page["segments"])
if offset == 0:
result["hands"] = page["hands"]
else:
result["hands"]["segments"].extend(page["hands"]["segments"])
result["hands"]["audit"].extend(page["hands"]["audit"])
next_offset = page["next_offset"]
if next_offset is not None and next_offset <= offset:
sys.exit("Invalid result cursor. Check the saved job ID.")
offset = next_offset
job["result_paged"] = False
if job["status"] != "completed":
print(json.dumps(job, ensure_ascii=False, indent=2))
sys.exit("Task not completed. Keep the saved request ID.")
endpoint = (job.get("result", {}).get("pose3d") or {}).get("result_endpoint")
job_path = "/api/v1/annotations/" + job_id
if endpoint != job_path + "/pose3d":
sys.exit("Missing or unexpected Pose endpoint. Check the original task.")
pose_path = endpoint[len(job_path):]
pose = None
frames = []
offset = 0
while offset is not None:
page = request(f"{pose_path}?offset={offset}")
if page.get("offset") != offset or not isinstance(page.get("frames"), list):
sys.exit("Invalid Pose page. Keep the saved request ID.")
if pose is None:
pose = {key: value for key, value in page.items()
if key not in ("frames", "offset", "next_offset")}
if page.get("total_frames") != pose.get("total_frames"):
sys.exit("Pose frame count changed. Check the original task.")
frames.extend(page["frames"])
if "next_offset" not in page:
sys.exit("Missing Pose cursor. Check the original task.")
next_offset = page["next_offset"]
if next_offset is not None and (type(next_offset) is not int or
next_offset <= offset or
next_offset != len(frames)):
sys.exit("Invalid Pose cursor. Check the original task.")
offset = next_offset
if len(frames) != pose.get("total_frames"):
sys.exit("Incomplete Pose result. Retry reads with the original task ID.")
pose["frames"] = frames
annotation_file = video.with_suffix(video.suffix + ".annotation.json")
pose_file = video.with_suffix(video.suffix + ".pose3d.json")
annotation_file.write_text(json.dumps(job, ensure_ascii=False, indent=2), encoding="utf-8")
pose_file.write_text(json.dumps(pose, ensure_ascii=False, indent=2), encoding="utf-8")
print("Saved:", annotation_file, pose_file)
PY