Workflow Rules

The /workflows/rules endpoint allows you to manage your Workflow Rules. A Workflow Rule defines an automated action that is triggered when a specific event occurs. For example, you can create a Workflow Rule that automatically transcribes an audio file when it is uploaded to the platform.

Workflow Rules DSL

Workflow Rules are defined using a DSL (Domain Specific Language) that is based on JSON. The DSL allows you to define the following:

  • The name of the rule.
  • The Endpoint: of the workflow to be executed.
  • The input type of the rule, which can be single, multiple, or none.
  • The match criteria, which is a JSON object that defines the events that will trigger the rule.
  • The config for the workflow, which is a JSON object that contains the parameters to be passed to the workflow.

Example Workflow Rule

{
  "name": "Transcribe Audio",
  "endpoint": "transcribe_audio",
  "input_type": "single",
  "match": {
    "event": "create",
    "type": "Audio"
  },
  "config": {
    "language": "en-US"
  }
}

This rule will be triggered when a new audio file is created. The transcribe_audio workflow will be executed with the language parameter set to en-US.

Create a Workflow Rule

Endpoint: /workflows/rules

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>
Content-Typeapplication/json

Input Parameters

ParameterData TypeDescription
namestringThe name of the workflow rule.
endpointstringThe endpoint of the workflow to be executed.
input_typeWorkflowRuleInputTypeThe input type of the rule.
matchRecord<string, any>The match criteria for the rule.
configRecord<string, any>The configuration for the workflow.

Example Request

{
  "name": "Transcribe Audio",
  "endpoint": "transcribe_audio",
  "input_type": "single",
  "match": {
    "event": "create",
    "type": "Audio"
  },
  "config": {
    "language": "en-US"
  }
}

Example Response

{
  "id": "<RULE_ID>",
  "name": "Transcribe Audio",
  "endpoint": "transcribe_audio",
  "input_type": "single",
  "match": {
    "event": "create",
    "type": "Audio"
  },
  "config": {
    "language": "en-US"
  },
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-10-26T15:12:42.202Z",
  "updated_at": "2023-10-26T15:12:42.202Z"
}

Code Examples

Create Workflow Rule

curl --location 'https://studio-server-production.api.becomposable.com/api/v1/workflows/rules' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Transcribe Audio",
    "endpoint": "transcribe_audio",
    "input_type": "single",
    "match": {
        "event": "create",
        "type": "Audio"
    },
    "config": {
        "language": "en-US"
    }
}'

Retrieve a Workflow Rule

Endpoint: /workflows/rules/<RULE_ID>

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<RULE_ID>The ID of the workflow rule to retrieve.

Example Request

There is no JSON body with this request.

Example Response

{
  "id": "<RULE_ID>",
  "name": "Transcribe Audio",
  "endpoint": "transcribe_audio",
  "input_type": "single",
  "match": {
    "event": "create",
    "type": "Audio"
  },
  "config": {
    "language": "en-US"
  },
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-10-26T15:12:42.202Z",
  "updated_at": "2023-10-26T15:12:42.202Z"
}

Code Examples

Retrieve Workflow Rule

curl --location 'https://studio-server-production.api.becomposable.com/api/v1/workflows/rules/<RULE_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Update a Workflow Rule

Endpoint: /workflows/rules/<RULE_ID>

Method: PUT

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>
Content-Typeapplication/json

Path Parameters

ParameterDescription
<RULE_ID>The ID of the workflow rule to update.

Input Parameters

ParameterData TypeDescription
namestringThe name of the workflow rule.
endpointstringThe endpoint of the workflow to be executed.
input_typeWorkflowRuleInputTypeThe input type of the rule.
matchRecord<string, any>The match criteria for the rule.
configRecord<string, any>The configuration for the workflow.

Example Request

