openapi: 3.1.0 info: title: Dexwize workflow service version: 1.0.0 description: > No-code remediation workflows (E31, ADR-0037). Definitions are drafts until published; each publish creates an immutable, hashed version and rollback republishes an older one as a new version. Runs are pinned to the version they started on and are interpreted deterministically on Temporal. Remediation steps go through remediation-service, so tenant autonomy and approval policy always apply; approval steps cannot be decided by the run starter or the workflow owner. servers: - url: https://api.dexwize.example security: - bearer: [] paths: /v1/workflows: get: summary: List workflows (FindingsRead) operationId: listWorkflows responses: '200': description: Workflows content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/Workflow' } } '403': { description: Missing FindingsRead } post: summary: Create a workflow from a draft definition (RemediationExecute; audited) operationId: createWorkflow requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/Definition' } responses: '201': description: Created content: application/json: schema: { $ref: '#/components/schemas/Workflow' } '400': { description: Invalid draft } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflows/actions: get: summary: Library action ids a remediation step may use (FindingsRead) operationId: listWorkflowActions responses: '200': description: Action ids from the signed content library content: application/json: schema: { type: array, items: { type: string } } /v1/workflows/validate: post: summary: Validate a definition without saving it (RemediationExecute) operationId: validateWorkflow requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/Definition' } responses: '200': description: Validation report content: application/json: schema: { $ref: '#/components/schemas/Validation' } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflows/triggers: post: summary: Start every enabled workflow whose trigger matches an event (WorkflowsTrigger) description: 'People with the analyst role and services holding workflow_trigger_sender (rules-engine when a finding opens, scoring-service when an alert opens). With an idempotency key a repeated event starts nothing. Schedule triggers are started by workflow-service itself, once per slot.' operationId: dispatchWorkflowTrigger requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/TriggerEvent' } responses: '200': description: Runs started content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/Run' } } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflows/{id}: parameters: [{ $ref: '#/components/parameters/Id' }] get: summary: Get a workflow with its draft and versions (FindingsRead) operationId: getWorkflow responses: '200': description: Workflow content: application/json: schema: { $ref: '#/components/schemas/Workflow' } '404': { description: Not found } /v1/workflows/{id}/draft: parameters: [{ $ref: '#/components/parameters/Id' }] put: summary: Replace the draft (RemediationExecute; audited) operationId: updateWorkflowDraft requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/Definition' } responses: '200': description: Updated content: application/json: schema: { $ref: '#/components/schemas/Workflow' } '404': { description: Not found } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflows/{id}/publish: parameters: [{ $ref: '#/components/parameters/Id' }] post: summary: Validate the draft and publish it as a new immutable version (RemediationExecute; audited) operationId: publishWorkflow requestBody: content: application/json: schema: type: object properties: note: { type: [string, 'null'], maxLength: 500 } responses: '200': description: Published content: application/json: schema: { $ref: '#/components/schemas/Workflow' } '400': { description: Validation errors } '404': { description: Not found } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflows/{id}/rollback: parameters: [{ $ref: '#/components/parameters/Id' }] post: summary: Republish an earlier version as a new version (RemediationExecute; audited) operationId: rollbackWorkflow requestBody: required: true content: application/json: schema: type: object required: [version] properties: version: { type: integer, minimum: 1 } responses: '200': description: Rolled back content: application/json: schema: { $ref: '#/components/schemas/Workflow' } '400': { description: 'Unknown version, or it no longer validates' } '404': { description: Not found } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflows/{id}/enable: parameters: [{ $ref: '#/components/parameters/Id' }] post: summary: Enable triggers and runs (RemediationExecute; audited) operationId: enableWorkflow responses: '200': description: Enabled content: application/json: schema: { $ref: '#/components/schemas/Workflow' } '404': { description: Not found } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflows/{id}/disable: parameters: [{ $ref: '#/components/parameters/Id' }] post: summary: Disable triggers and new runs (RemediationExecute; audited) operationId: disableWorkflow responses: '200': description: Disabled content: application/json: schema: { $ref: '#/components/schemas/Workflow' } '404': { description: Not found } /v1/workflows/{id}/runs: parameters: [{ $ref: '#/components/parameters/Id' }] get: summary: Run history for a workflow (FindingsRead) operationId: listWorkflowRuns responses: '200': description: Runs, newest first content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/Run' } } post: summary: Start a manual run on the current version (RemediationExecute; audited) operationId: startWorkflowRun requestBody: required: true content: application/json: schema: type: object properties: deviceIds: { type: array, maxItems: 1000, items: { type: string, format: uuid } } values: { type: object, additionalProperties: { type: string } } responses: '202': description: Run started content: application/json: schema: { $ref: '#/components/schemas/Run' } '400': { description: 'Not published, disabled, or too many devices' } '404': { description: Not found } '403': { description: 'Missing permission, or the tenant plan does not include workflows (ADR-0053): {"error":"feature_not_entitled","feature":"workflows"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; workflows is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } /v1/workflow-runs/{runId}: parameters: - { name: runId, in: path, required: true, schema: { type: string, format: uuid } } get: summary: Get a run with its step history (FindingsRead) operationId: getWorkflowRun responses: '200': description: Run content: application/json: schema: { $ref: '#/components/schemas/Run' } '404': { description: Not found } /v1/workflow-runs/{runId}/steps/{stepId}/decision: parameters: - { name: runId, in: path, required: true, schema: { type: string, format: uuid } } - { name: stepId, in: path, required: true, schema: { type: string } } post: summary: Approve or reject a waiting approval step (RecommendationsApprove; audited) description: The run starter and the workflow owner are refused; the caller must hold the step approver role. operationId: decideWorkflowStep requestBody: required: true content: application/json: schema: type: object required: [approved] properties: approved: { type: boolean } responses: '200': description: Decision recorded content: application/json: schema: { $ref: '#/components/schemas/Run' } '400': { description: 'Not waiting on this step, self-approval, or missing approver role' } '404': { description: Not found } '403': { description: 'Missing permission, or the tenant plan does not include approval_workflow (ADR-0053): {"error":"feature_not_entitled","feature":"approval_workflow"}', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } '503': { description: 'Entitlements could not be confirmed and nothing usable is cached; approval_workflow is refused (fail closed). Retry-After is set.', content: { application/json: { schema: { $ref: '#/components/schemas/FeatureRefusal' } } } } components: securitySchemes: bearer: { type: http, scheme: bearer, bearerFormat: JWT } parameters: Id: name: id in: path required: true schema: { type: string, format: uuid } schemas: FeatureRefusal: description: Module licensing refusal (ADR-0053); 403 feature_not_entitled or 503 entitlements_unavailable. type: object required: [error, feature] properties: error: { type: string, enum: [feature_not_entitled, entitlements_unavailable] } feature: { type: string, description: Feature code, for example remote_actions } Trigger: type: object required: [kind] properties: kind: { type: string, enum: [Manual, FindingType, Alert, Schedule] } value: { type: [string, 'null'], description: 'Finding type, alert rule, or daily@HH:mm / weekly:DDD@HH:mm' } Step: type: object required: [id, kind] properties: id: { type: string, pattern: '^[a-z][a-z0-9_]{0,40}$' } kind: { type: string, enum: [Condition, RemediationAction, Approval, Ticket, Notification, Wait, Loop] } next: { type: [string, 'null'] } else: { type: [string, 'null'] } field: { type: [string, 'null'], enum: [finding_type, severity, device_count, alert_rule, alert_severity, score, null] } op: { type: [string, 'null'], enum: [eq, ne, gte, lte, in, null] } value: { type: [string, 'null'] } actionId: { type: [string, 'null'], description: Must be an action in the remediation library } parameters: { type: [object, 'null'], additionalProperties: { type: string } } approverRole: { type: [string, 'null'], enum: [approver, tenant_admin, null] } timeoutHours: { type: [integer, 'null'] } summary: { type: [string, 'null'] } priority: { type: [integer, 'null'], minimum: 1, maximum: 4 } eventType: { type: [string, 'null'], enum: [workflow_notification, null] } waitMinutes: { type: [integer, 'null'], maximum: 43200 } maxIterations: { type: [integer, 'null'], maximum: 10 } body: { type: [string, 'null'], description: First step of a bounded loop body } Definition: type: object required: [name, trigger, start, steps] properties: name: { type: string, maxLength: 120 } trigger: { $ref: '#/components/schemas/Trigger' } start: { type: string } steps: { type: array, maxItems: 50, items: { $ref: '#/components/schemas/Step' } } Validation: type: object required: [valid, errors] properties: valid: { type: boolean } errors: { type: array, items: { type: string } } Version: type: object required: [number, sha256, publishedAt, publishedBy, note] properties: number: { type: integer } sha256: { type: string } publishedAt: { type: string, format: date-time } publishedBy: { type: string } note: { type: string } Workflow: type: object required: [id, owner, createdAt, enabled, versions] properties: id: { type: string, format: uuid } owner: { type: string } createdAt: { type: string, format: date-time } enabled: { type: boolean } currentVersion: { type: [integer, 'null'] } draft: { oneOf: [{ $ref: '#/components/schemas/Definition' }, { type: 'null' }] } current: { oneOf: [{ $ref: '#/components/schemas/Definition' }, { type: 'null' }] } versions: { type: array, items: { $ref: '#/components/schemas/Version' } } StepRecord: type: object required: [stepId, kind, outcome, detail, at] properties: stepId: { type: string } kind: { type: string } outcome: { type: string } detail: { type: string } at: { type: string, format: date-time } Run: type: object required: [id, workflowId, version, startedBy, status, steps, startedAt, deviceCount] properties: id: { type: string, format: uuid } workflowId: { type: string, format: uuid } version: { type: integer } startedBy: { type: string } status: { type: string, enum: [Running, WaitingApproval, Completed, Failed, Rejected] } waitingStep: { type: [string, 'null'] } steps: { type: array, items: { $ref: '#/components/schemas/StepRecord' } } startedAt: { type: string, format: date-time } endedAt: { type: [string, 'null'], format: date-time } deviceCount: { type: integer } TriggerEvent: type: object required: [kind, value] properties: kind: { type: string, enum: [FindingType, Alert, Schedule] } value: { type: string } deviceIds: { type: [array, 'null'], items: { type: string, format: uuid } } values: { type: [object, 'null'], additionalProperties: { type: string } } idempotencyKey: { type: [string, 'null'], minLength: 1, maxLength: 200, description: 'The event occurrence; a repeat of the key for the tenant starts nothing' }