Files
directus/docs/reference/system/flows.md
Connor 92621429ee Linting and Formatting Upgrade (#18892)
* add docs to eslint

* update prettier ignore

* fix vitepress linting

* eslint ignore fixes

* prettier run

* update prettier ignore

* fix formatting

* enable linting of markdown files

* revert format command change

* fix irregular whitespace

* update dictionary

* (Changelog) Create four-boxes-shake.md

* Rework ESLint / Prettier setup

- Disable js/ts/vue files for Prettier to ensure linting/formatting is
  only happening via ESLint
- Rework formatting of code blocks in md files
  - Disable formatting of code blocks in md files under '/docs' by Prettier
  - Instead use "eslint-plugin-markdown" to format & __lint__ js*/ts*/vue such code blocks
  - Replace unmaintained "eslint-plugin-md" plugin by official "eslint-plugin-markdown" plugin
  - I'll check whether we can use this to format other code blocks
    (json, html, ...) as well
- Restructure, clean-up and apply some fixes to the ESLint config
  (Note: Not ready for flat config yet since not supported by
  vscode-eslint)
- Enable cache for ESLint / Prettier in scripts
- Clean-up ignore file
  - Explicit folder declaration (.../)
  - Don't ignore all 'extensions' folders in ESLint (only
    '/api/extensions/')
  - Enable formatting in '/.github' folder

* Fix all formatting issues with Prettier

* Update md files under /docs/.typedocs

* Fix lint issues in vue/js files

* ESLint / Prettier config revision v2

Enable Prettier for md code blocks, but only as warnings since it can
get into the way with Vitepress md extensions like '[!code ...]'
comments

* Remove prettier-ignore comments

* Make spellchecker happy

* Remove changeset

* Revert lint setup for code blocks

There are many cases in the docs where linting / formatting of code
blocks doesn't make
sense:
- Code block is only an excerpt - linter fails
- Code block contains special comments (e.g. markdown extensions) which
  needs to remain at the same place - formatting would break it
- ...

* Apply lint issues / formatting from temp lint setup

* Run formatter

* Fix merge failure

* Simplify & modernize ESLint / Prettier setup

No longer run Prettier via ESLint. Nowadays, this is the recommended
setup. There's no real need to run it this way, it's just an additional
layer.

Add VS Code settings to make the work with the new setup easier.

* Remove unused eslint disable directives

* Make editorconfig more useful

* Fix formatting issues reported by editorconfig

* Format files with Prettier

* Enable formatting of source translations file

* Format source translations file

* Remove unnecessary console error

* Remove unnecessary line

* Only ignore md files under .changeset

* Add CI reporter for Prettier

* Fail job on wrongly formatted files

* Fix format

* Test Prettier action on changed/added file

* Use simple CI format check for now & no cache

* Revert "Test Prettier action on changed/added file"

This reverts commit 4f7d8826ad.

* Introduce code blocks check for docs

* Fix code block issues

* Ignore auto-generated packages dir

* Fix comment position

* Also lint `/app/.storybook`

* Reformat modified files

---------

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
2023-06-29 11:54:01 +02:00

7.7 KiB

description, readTime, pageClass
description readTime pageClass
REST and GraphQL API documentation on the Flows collection in Directus. 5 min read page-reference

Flows

Flows enable custom, event-driven data processing and task automation within Directus.


The Flow Object

id uuid
Primary key of the flow.

name string
Name for the flow.

icon string
Icon displayed in the Admin App for the flow.

color string
Color of the icon displayed in the Admin App for the flow.

note text
Short description displayed in the Admin App.

status string
Current status of the flow. One of active, inactive. Defaults to active when not specified.

trigger string
Type of trigger for the flow. One of hook, webhook, operation, schedule, manual.

options json
Options of the selected trigger for the flow.

accountability string
The permission used during the flow. One of $public, $trigger, $full, or UUID of a role.

date_created timestamp
Timestamp in ISO8601 when the flow was created.

user_created many-to-one
The user who created the flow. Many-to-one to users.

operation string
UUID of the operation connected to the trigger in the flow.

{
	"id": "2fab3b9d-0543-4b87-8a30-3c5ee66fedf1",
	"name": "My Flow",
	"icon": "bolt",
	"color": "#112233",
	"note": "Note for my flow",
	"status": "active",
	"trigger": "manual",
	"accountability": "$trigger",
	"date_created": "2022-05-11T13:14:52Z",
	"user_created": "12e62fd0-29c7-4fd3-b3d3-c7a39933e8af",
	"operation": "92e82998-e421-412f-a513-13701e83e4ce"
}

List Flows

List all flows that exist in Directus.

Query Parameters

Supports all global query parameters.

Returns

An array of up to limit flow objects. If no items are available, data will be an empty array.

REST API

GET /flows
SEARCH /flows

Learn more about SEARCH ->

GraphQL

POST /graphql/system
type Query {
	flows: [directus_flows]
}
Example
query {
	flows {
		id
		name
		status
	}
}

Retrieve a flow

List an existing flow by primary key.

Query Parameters

Supports all global query parameters.

Returns

Returns the requested flow object.

REST API

GET /flows/:id
Example
GET /flows/2fc325fb-299b-4d20-a9e7-a34349dee8b2