{
  "name": "Transcribe Audio",
  "endpoint": "transcribe_audio",
  "input_type": "single",
  "match": {
    "event": "create",
    "type": "Audio"
  },
  "config": {
    "language": "fr-FR"
  }
}

Example Response

{
  "id": "<RULE_ID>",
  "name": "Transcribe Audio",
  "endpoint": "transcribe_audio",
  "input_type": "single",
  "match": {
    "event": "create",
    "type": "Audio"
  },
  "config": {
    "language": "fr-FR"
  },
  "created_by": "user:<USER_ID>",
  "updated_by": "user:<USER_ID>",
  "created_at": "2023-10-26T15:12:42.202Z",
  "updated_at": "2023-10-26T15:17:12.934Z"
}

Code Examples

Update Workflow Rule

curl --location 'https://studio-server-production.api.becomposable.com/api/v1/workflows/rules/<RULE_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Transcribe Audio",
    "endpoint": "transcribe_audio",
    "input_type": "single",
    "match": {
        "event": "create",
        "type": "Audio"
    },
    "config": {
        "language": "fr-FR"
    }
}'

Delete a Workflow Rule

Endpoint: /workflows/rules/<RULE_ID>

Method: DELETE

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Path Parameters

ParameterDescription
<RULE_ID>The ID of the workflow rule to delete.

Example Response

{
    "id": "<RULE_ID>"
}

Code Examples

Delete Workflow Rule

curl --location 'https://studio-server-production.api.becomposable.com/api/v1/workflows/rules/<RULE_ID>' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
--request DELETE

List Workflow Rules

Endpoint: /workflows/rules

Method: GET

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>

Example Request

There is no JSON body with this request.

Example Response

[
  {
    "id": "<RULE_ID_1>",
    "name": "Transcribe Audio",
    "endpoint": "transcribe_audio",
    "input_type": "single",
    "match": {
      "event": "create",
      "type": "Audio"
    },
    "config": {
      "language": "en-US"
    },
    "created_by": "user:<USER_ID>",
    "updated_by": "user:<USER_ID>",
    "created_at": "2023-10-26T15:12:42.202Z",
    "updated_at": "2023-10-26T15:12:42.202Z"
  },
  {
    "id": "<RULE_ID_2>",
    "name": "Generate Embeddings",
    "endpoint": "generate_embeddings",
    "input_type": "multiple",
    "match": {
      "event": "create",
      "type": "Document"
    },
    "config": {
      "embeddingType": "text"
    },
    "created_by": "user:<USER_ID>",
    "updated_by": "user:<USER_ID>",
    "created_at": "2023-10-26T15:13:23.971Z",
    "updated_at": "2023-10-26T15:13:23.971Z"
  }
]

Code Examples

List Workflow Rules

curl --location 'https://studio-server-production.api.becomposable.com/api/v1/workflows/rules' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>'

Execute a Workflow Rule

Endpoint: /workflows/rules/<RULE_ID>/execute

Method: POST

Headers

HeaderValue
AuthorizationBearer <YOUR_JWT_TOKEN>
Content-Typeapplication/json

Path Parameters

ParameterDescription
<RULE_ID>The ID of the workflow rule to execute.

Input Parameters

ParameterData TypeDescription
objectIdsstring[]An optional array of object IDs to be passed to the workflow.
varsRecord<string, any>An optional object containing variables to be passed to the workflow.

Example Request

{
  "objectIds": ["<OBJECT_ID_1>", "<OBJECT_ID_2>"]
}

Example Response

{
  "runIds": ["<WORKFLOW_RUN_ID_1>", "<WORKFLOW_RUN_ID_2>"]
}

Code Examples

Execute Workflow Rule

curl --location 'https://studio-server-production.api.becomposable.com/api/v1/workflows/rules/<RULE_ID>/execute' \
--header 'Authorization: Bearer <YOUR_JWT_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "objectIds": ["<OBJECT_ID_1>", "<OBJECT_ID_2>"]
}'

Was this page helpful?