Skip to main content
PUT
/
defend
/
{workflow_id}
Update a Workflow
from deeprails import DeepRails

DEEPRAILS_API_KEY = "YOUR_API_KEY"

client = DeepRails(
    api_key=DEEPRAILS_API_KEY,
)

workflow_response = client.defend.update_workflow(
    workflow_id="wkfl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    description="A workflow used to test the DeepRails SDK"
    threshold_type="automatic",
    automatic_hallucination_tolerance_levels={
        "completeness": "low",
        "instruction_adherence": "medium",
        "comprehensive_safety": "medium"
    }
)
print(workflow_response)
{
  "workflow_id": "wkfl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "active",
  "modified_at": "2025-01-15T10:30:00Z"
}
This endpoint can update the workflow’s name, description, threshold_type, automatic_hallucination_tolerance_levels, custom_hallucination_threshold_values, and improvement_action when needed. You can also add or remove extended AI capabilities like web_search and file_search. Only fields provided in the request body will be updated.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

workflow_id
string
required

The ID of the workflow to edit.

Body

application/json
name
string

New name for the workflow.

description
string

New description for the workflow.

threshold_type
enum<string>

New type of thresholds to use for the workflow, either automatic or custom. Automatic thresholds are assigned internally after the user specifies a qualitative tolerance for the metrics, whereas custom metrics allow the user to set the threshold for each metric as a floating point number between 0.0 and 1.0.

Available options:
automatic,
custom
automatic_hallucination_tolerance_levels
object

New mapping of guardrail metrics to hallucination tolerance levels (either low, medium, or high) to be used when threshold_type is set to automatic. Possible metrics are completeness, instruction_adherence, context_adherence, ground_truth_adherence, or comprehensive_safety.

custom_hallucination_threshold_values
object

New mapping of guardrail metrics to floating point threshold values to be used when threshold_type is set to custom. Possible metrics are correctness, completeness, instruction_adherence, context_adherence, ground_truth_adherence, or comprehensive_safety.

improvement_action
enum<string>

The new action used to improve outputs that fail one or more guardrail metrics for the workflow events. May be regen, fixit, or do_nothing. ReGen runs the user's input prompt with minor induced variance. FixIt attempts to directly address the shortcomings of the output using the guardrail failure rationale. Do Nothing does not attempt any improvement.

Available options:
regen,
fixit,
do_nothing
max_improvement_attempts
integer
default:10

Max. number of improvement action attempts until a given event passes the guardrails. Defaults to 10.

Whether to enable web search for this workflow's evaluations. Defaults to false.

An array of file IDs to search in the workflow's evaluations. Files must be uploaded via the DeepRails API first.

A file ID corresponding to a file to search in the workflow's evaluations.

Response

Workflow updated successfully

workflow_id
string
required

A unique workflow ID.

Example:

"wkfl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

status
enum<string>
required

Status of the selected workflow. May be inactive or active. Inactive workflows will not accept events.

Available options:
inactive,
active
Example:

"active"

modified_at
string<date-time>
required

The time the workflow was last modified in UTC.

Example:

"2025-01-15T10:30:00Z"