Cadence HTTP API
Overview
Cadence HTTP API allows users to interact with the Cadence server using the HTTP protocol. You can leverage this functionality to initiate or terminate workflows from your bash scripts, monitor the status of your cluster, or execute any other operation that the Cadence RPC declaration supports.
Cadence HTTP API is provided via port 8800 and only available from Cadence v1.2.2.
To create a Cadence cluster with HTTP API enabled, please check out Creating a Cadence Cluster with HTTP API.
Examples
Curl command
You can run the following curl
command to start a dummy workflow in the Cadence server assuming the domain sample-domain
has already been created.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
curl -X POST https://<load balancer address or node IP>:8800 \ -H 'context-ttl-ms: 2000' \ -H 'rpc-caller: curl-client' \ -H 'rpc-service: cadence-frontend' \ -H 'rpc-encoding: json' \ -H 'rpc-procedure: uber.cadence.api.v1.WorkflowAPI::StartWorkflowExecution' \ -d \ '{ "domain": "sample-domain", "workflow_id": "sample-workflow-id", "execution_start_to_close_timeout": "61s", "task_start_to_close_timeout": "60s", "workflow_type": { "name": "sample-workflow-type" }, "task_list": { "name": "sample-task-list" }, "identity": "client-name-visible-in-history", "request_id": "8049B932-6C2F-415A-9BB2-241DCF4CFC9C", "input": { "data": "IkN1cmwhIg==" } }' |
Python
The following Python script starts a dummy workflow in the sample-domain
as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import requests url = "https://<load balancer address or node IP>:8800" payload = { "domain": "sample-domain", "workflow_id": "sample-workflow-id", "execution_start_to_close_timeout": "10s", "task_start_to_close_timeout": "5s", "workflow_type": {"name": "sample-workflow-type"}, "task_list": {"name": "sample-task-list"}, "identity": "sample-worker", "request_id": "8049B932-6C2F-415A-9BB2-241DCF4CFC9C" } headers = { "Content-Type": "application/json", "context-ttl-ms": "2000", "rpc-caller": "curl-client", "rpc-service": "cadence-frontend", "rpc-encoding": "json", "rpc-procedure": "uber.cadence.api.v1.WorkflowAPI::StartWorkflowExecution" } response = requests.post(url, json=payload, headers=headers) data = response.json() print(data) |
C#
You can also use C# to start a dummy workflow in the sample-domain
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
using System; using System.Net.Http; using System.Text; using System.Text.Json; using System.Threading.Tasks; class StartWorkflowExecution { static async Task Main() { string url = "https://<load balancer address or node IP>:8800"; var payload = new { domain = "sample-domain", workflow_id = "sample-workflow-id", execution_start_to_close_timeout = "10s", task_start_to_close_timeout = "5s", workflow_type = new { name = "sample-workflow-type" }, task_list = new { name = "sample-task-list" }, identity = "sample-worker", request_id = "8049B932-6C2F-415A-9BB2-241DCF4CFC9C" }; var headers = new { Content_Type = "application/json", context_ttl_ms = "2000", rpc_caller = "curl-client", rpc_service = "cadence-frontend", rpc_encoding = "json", rpc_procedure = "uber.cadence.api.v1.WorkflowAPI::StartWorkflowExecution" }; var jsonPayload = JsonSerializer.Serialize(payload); var httpContent = new StringContent(jsonPayload, Encoding.UTF8, headers.Content_Type); httpContent.Headers.Add("context-ttl-ms", headers.context_ttl_ms); httpContent.Headers.Add("rpc-caller", headers.rpc_caller); httpContent.Headers.Add("rpc-service", headers.rpc_service); httpContent.Headers.Add("rpc-encoding", headers.rpc_encoding); httpContent.Headers.Add("rpc-procedure", headers.rpc_procedure); var client = new HttpClient(); var response = await client.PostAsync(url, httpContent); if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsStringAsync(); var data = JsonSerializer.Deserialize<object>(responseContent); Console.WriteLine(data); } } } |
HTTP API Endpoints
Following are the HTTP API endpoints currently supported in our managed Cadence service. For more information about Cadence HTTP API, please check out the Cadence HTTP API documentation.
AdminAPI
uber.cadence.admin.v1.AdminAPI::DescribeCluster
MetaAPI
uber.cadence.api.v1.MetaAPI::Health
VisibilityAPI
uber.cadence.api.v1.VisibilityAPI::CountWorkflowExecutions
uber.cadence.api.v1.VisibilityAPI::GetSearchAttributes
uber.cadence.api.v1.VisibilityAPI::ListArchivedWorkflowExecutions
uber.cadence.api.v1.VisibilityAPI::ListClosedWorkflowExecutions
uber.cadence.api.v1.VisibilityAPI::ListOpenWorkflowExecutions
uber.cadence.api.v1.VisibilityAPI::ListWorkflowExecutions
uber.cadence.api.v1.VisibilityAPI::ScanWorkflowExecutions
WorkflowAPI
uber.cadence.api.v1.WorkflowAPI::DescribeTaskList
uber.cadence.api.v1.WorkflowAPI::DescribeWorkflowExecution
uber.cadence.api.v1.WorkflowAPI::GetClusterInfo
uber.cadence.api.v1.WorkflowAPI::GetTaskListsByDomain
uber.cadence.api.v1.WorkflowAPI::GetWorkflowExecutionHistory
uber.cadence.api.v1.WorkflowAPI::ListTaskListPartitions
uber.cadence.api.v1.WorkflowAPI::QueryWorkflow
uber.cadence.api.v1.WorkflowAPI::RefreshWorkflowTasks
uber.cadence.api.v1.WorkflowAPI::RequestCancelWorkflowExecution
uber.cadence.api.v1.WorkflowAPI::ResetWorkflowExecution
uber.cadence.api.v1.WorkflowAPI::RestartWorkflowExecution
uber.cadence.api.v1.WorkflowAPI::SignalWithStartWorkflowExecution
uber.cadence.api.v1.WorkflowAPI::SignalWorkflowExecution
uber.cadence.api.v1.WorkflowAPI::StartWorkflowExecution
uber.cadence.api.v1.WorkflowAPI::TerminateWorkflowExecution
Please contact [email protected] if you have any questions.