Send inputs to workflow via REST api?

Hello, I would like to easily push data into a temporal workflow on demand from another service. That said, is there a way to push data into an existing temporal workflow via REST api?

for example, if I had a simple workflow called MyNameWorkflow that accepts inputs name:str and returns f"my name is: {name}" using server foo.tmprl.cloud:7233 via Temporal Cloud. Is there a method in which I could trigger that workflow via rest?

curl -X POST https://foo.tmprl.cloud:8080/api/workflows \
-H "Content-Type: application/json" \
-d '{
    "id": "my_workflow_id",
    "workflowType": "MyNameWorkflow",
    "taskQueue": "my-task-queue",
    "input": {
        "name": "John Smith"
    }
}'

if not, I can create my own service that executes processes like this via the python sdk. Just wanted to triple check prior to see if temporal supports this natively

Yes you can use openapi so dont have to write custom wrappers if you dont want to.
You can see the openapi and swagger defs via:

http://<frontend_host>:<frontend_http_port>/swagger.json
http://<frontend_host>:<frontend_http_port>/openapi.yaml

default http port is 7243: temporal/docker/config_template.yaml at main · temporalio/temporal · GitHub

so your command to start new execution could be something like:

curl -X POST http://<frontend_host>:<frontend_http_port>/api/v1/namespaces/default/workflows/fromopenapi -H “Content-Type: application/json” -d @mystartrequest.json

where mystartrequest.json could be something like:

{
  "namespace": "default",
  "workflowId": "my-workflow-id",
  "workflowType": {
    "name": "MyWorkflowType"
  },
  "taskQueue": {
    "name": "my-task-queue"
  },
  "input": {
    "payloads": [
      {
        "name": "john"
      }
    ]
  }
}
1 Like