# Workflows API

Source: https://frameleaf.app/docs/api/reference/workflows/

Use your own server and its scoped API keys.

## List all workflows

GET /api/workflows

Retrieve a list of workflows available to the authenticated user.

```json
{
  "description": "Retrieve a list of workflows available to the authenticated user.",
  "operationId": "searchWorkflows",
  "parameters": [
    {
      "name": "description",
      "required": false,
      "in": "query",
      "description": "Workflow description",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "enabled",
      "required": false,
      "in": "query",
      "description": "Workflow enabled",
      "schema": {
        "type": "boolean"
      }
    },
    {
      "name": "id",
      "required": false,
      "in": "query",
      "description": "Workflow ID",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    },
    {
      "name": "logging",
      "required": false,
      "in": "query",
      "description": "Workflow logs run results",
      "schema": {
        "type": "boolean"
      }
    },
    {
      "name": "name",
      "required": false,
      "in": "query",
      "description": "Workflow name",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "trigger",
      "required": false,
      "in": "query",
      "description": "Workflow trigger type",
      "schema": {
        "$ref": "#/components/schemas/WorkflowTrigger"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "items": {
              "$ref": "#/components/schemas/WorkflowResponseDto"
            },
            "type": "array"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "List all workflows",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": "workflow.read"
}
```

## Create a workflow

POST /api/workflows

Create a new workflow, the workflow can also be created with empty filters and actions.

```json
{
  "description": "Create a new workflow, the workflow can also be created with empty filters and actions.",
  "operationId": "createWorkflow",
  "parameters": [],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/WorkflowCreateDto"
        }
      }
    },
    "required": true
  },
  "responses": {
    "201": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/WorkflowResponseDto"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Create a workflow",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": "workflow.create"
}
```

## List all workflow triggers

GET /api/workflows/triggers

Retrieve a list of all available workflow triggers.

```json
{
  "description": "Retrieve a list of all available workflow triggers.",
  "operationId": "getWorkflowTriggers",
  "parameters": [],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "items": {
              "$ref": "#/components/schemas/WorkflowTriggerResponseDto"
            },
            "type": "array"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "List all workflow triggers",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": false
}
```

## Delete a workflow

DELETE /api/workflows/{id}

Delete a workflow by its ID.

```json
{
  "description": "Delete a workflow by its ID.",
  "operationId": "deleteWorkflow",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    }
  ],
  "responses": {
    "204": {
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Delete a workflow",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": "workflow.delete"
}
```

## Retrieve a workflow

GET /api/workflows/{id}

Retrieve information about a specific workflow by its ID.

```json
{
  "description": "Retrieve information about a specific workflow by its ID.",
  "operationId": "getWorkflow",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/WorkflowResponseDto"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Retrieve a workflow",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": "workflow.read"
}
```

## Update a workflow

PUT /api/workflows/{id}

Update the information of a specific workflow by its ID. This endpoint can be used to update the workflow name, description, trigger type, filters and actions order, etc.

```json
{
  "deprecated": true,
  "description": "Update the information of a specific workflow by its ID. This endpoint can be used to update the workflow name, description, trigger type, filters and actions order, etc.",
  "operationId": "updateWorkflow",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/WorkflowUpdateDto"
        }
      }
    },
    "required": true
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/WorkflowResponseDto"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Update a workflow",
  "tags": [
    "Workflows",
    "Deprecated"
  ],
  "x-frameleaf-permission": "workflow.update"
}
```

## Retrieve workflow logs

GET /api/workflows/{id}/logs

Retrieve logs of a workflows runs by ID

```json
{
  "description": "Retrieve logs of a workflows runs by ID",
  "operationId": "getWorkflowLogs",
  "parameters": [
    {
      "name": "before",
      "required": false,
      "in": "query",
      "description": "Filter by runs before a date/time",
      "schema": {
        "format": "date-time",
        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
        "example": "2024-01-01T00:00:00.000Z",
        "type": "string"
      }
    },
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    },
    {
      "name": "limit",
      "required": false,
      "in": "query",
      "description": "Maximum number of logs",
      "schema": {
        "maximum": 200,
        "exclusiveMinimum": true,
        "default": 50,
        "type": "integer",
        "minimum": 0
      }
    },
    {
      "name": "result",
      "required": false,
      "in": "query",
      "description": "Filter by run result",
      "schema": {
        "$ref": "#/components/schemas/WorkflowResult"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "items": {
              "$ref": "#/components/schemas/WorkflowLogEntryDto"
            },
            "type": "array"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Retrieve workflow logs",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": "workflow.logs"
}
```

## Retry a workflow run

POST /api/workflows/{id}/runs/{runId}/retry

Run a logged workflow run again, as its next attempt, for the photo or video that started it. The workflow must be enabled and able to run.

```json
{
  "description": "Run a logged workflow run again, as its next attempt, for the photo or video that started it. The workflow must be enabled and able to run.",
  "operationId": "retryWorkflowRun",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "description": "Workflow ID",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
        "type": "string"
      }
    },
    {
      "name": "runId",
      "required": true,
      "in": "path",
      "description": "Run ID",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
        "type": "string"
      }
    }
  ],
  "responses": {
    "204": {
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Retry a workflow run",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": "workflow.update"
}
```

## Retrieve a workflow

GET /api/workflows/{id}/share

Retrieve a workflow details without ids, default values, etc.

```json
{
  "description": "Retrieve a workflow details without ids, default values, etc.",
  "operationId": "getWorkflowForShare",
  "parameters": [
    {
      "name": "id",
      "required": true,
      "in": "path",
      "schema": {
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$",
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/WorkflowShareResponseDto"
          }
        }
      },
      "description": ""
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "summary": "Retrieve a workflow",
  "tags": [
    "Workflows"
  ],
  "x-frameleaf-permission": "workflow.read"
}
```
