Schedules endpoint
Schedules are a tool that can be used to automatically run batch segmentation jobs once a day. You can use the /config/schedules
endpoint to retrieve a list of schedules, create a new schedule, retrieve details of a specific schedule, update a specific schedule, or delete a specific schedule.
Getting started
The endpoints used in this guide are part of the ۶Ƶ Experience Platform Segmentation Service API. Before continuing, please review the getting started guide for important information that you need to know in order to successfully make calls to the API, including required headers and how to read example API calls.
Retrieve a list of schedules retrieve-list
You can retrieve a list of all schedules for your organization by making a GET request to the /config/schedules
endpoint.
API format
The /config/schedules
endpoint supports several query parameters to help filter your results. While these parameters are optional, their use is strongly recommended to help reduce expensive overhead. Making a call to this endpoint with no parameters will retrieve all schedules available for your organization. Multiple parameters can be included, separated by ampersands (&
).
GET /config/schedules
GET /config/schedules?{QUERY_PARAMETERS}
Query parameters
table 0-row-3 1-row-3 2-row-3 | ||
---|---|---|
Parameter | Description | Example |
start |
Specifies which page the offset will start from. By default, this value will be 0. | start=5 |
limit |
Specifies the number of schedules returned. By default, this value will be 100. | limit=20 |
Request
The following request will retrieve the last ten schedules posted within your organization.
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with a list of schedules for the specified organization as JSON.
code language-json |
---|
|
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 8-row-2 | |
---|---|
Property | Description |
_page.totalCount |
The total number of schedules returned. |
_page.pageSize |
The size of the page of schedules. |
children.name |
The name of the schedule as a string. |
children.type |
The type of job as a string. The two supported types are “batch_segmentation” and “export”. |
children.properties |
An object containing additional properties related to the schedule. |
children.properties.segments |
Using ["*"] ensures all segments are included. |
children.schedule |
A string containing the job schedule. Jobs can only be scheduled to run once a day, meaning you cannot schedule a job to run more than once during a 24-hour period. For more information about cron schedules, please read the appendix on the cron expression format. In this example, “0 0 1 * *” means that this schedule will run at 1AM every day. |
children.state |
A string containing the schedule state. The two supported states are “active” and “inactive”. By default, the state is set to “inactive”. |
Create a new schedule create
You can create a new schedule by making a POST request to the /config/schedules
endpoint.
API format
POST /config/schedules
Request
code language-shell |
---|
|
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 | |
---|---|
Property | Description |
name |
Required. The name of the schedule as a string. |
type |
Required. The type of job as a string. The two supported types are “batch_segmentation” and “export”. |
properties |
Required. An object containing additional properties related to the schedule. |
properties.segments |
Required when type equals “batch_segmentation”. Using ["*"] ensures all segments are included. |
schedule |
Optional. A string containing the job schedule. Jobs can only be scheduled to run once a day, meaning you cannot schedule a job to run more than once during a 24-hour period. For more information about cron schedules, please read the appendix on the cron expression format. In this example, “0 0 1 * *” means that this schedule will run at 1AM every day. If this string is not supplied, a system-generated schedule will be automatically generated. |
state |
Optional. A string containing the schedule state. The two supported states are “active” and “inactive”. By default, the state is set to “inactive”. |
Response
A successful response returns HTTP status 200 with details of your newly created schedule.
code language-json |
---|
|
Retrieve a specific schedule get
You can retrieve detailed information about a specific schedule by making a GET request to the /config/schedules
endpoint and providing the ID of the schedule you wish to retrieve in the request path.
API format
GET /config/schedules/{SCHEDULE_ID}
{SCHEDULE_ID}
id
value of the schedule you want to retrieve.Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 200 with detailed information about the specified schedule.
code language-json |
---|
|
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 | |
---|---|
Property | Description |
name |
The name of the schedule as a string. |
type |
The type of job as a string. The two supported types are batch_segmentation and export . |
properties |
An object containing additional properties related to the schedule. |
properties.segments |
Using ["*"] ensures all segments are included. |
schedule |
A string containing the job schedule. Jobs can only be scheduled to run once a day, meaning you cannot schedule a job to run more than once during a 24 hour period. For more information about cron schedules, please read the appendix on the cron expression format. In this example, “0 0 1 * *” means that this schedule will run at 1AM every day. |
state |
A string containing the schedule state. The two supported states are active and inactive . By default, the state is set to inactive . |
Update details for a specific schedule update
You can update a specific schedule by making a PATCH request to the /config/schedules
endpoint and providing the ID of the schedule you are trying to update in the request path.
The PATCH request allows you to update either the state or the cron schedule for an individual schedule.
API format
PATCH /config/schedules/{SCHEDULE_ID}
{SCHEDULE_ID}
id
value of the schedule you want to update.You can use a JSON Patch operation to update the state of the schedule. To update the state, you declare the path
property as /state
and set the value
to either active
or inactive
. For more information about JSON Patch, please read the documentation.
Request
accordion | ||
---|---|---|
A sample request to update the schedule state. | ||
|
table 0-row-2 1-row-2 2-row-2 | |
---|---|
Property | Description |
path |
The path of the value you want to patch. In this case, since you are updating the schedule’s state, you need to set the value of path to “/state”. |
value |
The updated value of the schedule’s state. This value can either be set as “active” or “inactive” to activate or deactivate the schedule. Please note that you cannot disable a schedule if the organization has been enabled for streaming. |
Response
A successful response returns HTTP status 204 (No Content).
path
property as /schedule
and set the value
to a valid cron schedule. For more information about JSON Patch, please read the documentation. For more information about cron schedules, please read the appendix on the cron expression format.Request
code language-shell |
---|
|
table 0-row-2 1-row-2 2-row-2 | |
---|---|
Property | Description |
path |
The path of the value you want to updated. In this case, since you are updating the cron schedule, you need to set the value of path to /schedule . |
value |
The updated value of the cron schedule. This value needs to be in the form of a cron schedule. In this example, the schedule will run on the second of every month. |
Response
A successful response returns HTTP status 204 (No Content).
Delete a specific schedule
You can request to delete a specific schedule by making a DELETE request to the /config/schedules
endpoint and providing the ID of the schedule you wish to delete in the request path.
API format
DELETE /config/schedules/{SCHEDULE_ID}
{SCHEDULE_ID}
id
value of the schedule you want to delete.Request
code language-shell |
---|
|
Response
A successful response returns HTTP status 204 (No Content).
Next steps
After reading this guide you now have a better understanding of how schedules work.
Appendix appendix
The following appendix explains the format of cron expressions used in schedules.
Format
A cron expression is a string that is made up of 6 or 7 fields. The expression would look something similar to the following:
0 0 12 * * ?
In a cron expression string, the first field represents the seconds, the second field represents the minutes, the third field represents the hours, the fourth field represents the day of the month, the fifth field represents the month, and the sixth field represents the day of the week. You can also optionally include a seventh field, which represents the year.
, - * /
, - * /
, - * /
, - * ? / L W
, - * /
, - * ? / L #
, - * /
SUN
is equivalent to using sun
.The special characters allowed represent the following meanings:
*
*
in the hours field would mean every hour.?
3
in the day of the month field and ?
in the day of the week field.-
9-15
in the hours field, this would mean the hours would include 9, 10, 11, 12, 13, 14, and 15.,
MON, FRI, SAT
in the day of the week field, this would mean the days of the week would include Monday, Friday, and Saturday./
/
determines where it increments from, while the value placed after the /
determines how much it increments by. For example, if you put 1/7
in the minutes field, this would mean that the minutes would include 1, 8, 15, 22, 29, 36, 43, 50, and 57.L
Last
, and has a different meaning depending on which field it is used by. If it is used with the day of the month field, it represents the last day of the month. If it is used with the day of the week field by itself, it represents the last day of the week, which is Saturday (SAT
). If it is used with the day of the week field, in conjunction with another value, it represents the last day of that type for the month. For example, if you put 5L
in the day of the week field, it would only include the last Friday of the month.W
18W
in the day of the month field, and the 18th of that month was a Saturday, it would trigger on Friday the 17th, which is the closest weekday. If the 18th of that month was a Sunday, it would trigger on Monday the 19th, which is the closest weekday. Please note that if you put 1W
in the day of the month field, and the closest weekday would be in the previous month, the event will still trigger on the closest weekday of the current month.Additionally, you can combine
L
and W
to make LW
, which would specify the last weekday of the month.#
#
represents the day of the week, while the value placed after the #
represents which occurrence in the month it is. For example, if you put 1#3
, the event would trigger on the third Sunday of the month. Please note that if you put X#5
and there is no fifth occurrence of that day of the week in that month, the event will not be triggered. For example, if you put 1#5
, and there is no fifth Sunday in that month, the event will not be triggered.Examples
The following table shows sample cron expression strings and explains what they mean.
0 0 13 * * ?
0 30 9 * * ? 2022
0 * 18 * * ?
0 0/10 17 * * ?
0 13,38 5 ? 6 WED
0 30 12 ? * 4#3
0 30 12 ? * 6L
0 45 11 ? * MON-THU