Sign in to run requests with your own sandbox key. Sign in

Guides

Generate a cascade with AI

Turn a plain-English screening policy into a valid cascade with POST /workflows/generate, preview before saving, and handle the busy and failure cases.

POST /workflows/generate takes a description of your screening policy and returns a cascade definition built by Claude, validated against the same node grammar the visual builder enforces. Use it to draft a cascade from a sentence, then refine in the builder or with PATCH /workflows/{id}.

What do I send?

A prompt describing the policy in the language you would use with a colleague. Be explicit about products, thresholds, and what happens on each outcome:

cURL
curl -X POST "https://cascades.crscreditapi.com/api/v1/workflows/generate" \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Pull an Equifax credit report. Approve if FICO is at least 650; otherwise send an adverse-action notice for review.",
    "use_case": "tenant_screening"
  }'

Optional fields: name (otherwise the generator names it), use_case (defaults to tenant_screening), active (subject to the activation gate), and create: false to preview the definition without saving anything.

JSON
{
  "prompt": "Verify identity, pull a TransUnion credit report and a criminal search. Approve FICO 680 and above with no felonies. Send 620–679 to manual review. Decline below 620 or any felony, with an adverse-action notice.",
  "create": false
}

What comes back?

With create: false, 200 and a preview:

JSON
{
  "data": {
    "object": "cascade_generation",
    "definition": [ { "id": "start", "type": "ApplicantSource", "next_step": ["identity"] }, "…" ],
    "valid": true,
    "name": "Tenant screening — FICO 680 gate",
    "model": "claude-opus-4-8",
    "repaired": false,
    "warnings": []
  },
  "meta": { "request_id": "…" }
}

By default the cascade is saved and the response is 201 with the workflow plus a generation block carrying the same model, repaired and warnings fields. repaired: true means the first draft failed validation and a cheaper model fixed it in one repair turn; read warnings — they list anything the generator could not express exactly (a product your account cannot use, an ambiguous threshold).

On a sandbox account the cascade is saved as a draft and the response carries a note saying so. It still runs in test mode.

Which errors should I handle?

Code Meaning What to do
422 validation_failed Empty prompt, or longer than the cap Trim the prompt
422 generation_failed The model could not produce a valid definition; details lists the validation errors Rephrase — name products and thresholds explicitly
503 designer_busy The generator's concurrency cap is in use Retry after a few seconds with backoff
403 insufficient_scope Key lacks workflows:write Use a key with the scope

Generation is not idempotent: two identical prompts create two cascades. Use create: false when exploring.

Iterating

The returned definition is ordinary JSON. Edit nodes, thresholds or edges and send the whole array back with PATCH /workflows/{id}; the same validator runs on every save. To test it, trigger it in test mode with a registered subject and read step_outputs to see which branch fired.

Was this page helpful?