Running a flow via HTTP lets you call your active flow like you would a typical API endpoint. This means that anyone with an authentication token and the flow link (even outside of aiWARE) can run the flow. To run a flow via HTTP:
- Get an authentication token
- Get the flow ID
- Determine the endpoint
- Post to the flow
Steps
Get an authentication token
An authentication token verifies your identity when you try to interact with an API endpoint. To get a token:
- Open the Graphql API playground and run this query after updating it with your username and password:
mutation {
userLogin(
input: {
userName: "<email@veritone.com>"
password: "<your password>"
}
) {
token
organization {
id
name
}
}
}
The query responds with your token.
- Record your token in a safe place.
Get the flow ID
In order to call your flow, you need to get your unique flow ID.
- In the Automate Studio flow editor, open your flow.
- In your browser's search bar, copy the randomly generated string in the URL. This is the ID of your flow. For example, if your URL is
https://automate.us-1.veritone.com/flow/c616a5b6-2ef6-4113-b98f-d7088335d096/latest, then the string you should copy is c616a5b6-2ef6-4113-b98f-d7088335d096. - Record your flow ID in a safe place.
Determine the endpoint
In order to call the right API endpoint, you need to use your flow ID to determine which endpoint you should call.
- In this URL,
https://controller-edge1.veritone.com/flow/<flow-id>/process, replace <flow-id> with your flow ID.
[Note] The DEPLOYED revision, not the latest, is used in the URL. If the flow is not deployed, the API will return an error. You can deploy only one revision at a time.
To call a specific revision for testing purposes, use the following URL format: https://controller-edge1.veritone.com/flow/<flow-id>/<rev id OR rev number OR 'latest'>/process.
- Record your endpoint in a safe place.
Post data to the flow
Now that you have your bearer token, flow ID, and endpoint, you can use the POST method to trigger the flow and pass it data. The payload in your request body is passed to the aiware-in node in your flow. The payload must be in JSON format.
- In the header of your API call, set the
Authorization property to "Bearer <your bearer token>" and set the content-type property to "application/json". - In your request body, set the
url property to the data you want to send to your flow.
For example, the request body would look something like:
{
"url": "https://s3.amazonaws.com/static.veritone.com/assets/StateOfTheUnion_15s.mp4"
}
- Post to the API endpoint you saved in the Determine the endpoint section. In curl, the post looks like this:
curl --location --request POST 'https://automate-controller-v3f.aws-prod-rt.veritone.com/edge/v1/flow/7ec7fdef-bcd8-42b1-8d67-82b6286fce60/afce5bc7-74af-41f3-94f1-d91ebb621f4b/process'
--header 'Authorization: Bearer b23cd'
If the flow starts successfully, you receive a JSON response like this:
{
"FlowId": "string",
"FlowRevisionId": "string",
"FlowExecutionId": "string"
}