Setting Up Mesh Workflows
Manage your Mesh Workflows.

Create

To create a new custom workflow, specify a list of model IDs that are to be included in the workflow. Each model ID also requires a specific model version ID, since a model can have several versions.
Java
NodeJS
Python
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiWorkflowResponse postWorkflowsResponse = stub.postWorkflows(
8
PostWorkflowsRequest.newBuilder().addWorkflows(
9
Workflow.newBuilder()
10
.setId("my-custom-workflow")
11
.addNodes(
12
WorkflowNode.newBuilder()
13
.setId("food-concepts")
14
.setModel(
15
Model.newBuilder()
16
.setId("bd367be194cf45149e75f01d59f77ba7")
17
.setModelVersion(ModelVersion.newBuilder().setId("dfebc169854e429086aceb8368662641"))
18
)
19
)
20
.addNodes(
21
WorkflowNode.newBuilder()
22
.setId("general-concepts")
23
.setModel(
24
Model.newBuilder()
25
.setId("aaa03c23b3724a16a56b629203edc62c")
26
.setModelVersion(ModelVersion.newBuilder().setId("aa9ca48295b37401f8af92ad1af0d91d"))
27
)
28
)
29
).build()
30
);
31
32
if (postWorkflowsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
33
throw new RuntimeException("Post workflows failed, status: " + postWorkflowsResponse.getStatus());
34
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PostWorkflows(
5
{
6
workflows: [
7
{
8
id: "my-custom-workflow",
9
nodes: [
10
{
11
id: "food-concepts",
12
model: {
13
id: "bd367be194cf45149e75f01d59f77ba7",
14
model_version: {
15
id: "dfebc169854e429086aceb8368662641"
16
}
17
}
18
},
19
{
20
id: "general-concepts",
21
model: {
22
id: "aaa03c23b3724a16a56b629203edc62c",
23
model_version: {
24
id: "aa9ca48295b37401f8af92ad1af0d91d"
25
}
26
}
27
},
28
]
29
}
30
]
31
},
32
metadata,
33
(err, response) => {
34
if (err) {
35
throw new Error(err);
36
}
37
38
if (response.status.code !== 10000) {
39
throw new Error("Post workflows failed, status: " + response.status.description);
40
}
41
}
42
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
post_workflows_response = stub.PostWorkflows(
5
service_pb2.PostWorkflowsRequest(
6
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
7
workflows=[
8
resources_pb2.Workflow(
9
id="my-custom-workflow",
10
nodes=[
11
resources_pb2.WorkflowNode(
12
id="food-concepts",
13
model=resources_pb2.Model(
14
id="bd367be194cf45149e75f01d59f77ba7",
15
model_version=resources_pb2.ModelVersion(
16
id="dfebc169854e429086aceb8368662641"
17
)
18
)
19
),
20
resources_pb2.WorkflowNode(
21
id="general-concepts",
22
model=resources_pb2.Model(
23
id="aaa03c23b3724a16a56b629203edc62c",
24
model_version=resources_pb2.ModelVersion(
25
id="aa9ca48295b37401f8af92ad1af0d91d"
26
)
27
)
28
),
29
]
30
)
31
]
32
),
33
metadata=metadata
34
)
35
36
if post_workflows_response.status.code != status_code_pb2.SUCCESS:
37
raise Exception("Post workflows failed, status: " + post_workflows_response.status.description)
Copied!
1
# The first model is the Clarifai's Food model, and the second the Clarifai's General model.
2
3
curl -X POST 'https://api.clarifai.com/v2/workflows' \
4
-H 'Content-Type: application/json' \
5
-H 'Authorization: Key YOUR_API_KEY' \
6
--data-raw '{
7
"workflows": [{
8
"id": "my-custom-workflow",
9
"nodes": [
10
{
11
"id": "food-concepts",
12
"model": {
13
"id": "bd367be194cf45149e75f01d59f77ba7",
14
"model_version": {
15
"id": "dfebc169854e429086aceb8368662641"
16
}
17
}
18
},
19
{
20
"id": "general-concepts",
21
"model": {
22
"id": "aaa03c23b3724a16a56b629203edc62c",
23
"model_version": {
24
"id": "aa9ca48295b37401f8af92ad1af0d91d"
25
}
26
}
27
}
28
]
29
}]
30
}'
Copied!
1
// The first model is the Clarifai's Food model, and the second the Clarifai's General model.
2
3
const raw = JSON.stringify({
4
"user_app_id": {
5
"user_id": "{YOUR_USER_ID}",
6
"app_id": "{YOUR_APP_ID}"
7
},
8
"workflows": [{
9
"id": "my-custom-workflow",
10
"nodes": [
11
{
12
"id": "food-concepts",
13
"model": {
14
"id": "bd367be194cf45149e75f01d59f77ba7",
15
"model_version": {
16
"id": "dfebc169854e429086aceb8368662641"
17
}
18
}
19
},
20
{
21
"id": "general-concepts",
22
"model": {
23
"id": "aaa03c23b3724a16a56b629203edc62c",
24
"model_version": {
25
"id": "aa9ca48295b37401f8af92ad1af0d91d"
26
}
27
}
28
}
29
]
30
}]
31
});
32
33
const requestOptions = {
34
method: 'POST',
35
headers: {
36
'Accept': 'application/json',
37
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
38
},
39
body: raw
40
};
41
42
fetch(`https://api.clarifai.com/v2/workflows`, requestOptions)
43
.then(response => response.text())
44
.then(result => console.log(result))
45
.catch(error => console.log('error', error));
Copied!

Workflow Predict

Predict using a workflow. The response will contain the predictions each model in the workflow returns for the input.
Java
NodeJS
Python
C#
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
PostWorkflowResultsResponse postWorkflowResultsResponse = stub.postWorkflowResults(
8
PostWorkflowResultsRequest.newBuilder()
9
.setWorkflowId("{YOUR_WORKFLOW_ID}")
10
.addInputs(
11
Input.newBuilder().setData(
12
Data.newBuilder().setImage(
13
Image.newBuilder().setUrl(
14
"https://samples.clarifai.com/metro-north.jpg"
15
)
16
)
17
)
18
)
19
.build()
20
);
21
22
if (postWorkflowResultsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
23
throw new RuntimeException("Post workflow results failed, status: " + postWorkflowResultsResponse.getStatus());
24
}
25
26
// We'll get one WorkflowResult for each input we used above. Because of one input, we have here
27
// one WorkflowResult.
28
WorkflowResult results = postWorkflowResultsResponse.getResults(0);
29
30
// Each model we have in the workflow will produce one output.
31
for (Output output : results.getOutputsList()) {
32
Model model = output.getModel();
33
34
System.out.println("Predicted concepts for the model `" + model.getName() + "`:");
35
for (Concept concept : output.getData().getConceptsList()) {
36
System.out.printf("\t%s %.2f%n", concept.getName(), concept.getValue());
37
}
38
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PostWorkflowResults(
5
{
6
workflow_id: "{YOUR_WORKFLOW_ID}",
7
inputs: [
8
{data: {image: {url: "https://samples.clarifai.com/metro-north.jpg"}}}
9
]
10
},
11
metadata,
12
(err, response) => {
13
if (err) {
14
throw new Error(err);
15
}
16
17
if (response.status.code !== 10000) {
18
throw new Error("Post workflow results failed, status: " + response.status.description);
19
}
20
21
// We'll get one WorkflowResult for each input we used above. Because of one input, we have here
22
// one WorkflowResult.
23
const results = response.results[0];
24
25
// Each model we have in the workflow will produce one output.
26
for (const output of results.outputs) {
27
const model = output.model;
28
29
console.log("Predicted concepts for the model `" + model.name + "`:");
30
for (const concept of output.data.concepts) {
31
console.log("\t" + concept.name + " " + concept.value);
32
}
33
}
34
}
35
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
post_workflow_results_response = stub.PostWorkflowResults(
5
service_pb2.PostWorkflowResultsRequest(
6
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
7
workflow_id="{YOUR_WORKFLOW_ID}",
8
inputs=[
9
resources_pb2.Input(
10
data=resources_pb2.Data(
11
image=resources_pb2.Image(
12
url="https://samples.clarifai.com/metro-north.jpg"
13
)
14
)
15
)
16
]
17
),
18
metadata=metadata
19
)
20
if post_workflow_results_response.status.code != status_code_pb2.SUCCESS:
21
raise Exception("Post workflow results failed, status: " + post_workflow_results_response.status.description)
22
23
# We'll get one WorkflowResult for each input we used above. Because of one input, we have here
24
# one WorkflowResult.
25
results = post_workflow_results_response.results[0]
26
27
# Each model we have in the workflow will produce one output.
28
for output in results.outputs:
29
model = output.model
30
31
print("Predicted concepts for the model `%s`" % model.name)
32
for concept in output.data.concepts:
33
print("\t%s %.2f" % (concept.name, concept.value))
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
var response = client.PostModelOutputs(
5
new PostModelOutputsRequest()
6
{
7
UserAppId = new UserAppIDSet()
8
{
9
UserId = "excaliburne",
10
AppId = "moderation-test"
11
},
12
ModelId = "aaa03c23b3724a16a56b629203edc62c", // <- This is the general model_id
13
Inputs =
14
{
15
new List<Input>()
16
{
17
new Input()
18
{
19
Data = new Data()
20
{
21
Image = new Image()
22
{
23
Url = "https://samples.clarifai.com/dog2.jpeg"
24
}
25
}
26
}
27
}
28
}
29
},
30
metadata
31
);
32
33
if (response.Status.Code != StatusCode.Success)
34
throw new Exception("Request failed, response: " + response);
35
36
Console.WriteLine("Predicted concepts:");
37
foreach (var concept in response.Outputs[0].Data.Concepts)
38
{
39
Console.WriteLine(quot;{concept.Name, 15} {concept.Value:0.00}");
40
}
Copied!
1
curl -X POST \
2
-H 'authorization: Key YOUR_API_KEY' \
3
-H 'content-type: application/json' \
4
-d '{
5
"inputs": [
6
{
7
"data": {
8
"image": {
9
"url": "https://samples.clarifai.com/metro-north.jpg"
10
}
11
}
12
}
13
]
14
}'\
15
https://api.clarifai.com/v2/workflows/{YOUR_WORKFLOW_ID}/results
Copied!
1
const workflowID = '{YOUR_WORKFLOW_ID}'
2
3
const raw = JSON.stringify({
4
"user_app_id": {
5
"user_id": "{YOUR_USER_ID}",
6
"app_id": "{YOUR_APP_ID}"
7
},
8
"inputs": [
9
{
10
"data": {
11
"image": {
12
"url": "https://samples.clarifai.com/metro-north.jpg"
13
}
14
}
15
}
16
]
17
});
18
19
const requestOptions = {
20
method: 'POST',
21
headers: {
22
'Accept': 'application/json',
23
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
24
},
25
body: raw
26
};
27
28
fetch(`https://api.clarifai.com/v2/workflows/${workflowID}/results`, requestOptions)
29
.then(response => response.text())
30
.then(result => console.log(result))
31
.catch(error => console.log('error', error));
Copied!

Get

Get all workflows in an app

Return all custom workflows in your app.
Java
NodeJS
Python
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiWorkflowResponse listWorkflowsResponse = stub.listWorkflows(ListWorkflowsRequest.newBuilder().build());
8
9
if (listWorkflowsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
10
throw new RuntimeException("List workflows failed, status: " + listWorkflowsResponse.getStatus());
11
}
12
13
for (Workflow workflow : listWorkflowsResponse.getWorkflowsList()) {
14
System.out.println("The workflow " + workflow.getId() + " consists of these models:");
15
for (WorkflowNode workflowNode : workflow.getNodesList()) {
16
Model model = workflowNode.getModel();
17
System.out.println(model.getId());
18
}
19
System.out.println();
20
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.ListWorkflows(
5
{},
6
metadata,
7
(err, response) => {
8
if (err) {
9
throw new Error(err);
10
}
11
12
if (response.status.code !== 10000) {
13
throw new Error("List workflows failed, status: " + response.status.description);
14
}
15
16
for (const workflow of response.workflows) {
17
console.log("The workflow " + workflow.id + " consists of these models:");
18
for (const workflowNode of workflow.nodes) {
19
const model = workflowNode.model;
20
console.log(model.id);
21
}
22
console.log();
23
}
24
}
25
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
list_workflows_response = stub.ListWorkflows(
5
service_pb2.ListWorkflowsRequest(
6
user_app_id=userDataObject # The userDataObject is created in the overview and is required when using a PAT
7
),
8
metadata=metadata
9
)
10
11
if list_workflows_response.status.code != status_code_pb2.SUCCESS:
12
raise Exception("List workflows failed, status: " + list_workflows_response.status.description)
13
14
for workflow in list_workflows_response.workflows:
15
print(f"The workflow {workflow.id} consists of these models:")
16
for workflow_node in workflow.nodes:
17
model = workflow_node.model
18
print(model.id)
19
print()
Copied!
1
curl -X GET 'https://api.clarifai.com/v2/workflows' \
2
-H 'Content-Type: application/json' \
3
-H 'Authorization: Key YOUR_API_KEY'
Copied!
1
const appId = '{YOUR_APP_ID}'
2
3
const requestOptions = {
4
method: 'GET',
5
headers: {
6
'Accept': 'application/json',
7
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
8
}
9
};
10
11
fetch(`https://api.clarifai.com/v2/users/me/apps/${appId}/workflows`, requestOptions)
12
.then(response => response.text())
13
.then(result => console.log(result))
14
.catch(error => console.log('error', error));
Copied!

Get a workflow by a specific ID

Returns information about a specific workflow.
Java
NodeJS
Python
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
SingleWorkflowResponse getWorkflowResponse = stub.getWorkflow(
8
GetWorkflowRequest.newBuilder()
9
.setWorkflowId("food-and-general")
10
.build()
11
);
12
13
if (getWorkflowResponse.getStatus().getCode() != StatusCode.SUCCESS) {
14
throw new RuntimeException("Get workflow failed, status: " + getWorkflowResponse.getStatus());
15
}
16
17
Workflow workflow = getWorkflowResponse.getWorkflow();
18
19
System.out.println("The workflow consists of these models:");
20
for (WorkflowNode workflowNode : workflow.getNodesList()) {
21
Model model = workflowNode.getModel();
22
System.out.println(model.getId());
23
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.GetWorkflow(
5
{
6
workflow_id: "my-custom-workflow"
7
},
8
metadata,
9
(err, response) => {
10
if (err) {
11
throw new Error(err);
12
}
13
14
if (response.status.code !== 10000) {
15
throw new Error("Get workflow failed, status: " + response.status.description);
16
}
17
18
const workflow = response.workflow;
19
20
console.log("The workflow consists of these models:");
21
for (const workflowNode of workflow.nodes) {
22
const model = workflowNode.model;
23
console.log(model.id);
24
}
25
}
26
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
get_workflow_response = stub.GetWorkflow(
5
service_pb2.GetWorkflowRequest(
6
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
7
workflow_id="my-custom-workflow"
8
),
9
metadata=metadata
10
)
11
12
if get_workflow_response.status.code != status_code_pb2.SUCCESS:
13
raise Exception("Get workflow failed, status: " + get_workflow_response.status.description)
14
15
workflow = get_workflow_response.workflow
16
print(f"The workflow consists of these models:")
17
for workflow_node in workflow.nodes:
18
model = workflow_node.model
19
print(model.id)
Copied!
1
curl -X GET 'https://api.clarifai.com/v2/workflows/my-custom-workflow' \
2
-H 'Content-Type: application/json' \
3
-H 'Authorization: Key YOUR_API_KEY'
Copied!
1
const appId = '{YOUR_APP_ID}'
2
const workflowId = '{YOUR_WORKFLOW_ID}'
3
4
const requestOptions = {
5
method: 'GET',
6
headers: {
7
'Accept': 'application/json',
8
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
9
}
10
};
11
12
fetch(`https://api.clarifai.com/v2/users/me/apps/${appId}/workflows/${workflowId}`, requestOptions)
13
.then(response => response.text())
14
.then(result => console.log(result))
15
.catch(error => console.log('error', error));
Copied!

Update

Patch workflow

Ability to change the workflow, that is to change the models of which the workflow consists.
Possible actions are "overwrite", "merge" and "remove".
Java
NodeJS
Python
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiWorkflowResponse patchWorkflowsResponse = stub.patchWorkflows(
8
PatchWorkflowsRequest.newBuilder()
9
.setAction("overwrite")
10
.addWorkflows(
11
Workflow.newBuilder()
12
.setId("my-custom-workflow")
13
.addNodes(
14
WorkflowNode.newBuilder()
15
.setId("travel-concepts")
16
.setModel(
17
Model.newBuilder()
18
.setId("ccc28c313d69466f836ab83287a54ed9")
19
.setModelVersion(ModelVersion.newBuilder().setId("cce28c313d69466f836ab83287a54ed9"))
20
)
21
)
22
.addNodes(
23
WorkflowNode.newBuilder()
24
.setId("nsfw-concepts")
25
.setModel(
26
Model.newBuilder()
27
.setId("ccc76d86d2004ed1a38ba0cf39ecb4b1")
28
.setModelVersion(ModelVersion.newBuilder().setId("cc76a92beaeb4d8495a58ba197998158"))
29
)
30
)
31
.addNodes(
32
WorkflowNode.newBuilder()
33
.setId("wedding-concepts")
34
.setModel(
35
Model.newBuilder()
36
.setId("c386b7a870114f4a87477c0824499348")
37
.setModelVersion(ModelVersion.newBuilder().setId("787cc9a002164250800598d36b072384"))
38
)
39
)
40
).build()
41
);
42
43
if (patchWorkflowsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
44
throw new RuntimeException("Patch workflows failed, status: " + patchWorkflowsResponse.getStatus());
45
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PatchWorkflows(
5
{
6
action: "overwrite",
7
workflows: [
8
{
9
id: "my-custom-workflow",
10
nodes: [
11
{
12
id: "travel-concepts",
13
model: {
14
id: "ccc28c313d69466f836ab83287a54ed9",
15
model_version: {
16
id: "cce28c313d69466f836ab83287a54ed9"
17
}
18
}
19
},
20
{
21
id: "nsfw-concepts",
22
model: {
23
id: "ccc76d86d2004ed1a38ba0cf39ecb4b1",
24
model_version: {
25
id: "cc76a92beaeb4d8495a58ba197998158"
26
}
27
}
28
},
29
{
30
id: "wedding-concepts",
31
model: {
32
id: "c386b7a870114f4a87477c0824499348",
33
model_version: {
34
id: "787cc9a002164250800598d36b072384"
35
}
36
}
37
},
38
]
39
}
40
]
41
},
42
metadata,
43
(err, response) => {
44
if (err) {
45
throw new Error(err);
46
}
47
48
if (response.status.code !== 10000) {
49
throw new Error("Patch workflows failed, status: " + response.status.description);
50
}
51
}
52
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
patch_workflows_response = stub.PatchWorkflows(
5
service_pb2.PatchWorkflowsRequest(
6
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
7
action="overwrite",
8
workflows=[
9
resources_pb2.Workflow(
10
id="my-custom-workflow",
11
nodes=[
12
resources_pb2.WorkflowNode(
13
id="travel-concepts",
14
model=resources_pb2.Model(
15
id="ccc28c313d69466f836ab83287a54ed9",
16
model_version=resources_pb2.ModelVersion(
17
id="cce28c313d69466f836ab83287a54ed9"
18
)
19
)
20
),
21
resources_pb2.WorkflowNode(
22
id="nsfw-concepts",
23
model=resources_pb2.Model(
24
id="ccc76d86d2004ed1a38ba0cf39ecb4b1",
25
model_version=resources_pb2.ModelVersion(
26
id="cc76a92beaeb4d8495a58ba197998158"
27
)
28
)
29
),
30
resources_pb2.WorkflowNode(
31
id="wedding-concepts",
32
model=resources_pb2.Model(
33
id="c386b7a870114f4a87477c0824499348",
34
model_version=resources_pb2.ModelVersion(
35
id="787cc9a002164250800598d36b072384"
36
)
37
)
38
),
39
]
40
)
41
]
42
),
43
metadata=metadata
44
)
45
46
if patch_workflows_response.status.code != status_code_pb2.SUCCESS:
47
raise Exception("Patch workflows failed, status: " + patch_workflows_response.status.description)
Copied!
1
# Supported actions are: overwrite, merge, remove.
2
3
curl -X PATCH 'https://api.clarifai.com/v2/workflows' \
4
-H 'Content-Type: application/json' \
5
-H 'Authorization: Key YOUR_API_KEY' \
6
--data-raw '{
7
"action": "overwrite",
8
"workflows": [
9
{
10
"id": "my-custom-workflow",
11
"nodes": [
12
{
13
"id": "travel-concepts",
14
"model": {
15
"id": "ccc28c313d69466f836ab83287a54ed9",
16
"model_version": {
17
"id": "cce28c313d69466f836ab83287a54ed9"
18
}
19
}
20
},
21
{
22
"id": "nsfw-concepts",
23
"model": {
24
"id": "ccc76d86d2004ed1a38ba0cf39ecb4b1",
25
"model_version": {
26
"id": "cc76a92beaeb4d8495a58ba197998158"
27
}
28
}
29
},
30
{
31
"id": "wedding-concepts",
32
"model": {
33
"id": "c386b7a870114f4a87477c0824499348",
34
"model_version": {
35
"id": "787cc9a002164250800598d36b072384"
36
}
37
}
38
}
39
]
40
}
41
]
42
}'
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"action": "overwrite",
7
"workflows": [
8
{
9
"id": "my-custom-workflow",
10
"nodes": [
11
{
12
"id": "travel-concepts",
13
"model": {
14
"id": "ccc28c313d69466f836ab83287a54ed9",
15
"model_version": {
16
"id": "cce28c313d69466f836ab83287a54ed9"
17
}
18
}
19
},
20
{
21
"id": "nsfw-concepts",
22
"model": {
23
"id": "ccc76d86d2004ed1a38ba0cf39ecb4b1",
24
"model_version": {
25
"id": "cc76a92beaeb4d8495a58ba197998158"
26
}
27
}
28
},
29
{
30
"id": "wedding-concepts",
31
"model": {
32
"id": "c386b7a870114f4a87477c0824499348",
33
"model_version": {
34
"id": "787cc9a002164250800598d36b072384"
35
}
36
}
37
}
38
]
39
}
40
]
41
});
42
43
const requestOptions = {
44
method: 'PATCH',
45
headers: {
46
'Accept': 'application/json',
47
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
48
},
49
body: raw
50
};
51
52
fetch(`https://api.clarifai.com/v2/workflows`, requestOptions)
53
.then(response => response.text())
54
.then(result => console.log(result))
55
.catch(error => console.log('error', error));
Copied!

Delete

Delete workflow by ID

Delete a specific workflow.
Java
NodeJS
Python
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
BaseResponse deleteWorkflowResponse = stub.deleteWorkflow(
8
DeleteWorkflowRequest.newBuilder()
9
.setWorkflowId("my-custom-workflow")
10
.build()
11
);
12
13
if (deleteWorkflowResponse.getStatus().getCode() != StatusCode.SUCCESS) {
14
throw new RuntimeException("Delete workflow failed, status: " + deleteWorkflowResponse.getStatus());
15
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.DeleteWorkflow(
5
{
6
workflow_id: "my-custom-workflow",
7
},
8
metadata,
9
(err, response) => {
10
if (err) {
11
throw new Error(err);
12
}
13
14
if (response.status.code !== 10000) {
15
throw new Error("Delete workflow failed, status: " + response.status.description);
16
}
17
}
18
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
delete_workflow_response = stub.DeleteWorkflow(
5
service_pb2.DeleteWorkflowRequest(
6
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
7
workflow_id="my-custom-workflow"
8
),
9
metadata=metadata
10
)
11
12
if delete_workflow_response.status.code != status_code_pb2.SUCCESS:
13
raise Exception("Delete workflow failed, status: " + delete_workflow_response.status.description)
Copied!
1
curl -X DELETE 'https://api.clarifai.com/v2/workflows/my-custom-workflow \
2
-H 'Content-Type: application/json' \
3
-H 'Authorization: Key YOUR_API_KEY'
Copied!
1
const appId = '{YOUR_APP_ID}'
2
const workflowId = '{YOUR_WORKFLOW_ID}'
3
4
const requestOptions = {
5
method: 'DELETE',
6
headers: {
7
'Accept': 'application/json',
8
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'