POST
/
api
/
v2
/
workflow
/
run
curl --location 'https://agent.tennr.com/api/v2/workflow/run' \
--header 'Authorization: api-key <API key>' \
--form 'input-variable-1="What is tennr?"' \
--form 'input-variable-2="Use a concise tone."' \
--form 'agentId="<Agent ID>"'
{
  "output": "Tennr is an AI workflow builder.",
  "sources": [
    {
      "embedding": "Tennr is a new AI workflow building tool.",
      "metadata": {
        "assistantId": "...",
        "documentId": "...",
        "loc.lines.from": 1,
        "loc.lines.to": 50
      },
      "confidence": 0.85
    }
  ]
}

Body (multipart/form-data)

agentId
string
required

This is the ID of the agent that you would like to execute. Found within the Tennr platform.

your-input-variable
string

If your input step is not configured in “batched” mode, then you can put your arguments at the base level of the request body. For example, if you have an input variable named “Question” you would pass a form field, “Question”, with the value you’d like to pass to the workflow, such as “What is Tennr?“.

batches
string

If your input step is configured in “batched” mode, then you must provide an argument to the “batches” field in the request body. This field must be populated with a stringified JSON array of objects. Each object in the array represents one “batch” of inputs, and should be in { key: value } format. For example, if if you have an input configured to accept a “Question” and “Tone” you could provide the following arguments to submit two batches to the workflow.

[
{
  "Question": "What is Tennr?",
  "Tone": "Professional"
},
{
  "Question": "Why did the chicken cross the road?",
  "Tone": "Funny"
}
]
pastMessages
array

This optional argument allows you to supply a list of previous messages for usage in chat-based applications. Each message should be in the following format.

{
  "role": "system", "user", or "assistant",
  "content": "The content of the message"
}
stream
boolean

This optional argument enables streaming results back in real time. If enabled the results of individual steps and, for certain steps like generate answer, partial updates will be sent back as they are generated. The results will be sent back using server-sent events format. Please contact [email protected] for support ingesting the results on the frontend.

Response

output
string
required

The generated text response as configured in the Tennr app at the output step.

sources
array

If a workflow contains a reference context step the sources used will be returned as an array of objects in the following format.

[
  {
    "embedding": "The text that was used as a source.",
    "metadata": {
      ...various metadata for internal usage...
    },
    "confidence": 0.855
  },
  {
    "embedding": "More text that was used as a source.",
    "metadata": {
      ...various metadata for internal usage...
    },
    "confidence": 0.766
  }
]

Errors

We use zod to dynamically validate your inputs according to your workflow configuration. If the workflow is not in “batched” mode, you will receive an error response similar to the below with details for each value that was invalid.

Response
{
  "error": "Invalid input.",
  "details": {
    "field_a": ["Required"],
    "field_b": ["Must be one of these options: OptionA, OptionB"]
  }
}

If the workflow is in “batched” mode, you will receive a JSON response like the below that provides the same data as above, but with an indicator for which member of the input array was invalid.

Response
{
  "error": "Invalid input in batched mode.",
  "details": {
    "0.field_a": ["Required"],
    "1.field_b": ["Must be one of these options: OptionA, OptionB"]
  }
}