Enqueue Task
Enqueues a new task to be executed at a scheduled time.
Authentication
Requires authentication. Pass your API key via X-API-Key or Authorization: Bearer header.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | The unique identifier of the scheduler |
Request Body
| Field | Type | Description |
|---|---|---|
| id | string | Required task ID |
| future | string | ISO 8601 timestamp for when the task should become available |
| delay | string | Go duration string from now, such as 60s or 5m (alternative to future) |
| payload | object | Arbitrary JSON payload for the worker |
| labels | array of strings | Optional labels for filtering |
1{
2 "id": "task-x1y2z3",
3 "payload": {
4 "type": "send_email",
5 "to": "user@example.com",
6 "template": "welcome"
7 },
8 "delay": "60s",
9 "labels": ["project:onboarding", "priority:high"]
10}
Example Request
curl -X POST "https://api.hola.cloud/schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "task-x1y2z3",
"payload": {
"type": "send_email",
"to": "user@example.com",
"template": "welcome"
},
"delay": "60s",
"labels": ["project:onboarding", "priority:high"]
}'POST /schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks HTTP/1.1
Host: api.hola.cloud
X-API-Key: YOUR_API_KEY
Content-Type: application/json
{
"id": "task-x1y2z3",
"payload": {
"type": "send_email",
"to": "user@example.com",
"template": "welcome"
},
"delay": "60s",
"labels": ["project:onboarding", "priority:high"]
}package main
import (
"fmt"
"io"
"net/http"
"encoding/json"
"strings"
)
func main() {
payload := map[string]any{"delay": "60s", "id": "task-x1y2z3", "labels": []any{"project:onboarding", "priority:high"}, "payload": map[string]any{"template": "welcome", "to": "user@example.com", "type": "send_email"}}
bodyBytes, err := json.Marshal(payload)
if err != nil {
panic(err)
}
body := string(bodyBytes)
req, err := http.NewRequest("POST", "https://api.hola.cloud/schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(responseBody))
}
<?php
$payload = ['delay' => '60s', 'id' => 'task-x1y2z3', 'labels' => ['project:onboarding', 'priority:high'], 'payload' => ['template' => 'welcome', 'to' => 'user@example.com', 'type' => 'send_email']];
$body = json_encode($payload);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.hola.cloud/schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => [
'X-API-Key: YOUR_API_KEY',
'Content-Type: application/json',
],
]);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
curl_close($ch);
echo $response;
import requests
import json
headers = {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {"delay": "60s", "id": "task-x1y2z3", "labels": ["project:onboarding", "priority:high"], "payload": {"template": "welcome", "to": "user@example.com", "type": "send_email"}}
body = json.dumps(payload)
response = requests.request(
"POST",
"https://api.hola.cloud/schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks",
headers=headers,
data=body
)
print(response.text)
const payload = {"delay": "60s", "id": "task-x1y2z3", "labels": ["project:onboarding", "priority:high"], "payload": {"template": "welcome", "to": "user@example.com", "type": "send_email"}};
const response = await fetch("https://api.hola.cloud/schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
console.log(await response.text());
const payload = {"delay": "60s", "id": "task-x1y2z3", "labels": ["project:onboarding", "priority:high"], "payload": {"template": "welcome", "to": "user@example.com", "type": "send_email"}};
const response = await fetch("https://api.hola.cloud/schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.List;
public class Main {
public static void main(String[] args) throws Exception {
var payload = Map.of("delay", "60s", "id", "task-x1y2z3", "labels", List.of("project:onboarding", "priority:high"), "payload", Map.of("template", "welcome", "to", "user@example.com", "type", "send_email"));
var body = new ObjectMapper().writeValueAsString(payload);
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.hola.cloud/schedulers/sched-a1b2c3d4-e5f6-7890-abcd-ef1234567890/tasks"))
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.header("X-API-Key", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}Example Response
1HTTP/1.1 202 Accepted
The response body is empty.
Error Codes
| Status | Code | Description |
|---|---|---|
| 400 | invalid_json | Invalid JSON payload |
| 400 | validation_error | Missing id, invalid future/delay, or invalid labels |
| 401 | unauthorized | Missing or invalid API key |
| 409 | task_already_exists | Task already exists |
| 500 | internal_error | Internal server error |
Comments