Docs/API sequence reference
#

API sequence reference

Build, run, inspect, and repair API sequences generated from prompts or workflow runs. Learn how run history, detailed request/response inspection, and AI Doctor help you debug and improve sequences.

The fields of an API sequence, the checks you can make on a response, and how a step reads values from earlier steps. For the steps that write, save and run one, see API tests.

Sequence

FieldMeaning
stepsThe requests, in the order they run. Required, at least one.
descriptionA short summary of what the sequence covers.
stopOnFailureWhen true (the default), the first failed step skips the steps after it. When false, every step runs.
exportsValues to keep for later nodes in the same test. See Exports.

Step

FieldMeaning
stepIdThe name other steps use to read this step's response. Letters, digits and underscores, starting with a letter or underscore. Unique in the sequence. Defaults to step1, step2 and so on.
apiRequestIdThe id of a catalog request, from cofactor api-catalog endpoints list. Use "" for a step that does not use the catalog. It then needs method and urlTemplate.
credentialIdThe credential that signs the call, or null for none.
credentialTemplateNameA persona name. The call is signed with that persona's credential on the environment the test runs on. Wins over credentialId.
methodGET, POST, PUT, PATCH, DELETE, HEAD or OPTIONS. Defaults to the catalog request's method.
urlTemplateThe address to call. Defaults to the catalog request's address. Start it with $var.ENV.api_url to call the environment the test runs on.
queryParamsA list of { "key": "...", "value": "..." } pairs added to the address.
bodyTemplateThe request body as a JSON string, so inner quotes are escaped.
formPartsA multipart form body instead of bodyTemplate. Each part is { "kind": "text", "name": "...", "value": "..." } or { "kind": "file", "name": "...", "attachmentId": "<id>" }. A file part can add filename. Do not set a Content-Type header on the step.
headersTemplateExtra request headers, as { "Header-Name": "value" }.
expectedStatusCodesThe status codes that pass, from 100 to 599. Without it, any 2xx passes.
validationsChecks on the response. See Assertions.
validationModeall (the default) requires every validation to pass. any requires at least one. The status code must pass either way.
descriptionA label for the step.

urlTemplate, queryParams values, bodyTemplate, headersTemplate values and text formParts values can use values from earlier steps, $var variables and macros.

Assertions

Each validation has a left value, an operator and, for most operators, a right value.

json
{ "left": "read.response.status", "operator": "equals", "right": "active" }

left is <stepId>.response.<path>, a path into that step's JSON response. right is compared as written. It is not expanded, so {{...}} and $var in right stay literal text.

OperatorPasses when
equalsThe value equals right.
not_equalsThe value differs from right.
gt, gte, lt, lteThe value is greater than, at least, less than or at most right. Both are read as numbers.
containsThe value includes right as text.
not_containsThe value does not include right.
is_setThe value exists. Needs no right.
is_not_setThe value does not exist. Needs no right.

Validations run only when the status code passes, and only on JSON responses. A validation on a missing value fails, except is_not_set, not_equals and not_contains, which pass.

Read values from earlier steps

Write {{<stepId>.response.<path>}} where a later step needs a value.

PartRule
PathDots for keys and [0] for list items, as in {{list.response.data.pages[0].slug}}.
.response.Required. {{create.id}} is rejected when you save.
OrderA step reads only steps before it. A step cannot read itself.
FormatThe earlier response must be JSON.

Other values:

ValueMeaning
$var.ENV.api_urlThe API address of the environment the test runs on. On a sandbox it is the address of the sandbox's api port, when the application declares one.
$var.ENV.app_urlThe web address of the environment.
$var.ENV.<port>_urlThe address of any other port a sandbox declares.
$var.<name>A value from the test's own variables, such as an export from a seed test.
$RANDOM_STRING(6), $EMAIL() and othersA fresh value on every run. See Macros and variables.

Exports

An export keeps a value from one step so later nodes in the same test can read it as $var.<variableName>.

json
{ "variableName": "project_id", "stepId": "create", "responsePath": "id" }
FieldMeaning
variableNameThe variable's name, such as project_id. Unique in the sequence.
stepIdThe step to read from.
responsePathThe path into the JSON body, such as data.id.
sourceresponse (the default) or request.

Keep tokens out of exports. Use a credential for them.

Limits

  • A call that gets no answer within 120 seconds fails.
  • Saving checks the sequence's shape and references. It does not call your API. Run the test once before you rely on it.
  • A run stores each request and response body up to a size cap. cofactor workflow runs get ... --api-call prints the stored copy.
  • $var.ENV.* needs an environment. cofactor workflow api-sequence execute fails before it sends a request when the test has no default environment.