Actions: Preview, Then Confirm
An Action is a bulk operation Provet runs for a signed-in user after the user has seen and confirmed what it will do, for example sending debt letters to a list of clients. Every Action works the same way:
Preview. Your application sends the request. Provet checks it against live data and answers with what would happen. Nothing is written.
Show the preview to the user. The user confirms it, or not.
Confirm. Your application confirms that preview. Provet runs exactly what the preview showed, as that user.
Follow the run until it is done or failed.
The request and response bodies of each Action are in the
schema, under the tag
Action: <key>.
Access
Only OAuth tokens issued to a user work. An Action runs as that user, with that user’s permissions. Legacy API keys and tokens without a user (client credentials) get
403with codeuser_token_required; a request without credentials gets401. See Authentication via OAuth 2.0.The token needs the
restapiandactionsscopes: request them together, asscope=restapi actions.actionsalone is refused with the OAuth errorinvalid_scope, because the rest of the REST API authorizes by the user’s permissions, not by scope. A token withoutactionsgets403with codeinsufficient_scopeon every endpoint below. The scope is not self-service: it is enabled for your application when you agree on Actions with Provet (see Adding an Application in Provet).Each Action is switched on separately. An Action that is not enabled for the organization answers
403with codefeature_disabled. The user also needs the permissions of the page the Action mirrors; otherwise the answer is403with codepermission_denied.The department is the user’s active department in Provet, the one the user last selected in the app. Your application does not choose it.
GET actions/ lists every Action and tells you, in enabled, whether this
user may run it now. It applies the same checks as the Action’s own endpoints,
so use it instead of trying a preview.
Endpoints
All paths are under /<provet_id>/api/0.1/.
Call |
Request |
Response |
|---|---|---|
|
Every Action: |
|
|
The Action’s parameters |
|
|
|
The run. |
|
Filters: |
The user’s own runs: |
Previews
A
preview_idis valid forpreview_ttl_seconds(10 minutes by default) and can be confirmed once, by the same user, for the same Action.Confirm runs what the preview showed. It never recomputes the list. If the data changed since the preview in a way that matters (for example, a client paid), confirm answers
400with codepreview_stale: preview again and show the user the new result.A preview with nothing to do answers
400withpreview_empty. More targets thanmax_targetsanswer400withtoo_many_targets.
Retries
Confirm is safe to retry with the same preview_id:
200with the run: this preview was already confirmed. Nothing ran twice.409withconfirm_in_progress: the first confirm is still starting the run. Wait a moment and retry.400withpreview_not_found: the preview expired, was refused, or never existed. Preview again.
Following a run
Poll GET action_runs/{id}/ until status is done or failed. When
a run fails, error_code says why:
start_failed: the work could not be started.task_failed: the background work failed. Part of it may be done; theresultcounts, when present, say how much.timed_out: the work did not report back in time.
Runs stay readable while an Action is switched off, so a started run can always be followed to its end.
Errors and rate limits
Errors carry {"detail": "...", "code": "..."}. Branch on code, which is
stable; detail is for people and may change.
Rate limits apply per user, not per token: every token of the same user,
in every application, shares one budget. By default, per minute: 30 previews and
10 confirms per Action, 60 list calls and 120 run lookups. A request over the
limit gets 429 with Retry-After. See Rate limit.