Your First API Call#
This guide takes you from an API key to your first result in under 5 minutes.
What you need#
- An API key (sign up)
curlandjq(or any HTTP client)
1. Make your first call (wait for the result)#
The simplest way: send code and get the result back on the same request.
curl -s -X POST "https://api.rustbox.sh/api/submit?wait=true" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_key_here" \
-d '{"language": "python", "code": "print(42)"}' | jqReplace
rb_live_your_key_herewith your own API key. Sign up to get one.
Response:
{
"id": "f2c6c5f7-1203-46e5-8a4f-a619c12bfeb0",
"schema_version": "2.0",
"language": "python",
"profile": "judge",
"status": "completed",
"timestamps": {
"created_at": "2026-04-03T08:05:23.540110+00:00",
"started_at": "2026-04-03T08:05:23.540218+00:00",
"completed_at": "2026-04-03T08:05:23.570195+00:00"
},
"result": {
"verdict": "AC",
"cause": "normal_exit",
"actor": "runtime",
"exit_code": 0,
"signal": null,
"error_message": null
},
"output": {
"stdout": "42\n",
"stderr": "",
"integrity": "complete"
},
"metrics": {
"cpu_time_secs": 0.009142,
"wall_time_secs": 0.01,
"memory_peak_bytes": 3862528,
"cpu_wall_ratio": 0.9,
"divergence": "cpu_bound"
},
"evidence": {
"isolation": {
"mode": "strict",
"controls_applied": ["pid_namespace", "mount_namespace", "network_namespace", "memory_limit", "process_limit", "no_new_privileges"],
"controls_missing": [],
"proc_policy": "hardened",
"sys_policy": "builtin-deny",
"pidfd_mode": "native",
"reason": "All configured controls applied"
},
"limits": {
"rlimits": {
"cpu_secs": { "soft": 4, "hard": 4 },
"as_bytes": { "soft": 1073741824, "hard": 1073741824 },
"nofile": { "soft": 32, "hard": 32 },
"nproc": { "soft": 10, "hard": 10 }
},
"cgroup_backend": "cgroup_v2",
"cgroup": {
"memory_limit_bytes": 268435456,
"memory_peak_bytes": 3862528,
"oom_events": 0,
"oom_kill_events": 0,
"cpu_usage_usec": 9142,
"process_count": 0,
"process_limit": 10
}
},
"teardown": {
"reap_status": "clean",
"descendant_containment": "ok",
"zombie_count": 0,
"cleanup_verified": true,
"residual_mounts": [],
"collection_errors": []
}
}
}result.verdict: "AC" means the code ran fine and exited cleanly.
2. Send now, get the result later#
For big batches, or when you don't want to keep a connection open.
- You send
POST /api/submitwith{language, code}. - Rustbox answers
202with{id, status: "pending"}and puts the run in the queue. - A worker runs it in a fresh box and records the result and the proof.
- You check
GET /api/result/{id}untilstatusiscompleted, then readresult,outputandevidence.
Submit:
curl -s -X POST "https://api.rustbox.sh/api/submit" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_key_here" \
-d '{"language": "python", "code": "print(42)"}' | jq{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "pending",
"queue_depth": 0
}Check for the result:
curl -s "https://api.rustbox.sh/api/result/550e8400-e29b-41d4-a716-446655440000" \
-H "X-API-Key: rb_live_your_key_here" | jqKeep checking until status is completed or error.
3. Giving your program input#
Many programs read input. Send it in the stdin field:
curl -s -X POST "https://api.rustbox.sh/api/submit?wait=true" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_key_here" \
-d '{
"language": "python",
"code": "name = input()\nprint(f\"Hello, {name}!\")",
"stdin": "World"
}' | jq{
"id": "b1c2d3e4-5f6a-7b8c-9d0e-f1a2b3c4d5e6",
"schema_version": "2.0",
"language": "python",
"profile": "judge",
"status": "completed",
"timestamps": {
"created_at": "2026-04-03T08:06:11.120000+00:00",
"started_at": "2026-04-03T08:06:11.121000+00:00",
"completed_at": "2026-04-03T08:06:11.146000+00:00"
},
"result": {
"verdict": "AC",
"cause": "normal_exit",
"actor": "runtime",
"exit_code": 0,
"signal": null,
"error_message": null
},
"output": {
"stdout": "Hello, World!\n",
"stderr": "",
"integrity": "complete"
},
"metrics": {
"cpu_time_secs": 0.013,
"wall_time_secs": 0.025,
"memory_peak_bytes": 3200000,
"cpu_wall_ratio": 0.52,
"divergence": "cpu_bound"
}
}4. Webhooks (get results sent to you)#
For lots of runs, add a webhook URL to your project in the dashboard. Every run sent with an API key from that project sends its result to the project's active webhooks.
curl -s -X POST "https://api.rustbox.sh/api/submit" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_project_key_here" \
-d '{"language": "python", "code": "print(42)"}' | jqThe result is sent to your URL with a signature (HMAC-SHA256), so you can check it really came from rustbox. It follows the Standard Webhooks spec. See the Webhooks reference for how to check the signature.
5. When code crashes#
Not all code runs cleanly. Here is what a crash looks like:
curl -s -X POST "https://api.rustbox.sh/api/submit?wait=true" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_key_here" \
-d '{"language": "python", "code": "raise ValueError(\"boom\")"}' | jq{
"id": "64374887-a809-4542-9c85-4002d2ebf3fa",
"schema_version": "2.0",
"language": "python",
"profile": "judge",
"status": "completed",
"timestamps": {
"created_at": "2026-04-03T08:07:02.300000+00:00",
"started_at": "2026-04-03T08:07:02.301000+00:00",
"completed_at": "2026-04-03T08:07:02.311000+00:00"
},
"result": {
"verdict": "RE",
"cause": "re_nonzero_exit",
"actor": "runtime",
"exit_code": 1,
"signal": null,
"error_message": null
},
"output": {
"stdout": "",
"stderr": "Traceback (most recent call last):\n File \"/tmp/rustbox-uid-0/60000/workdir/solution.py\", line 1, in <module>\n raise ValueError(\"boom\")\nValueError: boom\n",
"integrity": "complete"
},
"metrics": {
"cpu_time_secs": 0.009511,
"wall_time_secs": 0.01,
"memory_peak_bytes": 3858432,
"cpu_wall_ratio": 0.95,
"divergence": "cpu_bound"
},
"evidence": {
"isolation": {
"mode": "strict",
"controls_applied": ["pid_namespace", "mount_namespace", "network_namespace", "memory_limit", "process_limit", "no_new_privileges"],
"controls_missing": []
}
}
}result.verdict: "RE" (crashed) means the program exited with a non-zero code. output.stderr holds the error message, and result.exit_code is the exact code the program returned.
6. Try another language#
All 8 languages work the same way. Just change the language field:
curl -s -X POST "https://api.rustbox.sh/api/submit?wait=true" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_key_here" \
-d '{"language": "javascript", "code": "console.log(\"Hello from JS\")"}' | jq
curl -s -X POST "https://api.rustbox.sh/api/submit?wait=true" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_key_here" \
-d '{"language": "c", "code": "#include <stdio.h>\nint main() { printf(\"Hello from C\\n\"); return 0; }"}' | jq
curl -s -X POST "https://api.rustbox.sh/api/submit?wait=true" \
-H "Content-Type: application/json" \
-H "X-API-Key: rb_live_your_key_here" \
-d '{"language": "go", "code": "package main\nimport \"fmt\"\nfunc main() { fmt.Println(\"Hello from Go\") }"}' | jqNext steps#
- API Reference - Every endpoint, every field
- Limits - Memory and time limits per language
- POST /api/judge - Run one program against many test cases
- Webhooks - Results sent to your server, signed
- Security - How the 8 layers of protection work