Run a definition over history
/scripts/{slug}/collectRuns one version of a definition over a window and stores its events, the same as running it over history in the app. Only the part of the window the definition has not covered yet runs.
Scope | Heavy call | Long poll | CLI |
|---|---|---|---|
| Yes | No |
|
Guidance
The call returns once the work is queued. Then poll Summarise events until
collectingis empty, and read the events with List events. Thenextfield says the same.Calling it again for a window that is already covered answers
200withcovered: trueand runs nothing, so it is safe to call before every study.You rarely need it before a study: Create a run of a study runs each definition it reads over the study's window first.
The window is not moved to your plan's history start, unlike a run's. Keep
fromat or afterhistory_startfrom Get usage.heldcounts parts held back instead of queued, because they cannot run as things stand. A non-zeroheldmeans the window will not be fully covered whencollectingempties.The stored events count toward your plan's definition events. At the cap, or when your plan does not include running definitions over history, the answer is
403 plan_limit.It is a heavy call. On
429 busy, wait forRetry-After(2 seconds) and send it again.
Path parameters
Name | Type | Description |
|---|---|---|
| string | Your definition's slug |
Request body
Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Canonical or short symbol |
| string | Yes | One of the timeframes. Upper case is lowered |
| object | Yes | Exactly one of |
| integer | No | The version to run. Defaults to the latest |
Response
202 when runs were queued, 200 when the whole window was already covered:
Field | Type | Description |
|---|---|---|
| string | The version that runs, as |
| string | Canonical symbol |
| string | Timeframe |
| object |
|
| boolean |
|
| integer | How many runs were queued for the parts not covered |
| integer | How many parts were held back instead of queued |
| string | What to call next |
Status codes
Status | Code | Meaning |
|---|---|---|
| - | The window was already covered. Nothing ran |
| - | Runs were queued for the parts not covered |
|
| The slug or body is not valid, or the window is not: it needs exactly one of |
|
| No instrument matches |
|
|
|
|
| Your plan does not include running definitions over history, or you are at your definition events cap |
|
| You have no definition with that slug, or it has no such |
|
| Past your heavy calls at once. |
