package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.elefork.com/v1/projects/example/tasks"
payload := strings.NewReader("{ \"name\": \"example\", \"template\": \"example\", \"rules\": [ { \"name\": \"example\", \"sql\": \"example\", \"expect\": \"example\", \"weight\": 1 } ], \"seed\": 1, \"role\": \"owner\", \"allow\": [ \"trigger\" ] }")
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(res) fmt.Println(string(body))
}const url = 'https://api.elefork.com/v1/projects/example/tasks';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"example","template":"example","rules":[{"name":"example","sql":"example","expect":"example","weight":1}],"seed":1,"role":"owner","allow":["trigger"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.elefork.com/v1/projects/example/tasks \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "example", "template": "example", "rules": [ { "name": "example", "sql": "example", "expect": "example", "weight": 1 } ], "seed": 1, "role": "owner", "allow": [ "trigger" ] }'Creating a task with an existing name adds a new version. The control plane fingerprints a fresh branch of
the template (catalog, watched system catalogs, table contents, start WAL position); episodes can start
once state is ready.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Template id or name (platform or org)
Runs read-only on the sealed copy with search_path = pg_catalog, pg_temp (schema-qualify user tables). It
must return one row with one column. The rule passes when the value equals expect (JSON comparison;
numeric strings compare numerically), or is true when expect is omitted.
object
Expected value (any JSON)
Recorded with the task; not yet applied with setseed()
Role the agent is expected to use. Results of superuser tasks are marked not tamper-evident.
Object kinds the task may legitimately create or change (not reported as tampering).
Responses
Section titled “Responses”Created; preparing its baseline
object
Runs read-only on the sealed copy with search_path = pg_catalog, pg_temp (schema-qualify user tables). It
must return one row with one column. The rule passes when the value equals expect (JSON comparison;
numeric strings compare numerically), or is true when expect is omitted.
object
Expected value (any JSON)
Example
{ "role": "owner", "allow": [ "trigger" ], "rules": [ { "weight": 1 } ], "state": "preparing"}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}idempotency_mismatch: this Idempotency-Key was used with a different request
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Error
object
object
Example
{ "error": { "code": "not_found" }}Temporarily unavailable; retry after the Retry-After seconds. Codes:
database_unavailable (the metadata database is failing over) and
cube_admission (a compute node runs a sandbox shim below the
platform minimum, so creates, forks, checkpoints and resets are
refused until it is upgraded).
object
object
Example
{ "error": { "code": "not_found" }}