Create Schedule
POST https://api.letpay.io/myreports/schedule
Create a new Schedule
This endpoint is used to schedule the execution of a report at a specified time.
Schedules can be created for daily, weekly, or monthly execution by specifying:
- The day of the month (for monthly schedules).
- The day of the week (for weekly schedules).
- The time of execution.
Request description
report
: (required/object) - The report associated with the schedule.id
: (optional/int) - The unique identifier of the report.
run_every
: (required/string) - Specifies the frequency of execution. Accepted values are:DAILY
WEEKLY
MONTHLY
day_of_week
: (optional/string) - Specifies the day of the week when the report will be executed. Required when the frequency is WEEKLY.day_of_month
: (optional/int) - Specifies the day of the month when the report will be executed. Required when the frequency is MONTHLY.run_at
: (required/time (HH:mm)) - Specifies the exact time at which the report will run. Example: 14:30 (2:30 PM).recipient
: (required/string) - Specifies the email addresses to which the report will be sent. Multiple emails can be separated by commas.enable
: (required/boolean) - Determines whether the schedule is enabled or disabled.
Authorization
AUTHORIZATION | API Key |
---|---|
Key | X-Auth-Token |
Value | MY_ACCESS_TOKEN |
Body Raw(json)
json
{
"report": {
"id": {{reportId}}
},
"run_every": "MONTHLY",
"day_of_week": null,
"day_of_month": 5,
"run_at": "08:07:00",
"recipient":"[email protected]",
"enable": true
}
Example Request
- 201 - WEEKLY
- 201 - DAILY
- 201 - MONTHLY
- 401 - Unauthorized
- 400 - Bad Request
Example Request
201 - WEEKLY
curl --location -g 'https://api.letpay.io/myreports/schedule' \
--header 'X-Auth-Token: MY_ACCESS_TOKEN' \
--data-raw '{
"report": {
"id": 183
},
"run_every": "WEEKLY",
"day_of_week": "WEDNESDAY",
"run_at": "08:07:00",
"recipient":"[email protected]",
"enable": true
}'
Example Response
Header
Content-Type: application/json
Body
{
"id": 20,
"report": {
"id": 183
},
"run_every": "WEEKLY",
"day_of_week": "WEDNESDAY",
"day_of_month": null,
"run_at": "08:00:00",
"recipient": "[email protected]",
"enable": true
}
Example Request
201 - DAILY
curl --location -g 'https://api.letpay.io/myreports/schedule' \
--header 'X-Auth-Token: MY_ACCESS_TOKEN' \
--data-raw '{
"report": {
"id": 183
},
"run_every": "DAILY",
"run_at": "17:01:00",
"recipient":"[email protected]",
"enable": true
}'
Example Response
Header
Content-Type: application/json
Body
{
"id": 23,
"report": {
"id": 183
},
"run_at": "17:01:00",
"recipient": "[email protected]",
"enable": true
}
Example Request
201 - MONTHLY
curl --location -g 'https://api.letpay.io/myreports/schedule' \
--header 'X-Auth-Token: MY_ACCESS_TOKEN' \
--data-raw '{
"id": 17,
"report": {
"id": 183
},
"run_every": "MONTHLY",
"day_of_week": null,
"day_of_month": 5,
"run_at": "08:07:00",
"recipient":"[email protected]",
"enable": true
}'
Example Response
Header
Content-Type: application/json
Body
{
"id": 17,
"report": {
"id": 183,
"name": "Po1553"
},
"run_every": "MONTHLY",
"day_of_week": null,
"day_of_month": 5,
"run_at": "08:07:00",
"recipient": "[email protected]",
"next_execution": "2025-01-05T08:07:00",
"last_execution": null,
"enable": true
}
Example Request
401 - Unauthorized
curl --location -g 'https://api.letpay.io/myreports/schedule' \
--header 'X-Auth-Token: MY_ACCESS_TOKEN' \
--data-raw '{
"id": 17,
"report": {
"id": 183
},
"run_every": "MONTHLY",
"day_of_week": null,
"day_of_month": 5,
"run_at": "08:07:00",
"recipient":"[email protected]",
"enable": true
}'
Example Response
Header
Content-Type: application/json
Body
{
"message": "Invalid or expired token",
"code": 0,
"details": {}
}
Example Request
400 - Bad Request
curl --location -g 'https://api.letpay.io/myreports/schedule' \
--header 'X-Auth-Token: MY_ACCESS_TOKEN' \
--data-raw '{
"id": 17,
"report": {
"id": 183
},
"run_every": null,
"day_of_week": null,
"run_at": null,
"recipient":"[email protected]",
"enable": true
}'
Example Response
Header
Content-Type: application/json
Body
{
"message": "Validation error",
"code": 0,
"details": {
"runAt": "não deve ser nulo",
"runEvery": "não deve ser nulo"
}
}