مرجع کامل endpointهای بخش «زمانبندی» در API کلاینت پافرلند.
ساخت و مدیریت وظایف خودکار با زمانبندی کرون (cron). مجوزهای لازم: schedule.read، schedule.create، schedule.update، schedule.delete و schedule.execute.
در مسیرهای زیر {schedule} شناسهی عددی زمانبندی و {task} شناسهی عددی وظیفه است. محدودیتها: ۱۰ تا ۵۰ زمانبندی برای هر سرور، حداکثر ۲۰ وظیفه برای هر زمانبندی و ۳ زمانبندی همزمان در حال اجرا.
GET /api/client/servers/{server}/schedules
تمام زمانبندیهای سرور را برمیگرداند.
curl "https://pufferland.ir/api/client/servers/1a85a183/schedules" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json"
نمونه پاسخ واقعی:
{
"object" : "list" ,
"data" : []
}
GET /api/client/servers/{server}/schedules/{schedule}
جزئیات یک زمانبندی شامل تمام وظایف آن را برمیگرداند: name، cron (با فیلدهای minute، hour، day_of_month، month، day_of_week)، is_active، is_processing، last_run_at، next_run_at و relationships.tasks.
curl "https://pufferland.ir/api/client/servers/1a85a183/schedules/1" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json"
POST /api/client/servers/{server}/schedules
یک زمانبندی جدید میسازد. خطاها: 400 با کد TooManySchedulesException و 422 با کد ValidationException برای الگوی کرون نامعتبر.
فیلد نوع الزام توضیح
namestring ✓ نام زمانبندی (حداکثر ۲۵۵ کاراکتر).
minutestring ✓ کرون دقیقه: ۰–۵۹ یا *.
hourstring ✓ کرون ساعت: ۰–۲۳ یا *.
day_of_monthstring ✓ روز ماه: ۱–۳۱ یا *.
monthstring ✓ ماه: ۱–۱۲ یا *.
day_of_weekstring ✓ روز هفته: ۰–۶ یا *.
is_activeboolean — پیشفرض true.
only_when_onlineboolean — اجرا فقط وقتی سرور روشن است؛ پیشفرض false.
curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"name": "Nightly Restart", "minute": "0", "hour": "4", "day_of_month": "*", "month": "*", "day_of_week": "*", "is_active": true}'
await fetch('https://pufferland.ir/api/client/servers/1a85a183/schedules', {
method: 'POST',
headers: {
Authorization: 'Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Nightly Restart', minute: '0', hour: '4',
day_of_month: '*', month: '*', day_of_week: '*', is_active: true,
}),
}).then(r => r.json()).then(console.log);
import requests
r = requests.post(
"https://pufferland.ir/api/client/servers/1a85a183/schedules",
json={
"name": "Nightly Restart", "minute": "0", "hour": "4",
"day_of_month": "*", "month": "*", "day_of_week": "*",
"is_active": True,
},
headers={"Authorization": "Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx"},
)
print(r.json())
curl_post('https://pufferland.ir/api/client/servers/1a85a183/schedules', [
CURLOPT_POSTFIELDS => json_encode(['name' => 'Nightly Restart', 'minute' => '0', 'hour' => '4', 'day_of_month' => '*', 'month' => '*', 'day_of_week' => '*', 'is_active' => true]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type: application/json',
],
]);
نمونه پاسخ واقعی:
{
"object" : "server_schedule" ,
"attributes" : {
"id" : 78,
"name" : "docs-sample" ,
"cron" : {
"day_of_week" : "*" ,
"day_of_month" : "*" ,
"month" : "*" ,
"hour" : "5" ,
"minute" : "0"
},
"is_active" : false,
"is_processing" : false,
"only_when_online" : false,
"last_run_at" : null,
"next_run_at" : "2026-09-17T05:00:00+03:30" ,
"created_at" : "2026-09-16T05:38:49+03:30" ,
"updated_at" : "2026-09-16T05:38:49+03:30" ,
"relationships" : {
"tasks" : {
"object" : "list" ,
"data" : []
}
}
}
}
POST /api/client/servers/{server}/schedules/{schedule}
تنظیمات زمانبندی موجود را تغییر میدهد. فیلدها همان ساخت است اما همگی اختیاریاند. پاسخ موفق: 204 بدون بدنه.
curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules/1" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"name": "Restart شبانه", "is_active": true}'
DELETE /api/client/servers/{server}/schedules/{schedule}
زمانبندی و تمام وظایف آن را برای همیشه حذف میکند. پاسخ موفق: 204.
حذف زمانبندی دائمی و غیرقابل بازگشت است.
curl -X DELETE "https://pufferland.ir/api/client/servers/1a85a183/schedules/1" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json"
نمونه پاسخ واقعی:
204 No Content
POST /api/client/servers/{server}/schedules/{schedule}/execute
زمانبندی را بلافاصله و بهصورت دستی اجرا میکند. پاسخ موفق: 204. خطای 409 با کد ConflictingServerStateException اگر در حال اجرا باشد و 400 اگر زمانبندی غیرفعال باشد.
curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/execute" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json" \
-H "Content-Type: application/json"
GET /api/client/servers/{server}/schedules/{schedule}/tasks
فهرست وظایف یک زمانبندی را برمیگرداند.
curl "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json"
POST /api/client/servers/{server}/schedules/{schedule}/tasks
یک وظیفهی جدید به زمانبندی اضافه میکند.
فیلد نوع الزام توضیح
actionstring ✓ یکی از command، power یا backup.
payloadstring ✓ برای command: متن دستور؛ برای power: start، stop، restart یا kill؛ برای backup: رشتهی خالی یا نام بکاپ.
time_offsetinteger ✓ تأخیر بر حسب ثانیه بعد از وظیفهی قبلی.
continue_on_failureboolean — ادامه پس از شکست؛ پیشفرض false.
پاسخ شامل id، action، payload، sequence_id و time_offset است.
curl -X POST "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"action": "command", "payload": "say Hello", "time_offset": 0}'
نمونه پاسخ واقعی:
{
"object" : "schedule_task" ,
"attributes" : {
"id" : 61,
"sequence_id" : 1,
"action" : "command" ,
"payload" : "say hi" ,
"time_offset" : 0,
"is_queued" : false,
"continue_on_failure" : false,
"created_at" : "2026-09-16T05:38:49+03:30" ,
"updated_at" : "2026-09-16T05:38:49+03:30"
}
}
PATCH /api/client/servers/{server}/schedules/{schedule}/tasks/{task}
وظیفهی مشخصشده را ویرایش میکند (همان فیلدهای ساخت).
curl -X PATCH "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks/1" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"payload": "say Updated"}'
DELETE /api/client/servers/{server}/schedules/{schedule}/tasks/{task}
وظیفه را از زمانبندی حذف میکند. پاسخ موفق: 204.
curl -X DELETE "https://pufferland.ir/api/client/servers/1a85a183/schedules/1/tasks/1" \
-H "Authorization: Bearer ptlc_xxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Accept: application/json"