GraphQL

POST /graphql/system
type Query {
	flows_by_id(id: ID!): directus_flows
}
Example
query {
	flows_by_id(id: "2fc325fb-299b-4d20-a9e7-a34349dee8b2") {
		id
		name
		status
	}
}

Create a Flow

Create a new flow.

Query Parameters

Supports all global query parameters.

Request Body

A partial flow object.

Returns

Returns the flow object for the created flow.

REST API

POST /flows
Example
// POST /flows

{
	"name": "My Flow",
	"status": "active",
	"trigger": "manual"
}

GraphQL

POST /graphql/system
type Mutation {
	create_flows_item(data: create_directus_flows_input!): directus_flows
}
Example
mutation {
	create_flows_item(data: { name: "My Flow", status: "active", trigger: "manual" }) {
		id
		name
		status
	}
}

Create Multiple Flows

Create multiple new flows.

Query Parameters

Supports all global query parameters.

Request Body

An array of partial flow objects.

Returns

Returns the flow object for the created flow.

REST API

POST /flows
Example
// POST /flows

[
	{
		"name": "My Flow",
		"status": "active",
		"trigger": "manual"
	},
	{
		"name": "Another Flow",
		"status": "active",
		"trigger": "webhook"
	}
]

GraphQL

POST /graphql/system
type Mutation {
	create_flows_items(data: [create_directus_flows_input!]!): [directus_flows]
}
Example
mutation {
	create_flows_items(
		data: [
			{ name: "My Flow", status: "active", trigger: "manual" }
			{ name: "Another Flow", status: "active", trigger: "webhook" }
		]
	) {
		id
		name
		status
	}
}

Update a Flow

Update an existing flow.

Query Parameters

Supports all global query parameters.

Request Body

A partial flow object.

Returns

Returns the flow object for the updated flow.

REST API

PATCH /flows/:id
Example
// PATCH /flows/2fc325fb-299b-4d20-a9e7-a34349dee8b2

{
	"name": "My Updated Flow"
}

GraphQL

POST /graphql/system
type Mutation {
	update_flows_item(id: ID!, data: update_directus_flows_input): directus_flows
}
Example
mutation {
	update_flows_item(id: "2fc325fb-299b-4d20-a9e7-a34349dee8b2", data: { name: "My Updated Flow" }) {
		id
		name
	}
}

Update Multiple Flows

Update multiple existing flows.

Query Parameters

Supports all global query parameters.

Request Body

keys Required
Array of primary keys of the flows you'd like to update.

data Required
Any of the flow object's properties.

Returns

Returns the flow objects for the updated flows.

REST API

PATCH /flows
Example
// PATCH /flows

{
	"keys": ["3f2facab-7f05-4ee8-a7a3-d8b9c634a1fc", "7259bfa8-3786-45c6-8c08-cc688e7ba229"],
	"data": {
		"status": "inactive"
	}
}

GraphQL

POST /graphql/system
type Mutation {
	update_flows_items(ids: [ID!]!, data: update_directus_flows_input): [directus_flows]
}
Example
mutation {
	update_flows_items(
		ids: ["3f2facab-7f05-4ee8-a7a3-d8b9c634a1fc", "7259bfa8-3786-45c6-8c08-cc688e7ba229"]
		data: { status: "inactive" }
	) {
		id
		name
		status
	}
}

Delete a Flow

Delete an existing flow.

Returns

Empty body.

REST API

DELETE /flows/:id
Example
DELETE /flows/12204ee2-2c82-4d9a-b044-2f4842a11dba

GraphQL

POST /graphql/system
type Mutation {
	delete_flows_item(id: ID!): delete_one
}
Example
mutation {
	delete_flows_item(id: "12204ee2-2c82-4d9a-b044-2f4842a11dba") {
		id
	}
}

Delete Multiple Flows

Delete multiple existing flows.

Request Body

An array of flows primary keys

Returns

Empty body.

REST API

DELETE /flows
Example
// DELETE /flows
["25821236-8c2a-4f89-8fdc-c7d01f35877d", "02b9486e-4273-4fd5-b94b-e18fd923d1ed", "7d62f1e9-a83f-407b-84f8-1c184f014501"]

GraphQL

POST /graphql/system
type Mutation {
	delete_flows_items(ids: [ID!]!): delete_many
}
Example
mutation {
	delete_flows_items(
		ids: [
			"25821236-8c2a-4f89-8fdc-c7d01f35877d"
			"02b9486e-4273-4fd5-b94b-e18fd923d1ed"
			"7d62f1e9-a83f-407b-84f8-1c184f014501"
		]
	) {
		ids
	}
}

Flow with GET webhook trigger

Start a flow with GET webhook trigger.

Returns

Result of the flow, if any.

REST API

GET /flows/trigger/:flow_uuid
Example
// GET /flows/trigger/202a940b-a00b-47df-b832-369c53f13122
// Payload here

Flow with POST webhook trigger

Start a flow with POST webhook trigger.

Request Body

Payload for the POST request.

Returns

Result of the flow, if any.

REST API

POST /flows/trigger/:flow_uuid
Example
// POST /flows/trigger/202a940b-a00b-47df-b832-369c53f13122
// Payload here