Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

Activate a Service Revision with the REST APIBeta

Beta
This is coming — this page describes a feature that's still being rolled out and may not be available to you yet.

Activate a revision of a service from a script or CI job, and find out whether it went live or is waiting for quality checks.


About This Task​

Some services test every new revision before it goes live. That test is called a Deployment Gate, and it works like a release gate in a CI/CD workflow. When you activate a revision on such a service, it doesn't serve requests right away. The platform holds it while the checks run, and the service keeps answering with its current revision until they pass. Services without a gate activate revisions immediately.

The hold applies when you activate a revision that was never active before. It also applies when you re-activate a service that has never had an active or pending revision. Re-activating a revision that was active before isn't held.

In the API, a service is called a deployment. Currently, you create gates only with the REST API. To learn what a gate checks, see Deployment Gates.

Prerequisites​

  • You need a Haystack Platform API key. For details, see Generate API Keys.
  • You need the ID of the service and the ID of the revision you want to activate.

Activate a Revision​

Send a POST request to Activate Deployment Revision. Replace <YOUR_WORKSPACE>, <DEPLOYMENT_ID>, <REVISION_ID>, and <YOUR_API_KEY> with your values:

curl --request POST \
--url https://api.cloud.deepset.ai/api/v1/workspaces/<YOUR_WORKSPACE>/deployments/<DEPLOYMENT_ID>/revisions/<REVISION_ID>/activate \
--header 'accept: application/json' \
--header 'authorization: Bearer <YOUR_API_KEY>'

To activate a service that has no revision yet, use Activate Deployment instead.

If a gate holds the revision, the response contains a deployment_gate_result_id. Keep it to follow the result.

Follow a Held Revision​

To find out whether the held revision passed, read its Gate Result. Replace <DEPLOYMENT_GATE_RESULT_ID> with the ID from the previous step:

curl --request GET \
--url https://api.cloud.deepset.ai/api/v1/workspaces/<YOUR_WORKSPACE>/deployments/<DEPLOYMENT_ID>/gate-results/<DEPLOYMENT_GATE_RESULT_ID> \
--header 'accept: application/json' \
--header 'authorization: Bearer <YOUR_API_KEY>'

The Gate Result gives the status of the run, the checks it judged, the verdict of each check once the run has decided, and the error if the run failed. It also gives the replay suite of each Dataset and the Scoring Run of each Metric Group, so you can open them to see why a check passed or failed.

  • The run passes: the revision activates.
  • The run is still going: the service keeps serving its current revision. Read the progress object to see how far the run has got, and send the request again later (see See How Far a Running Gate Has Got).
  • The run fails: read undecidable, error_code, and the checks in the Gate Result to see why. The service keeps serving its current revision.

The request returns a 404 error if the service or the Gate Result doesn't exist. To read a result in the UI instead, see Check If a Revision Went Live.

See How Far a Running Gate Has Got​

A gate run can take many minutes. While a Gate Result is still in flight, which means its status is pending, replaying, or evaluating, it carries a progress object. Use it to tell a slow run from a stuck one: if the counts keep rising between requests, the run is moving. The object is also on the results that the list, override, and retry requests return. Its fields are:

FieldMeaning
replays_totalHow many Session replay runs the gate planned across its suites.
replays_doneHow many replay runs finished, whether they ended or failed.
replays_failedHow many replay runs failed.
cells_totalHow many evaluation cells, one per Session and Evaluator, the Scoring Runs created so far contain.
cells_doneHow many of those cells finished, whether they were judged, errored, or failed.
sessions_judgedHow many Sessions, counted per Scoring Run, have every one of their cells finished.

The run replays first and judges afterward, so cells_total grows as the Scoring Runs are created. Compare replays_done with replays_total during the replay phase, and cells_done with cells_total during the judging phase.

Once the result is decided, progress is null. Gate Results that predate the field also don't carry it, so handle null in your script.

Tell a Quality Failure from an Undecided Run​

A Gate Result with the status FAILED is not always a quality failure. Two fields tell the cases apart:

  • undecidable: true when the gate could not judge the revision, for example because there was no data to score or a scoring run failed. false when every check was judged. Use this field to treat "could not decide" differently from "missed the goals".
  • error_code: a stable code for why the run failed or could not decide. It is null when a check was judged and missed its goals. The error field keeps the explanation in plain text.

The codes mean:

error_codeMeaning
no_dataThere was nothing to score: no sessions were replayed, or no Evaluator or Evaluator version was available.
low_coverageToo few test cases were judged to reach the check's minimum coverage.
replays_failedEvery replay of the Dataset failed.
run_failedA scoring run or the replay suite failed, or the Evaluator version didn't match the one the check pins.
no_goalsNo Evaluation goals were left to check.
pipeline_mismatchThe revision's pipeline doesn't match the pipeline the check was built for.
timed_outThe run didn't finish in time.
supersededThe service changed after the gate passed, so the revision wasn't activated. undecidable is false here, because every check was judged.
dataset_goneThe Dataset of the check was deleted or is empty.
version_goneThe pipeline version of the held revision was deleted.
too_largeThe replay plan or a scoring run is over the size limit.

A result can be undecidable with no error_code when it was written before codes existed, so fall back to the error text when error_code is null. New codes can be added over time, so don't fail on a code your script doesn't know; treat it as an undecided run and show the error text.

See How Far a Goal Missed Its Bar​

When a check was judged and missed its goals, the goal results in the Gate Result show how far each goal was from its bar and how many sessions passed it. Each goal result carries these fields:

FieldMeaning
targetThe bar the goal is held to: the share of sessions that must pass for a pass-rate goal, otherwise the threshold.
lower_is_bettertrue when a lower value is better, false when a higher value is better. It is null when the Evaluator versions don't agree on a direction. A pass-rate goal is always false, because its value is a share.
passingHow many scored sessions pass the goal's rule.
valuedHow many sessions the goal's Metric was scored on.
marginHow far the goal's value, which is aggregate or pass_rate, is on the good side of target. It is positive when the goal is met and negative when it is missed. It is null when the value, target, or direction is unknown.

For example, a goal with a target of 0.80 and a pass_rate of 0.74 has a margin of -0.06. With passing at 41 and valued at 64, you can report that 41 of 64 sessions pass the goal.

Use margin instead of calculating the difference yourself, so the sign is correct for goals where a lower value is better. Gate Results stored before these fields existed return null for target, lower_is_better, passing, valued, and margin, so handle null in your script.

Fix a Refused Activation​

The platform refuses the activation when the gate can't vouch for the revision:

  • 409 with gate_run_in_flight: a gate run for this service is still running. Wait for it to finish, then try again.
  • 409 with gate_draft_version: the gate can't judge a draft pipeline version. Use a published version.
  • 409 with gate_revision_config_mismatch: the revision's configuration doesn't match the pipeline version the gate would replay. Create the revision again from the pipeline version you want to serve.
  • 422 with gate_requires_platform_revision: the revision doesn't run a pipeline built on the platform, so there's nothing to replay. Gated services accept only platform pipeline revisions.

A service with a gate also doesn't accept an optimization suggestion directly. The accept request returns 409 with gate_blocks_optimization_accept, because the suggestion would change the served configuration without going through the gate. Deploy the candidate's pipeline version through the service so the gate judges it.