Functions
14 endpoints at https://api.kosa8.com, sent with Authorization: Bearer $KOSA8_API_KEY. Generated from the API's own OpenAPI description, which a test holds to the router.
List functions#
GET
Responses/v1/functionsscope functions:invoke200401403
curl -s -X GET https://api.kosa8.com/v1/functions \ -H "Authorization: Bearer $KOSA8_API_KEY"
Deploy or replace a function (bumps version)#
PUT
/v1/functions/{name}scope functions:deploy201 when the name is new (version 1); 200 when it replaces a deployed function.
Parametersnamerequiredpath · stringFunction name
runtimerequired"python3.12" | "node22"—
coderequiredstringThe source, at most 1 MiB
envobjectNames not starting with K8_; 16 KiB in all
timeout_sintegerDefault
30. Min 1. Max 90.web"off" | "public" | "key"Default
"off".schedulestring | nullA five-field cron expression (UTC), or null for none
200201400401403413
curl -s -X PUT https://api.kosa8.com/v1/functions/$NAME \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
Get a function with its code#
GET
Parameters/v1/functions/{name}scope functions:deploynamerequiredpath · stringFunction name
200401403404
curl -s -X GET https://api.kosa8.com/v1/functions/$NAME \ -H "Authorization: Bearer $KOSA8_API_KEY"
Delete a function#
DELETE
Parameters/v1/functions/{name}scope functions:deploynamerequiredpath · stringFunction name
200401403404
curl -s -X DELETE https://api.kosa8.com/v1/functions/$NAME \ -H "Authorization: Bearer $KOSA8_API_KEY"
Call a function: {event} → result, logs, timings#
POST
Parameters/v1/functions/{name}/invokescope functions:invokenamerequiredpath · stringFunction name
eventobject—
200401402403404
curl -s -X POST https://api.kosa8.com/v1/functions/$NAME/invoke \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
Call a function on up to 100 events#
POST
Parameters/v1/functions/{name}/mapscope functions:invokenamerequiredpath · stringFunction name
eventsrequiredarray of object—
concurrencyintegerMax 16.
200401402403404
curl -s -X POST https://api.kosa8.com/v1/functions/$NAME/map \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
Recent calls, newest first#
GET
Parameters/v1/functions/{name}/invocationsscope functions:invokenamerequiredpath · stringFunction name
limitquery · integerHow many
200401403
curl -s -X GET https://api.kosa8.com/v1/functions/$NAME/invocations \ -H "Authorization: Bearer $KOSA8_API_KEY"
Run code or a command in a fresh sandbox, one call: output, exit code and files back, sandbox deleted#
POST
/v1/runscope sandboxes:writeBilled per second like any sandbox. A command that exits non-zero is a 200 with status failed; 4xx/5xx carry hint (the next step) and docs.
JSON bodycodestringSource to run; written to filename (main.<ext>) in /workspace
commandstring | array of stringA shell string, or a list of strings; with code, runs instead of the language's own command
language"python" | "node" | "typescript" | "bash" | "sh"Default: from filename, else python
filenamestring—
templatestringDefault: the language's (python, node, base)
filesobject | array of object{path: text} or [{path, content, encoding: utf8|base64}]; paths are under /workspace
envobject—
sizestring—
timeout_sintegerDefault
60. Min 1. Max 3600.streamboolean | "ndjson" | "sse"true or ndjson: NDJSON frames as it prints; sse: server-sent events (or send Accept: text/event-stream)
outputsarray of stringFiles to send back, base64, 4 MiB together
shareboolean | objecttrue: a public read-only run card (command, output, duration; never env or files). {public, code} also shows the code.
200400401402403413429
curl -s -X POST https://api.kosa8.com/v1/run \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
The org's recent runs, newest first (kept 30 days)#
GET
Parameters/v1/runsscope sandboxes:readlimitquery · integerHow many, up to 100
200401403
curl -s -X GET https://api.kosa8.com/v1/runs \ -H "Authorization: Bearer $KOSA8_API_KEY"
One run, with the saved tail of its output#
GET
Parameters/v1/runs/{id}scope sandboxes:readidrequiredpath · stringRun id (sr_…)
200401403404
curl -s -X GET https://api.kosa8.com/v1/runs/$SBX \ -H "Authorization: Bearer $KOSA8_API_KEY"
Publish or unpublish a run's read-only card#
POST
Parameters/v1/runs/{id}/sharescope sandboxes:writeidrequiredpath · stringRun id (sr_…)
publicrequiredboolean—
codeboolean—
200400401403404
curl -s -X POST https://api.kosa8.com/v1/runs/$SBX/share \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
A run card's model (serverless run, job or RL run) for the org's members#
GET
Parameters/v1/cards/{id}scope sandboxes:readidrequiredpath · stringsr_…, job_… or run_…
200401403404
curl -s -X GET https://api.kosa8.com/v1/cards/$SBX \ -H "Authorization: Bearer $KOSA8_API_KEY"
Publish or unpublish a job's read-only card#
POST
Parameters/v1/jobs/{id}/sharescope sandboxes:writeidrequiredpath · stringJob id
publicrequiredboolean—
200400401403404
curl -s -X POST https://api.kosa8.com/v1/jobs/$SBX/share \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json
Publish or unpublish an RL run's read-only card#
POST
Parameters/v1/rl/runs/{id}/sharescope sandboxes:writeidrequiredpath · stringRL run id
publicrequiredboolean—
200400401403404
curl -s -X POST https://api.kosa8.com/v1/rl/runs/$SBX/share \ -H "Authorization: Bearer $KOSA8_API_KEY" \ -H 'Content-Type: application/json' -d @body.json