Managing pulling mode and smart schedule in Management API#
This guide explains how to list datastreams and manage their pulling mode — switching between smart schedule and custom schedule — using the Management API.
Both schedule types coexist: switching to smart schedule does not delete your custom schedule configuration, so you can switch back at any time. For information on configuring custom fetch schedules, see Scheduling fetches.
Warning
PATCH and PUT requests accept optional query parameters to limit the
scope of the operation. If no filter parameters are included, the
request applies to all datastreams accessible to the API key.
Always include the datastream_id parameter (or another filter)
when you intend to update a specific datastream.
Note
On PATCH and PUT requests, the datastream_id and workspace_id
parameters each accept at most 50 repeated values. Requests that exceed
this limit return an HTTP 422 error.
Prerequisites#
Before you complete the procedures in this guide, perform all of the following actions:
Generate an API key with the appropriate scope:
datastream:readto list datastreams.datastream:writeto update datastream configuration.
For more information on generating API keys, see Authorizing to Management API.
Create a datastream and note its datastream ID. For more information, see Creating datastreams.
Listing datastreams#
To retrieve a list of datastreams, follow these steps:
Create a GET request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastreams/
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}.Optionally, add query parameters to filter the results:
Parameter
Description
datastream_idOne or more datastream UUIDs. Repeat the parameter for multiple values.
workspace_idOne or more workspace UUIDs. Repeat the parameter for multiple values.
workspace_scopeScope of the workspace filter. Accepted values:
ancestors,descendants,family.enabledFilter by enabled state. Accepted values:
true,false.active_pulling_modeFilter by active pulling mode. Accepted values:
smart,smart-bundle,schedule.scheduled_deletionFilter by scheduled deletion state. Use
trueto return only the datastreams that are scheduled for deletion, orfalseto exclude them. Omit the parameter to return both.Send the request.
As a result, you obtain the list of datastreams in the response.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request GET 'https://{{INSTANCE}}/api/v1/datastreams/' \
--header 'Authorization: Bearer {{KEY}}'
The example response below shows one datastream with smart schedule active:
{
"count": 1,
"items": [
{
"id": "{{DATASTREAM_UUID}}",
"name": "{{DATASTREAM_NAME}}",
"enabled": true,
"workspace": {
"id": "{{WORKSPACE_UUID}}",
"name": "{{WORKSPACE_NAME}}"
},
"pulling": {
"active_mode": "smart",
"smart": {
"is_active": true,
"range_spec": [
{
"frequency": {"value": 1, "unit": "day"},
"on": null,
"range": {"value": 7, "unit": "day"}
},
{
"frequency": {"value": 1, "unit": "week"},
"on": {"day": 1, "day_type": "week"},
"range": {"value": 30, "unit": "day"}
}
],
"deadline": null,
"start": null,
"frequency": "daily",
"refresh_range": {
"value": 6,
"unit": "day"
}
},
"smart_bundle": null
}
}
]
}
The pulling.active_mode field indicates which schedule type is
currently active for the datastream. Possible values are:
smart— smart schedule is active.smart-bundle— a smart bundle schedule is active (deprecated).schedule— a custom fetch schedule is active.null— no schedule is configured.
The response describes the smart schedule twice, and range_spec is
the authoritative version:
range_speclists every configured range. A datastream can have up to four, for example a daily check plus a wider weekly refresh.frequencyandrefresh_rangeare only present to provide backwards compatibility for integrations written beforerange_specexisted. They summarise the same configuration as a single cadence. Adverity derives them fromrange_specon every request, and reports the range with the finest cadence — the one that fires most often — asfrequency, with the history it refreshes beyond one cadence period asrefresh_range, always in days. In the example above, the weekly range does not appear in this summary.
Enabling or disabling datastreams#
To enable or disable one or more datastreams, follow these steps:
Create a PATCH request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastreams/
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}.In the HTTP request header, include the parameter
Content-Typewith valueapplication/json.Optionally, add query parameters to filter which datastreams are affected. See the filter parameters described in Listing datastreams.
In the HTTP request body, include the
enabledparameter set totrueorfalse.Send the request.
As a result, the specified datastreams are enabled or disabled. The response contains the UUIDs of all datastreams whose state actually changed.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request PATCH 'https://{{INSTANCE}}/api/v1/datastreams/?datastream_id={{DATASTREAM_UUID}}' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{"enabled": false}'
The example response is the following:
{
"affected": {
"datastream_ids": ["{{DATASTREAM_UUID}}"]
}
}
Switching to smart schedule#
To switch one or more datastreams to smart schedule, follow these steps:
Create a PATCH request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastreams/
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}.In the HTTP request header, include the parameter
Content-Typewith valueapplication/json.Optionally, add query parameters to filter which datastreams are affected. See the filter parameters described in Listing datastreams.
In the HTTP request body, include the following payload:
{ "pulling": { "active_mode": "smart" } }
Send the request.
As a result, smart schedule is activated for the targeted datastreams. The response contains the UUIDs of all datastreams whose pulling mode actually changed.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request PATCH 'https://{{INSTANCE}}/api/v1/datastreams/?datastream_id={{DATASTREAM_UUID}}' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{"pulling": {"active_mode": "smart"}}'
The example response is the following:
{
"affected": {
"datastream_ids": ["{{DATASTREAM_UUID}}"]
}
}
Switching to custom schedule#
To switch one or more datastreams to a custom schedule, follow these steps:
Note
A datastream must already have a custom fetch schedule configured
before you can switch it to schedule mode. If any datastream
in the targeted set has no fetch schedule, the request returns
HTTP 400 and no changes are applied. To configure a custom
schedule, see
Scheduling fetches.
Create a PATCH request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastreams/
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}.In the HTTP request header, include the parameter
Content-Typewith valueapplication/json.Optionally, add query parameters to filter which datastreams are affected. See the filter parameters described in Listing datastreams.
In the HTTP request body, include the following payload:
{ "pulling": { "active_mode": "schedule" } }
Send the request.
As a result, custom schedule is activated for the targeted datastreams. The response contains the UUIDs of all datastreams whose pulling mode actually changed.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request PATCH 'https://{{INSTANCE}}/api/v1/datastreams/?datastream_id={{DATASTREAM_UUID}}' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{"pulling": {"active_mode": "schedule"}}'
The example response is the following:
{
"affected": {
"datastream_ids": ["{{DATASTREAM_UUID}}"]
}
}
Configuring smart-pulling settings#
Warning
This endpoint replaces the entire configuration. The
range_spec in the request body carries the full list of ranges,
so any range you leave out is removed from the targeted
datastreams. To change one range, send the complete
range_spec with that range altered.
The body accepts only the parameters listed below. The
Listing datastreams response also carries
a frequency and refresh_range pair, but those are read-only
and are not part of the PUT request below; including them returns a
validation error.
To set or update the smart-pulling configuration for one or more datastreams, follow these steps:
Create a PUT request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastreams/pulling/smart/
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}.In the HTTP request header, include the parameter
Content-Typewith valueapplication/json.Optionally, add query parameters to filter which datastreams are affected. See the filter parameters described in Listing datastreams.
In the HTTP request body, include the smart-pulling configuration. The available parameters are:
Parameter
Required
Description
is_activeYes
Whether smart schedule is active. Accepted values:
true,false.range_specYes
The ranges to fetch, as a list of one to four objects. Each range fires on its own cadence and refreshes its own window of history. Every range in the list must use a different
frequency. Each object contains:frequency— how often this range is fetched. Containsvalue, an integer, andunit. Only five combinations are accepted: every1day, every1week, every2week, every4week, and every1month. Anything else is rejected.range— the rolling window of history to refresh each time this range fires. Containsvalue, an integer, andunit. The window must cover at least onefrequencyperiod, and must be one of the time ranges the data source offers.on— the day the range fires on. Required for aweekormonthfrequency, and not allowed for adayfrequency. Containsday, an integer from 1 to 7 for a week (Monday is 1) or 1 to 28 for a month, andday_type, eitherweekormonth, matching the frequency unit.
deadlineNo
The time by which the fetch must complete. Omit or send
nullto inherit the workspace’s default deadline (which may itself be no deadline). Contains:time— time inHH:MM:SSformat, rounded to the half hour (for example,10:00:00or10:30:00) and in UTC. An offset is rejected rather than converted.
startNo
The earliest time of day a fetch may start. Uses the same
HH:MM:SSformat, half-hour rounding, and UTC-only rule asdeadline. Contains:time— the earliest start time.
Unlike
deadline,starthas four states, and omitting it is not the same as sending it asnull:Omit the field entirely to leave the datastream’s current start setting unchanged.
Send
startasnullto remove any per-datastream start time and inherit the workspace’s default instead.Send
startwithtimeset tonullto lift the restriction outright. This is an explicit per-datastream setting, not inheritance: it overrides the workspace default rather than falling back to it.Send
startwith atimevalue to set a specific start time for this datastream, overriding the workspace default.
startmust resolve to a time earlier than the effectivedeadline, once workspace defaults are resolved for any value that is inherited. Sending astartat or after the deadline fails with a400error.Send the request.
As a result, the smart-pulling configuration is applied to all targeted datastreams. The response contains the UUIDs of datastreams whose configuration actually changed.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request PUT 'https://{{INSTANCE}}/api/v1/datastreams/pulling/smart/?datastream_id={{DATASTREAM_UUID}}' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"is_active": true,
"range_spec": [
{
"frequency": {"value": 1, "unit": "day"},
"on": null,
"range": {"value": 7, "unit": "day"}
},
{
"frequency": {"value": 1, "unit": "week"},
"on": {"day": 1, "day_type": "week"},
"range": {"value": 30, "unit": "day"}
}
],
"deadline": {
"time": "06:00:00"
},
"start": {
"time": "22:00:00"
}
}'
This example configures two ranges: the last 7 days refreshed every day, and the last 30 days refreshed every Monday.
The example response is the following:
{
"affected": {
"datastream_ids": ["{{DATASTREAM_UUID}}"]
}
}