Skip to main content

/flows

Invoke a flow and get the generated result.

Promptitude Team avatar
Written by Promptitude Team
Updated this week

Generate Endpoint

Simple send a POST request to the endpoint, including the Authorization Header and the Request Object.

Action

POST

Endpoint URL

https://api.promptitude.io/v1/flows/:flowId/generate

Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Body

The below Request Object (JSON)

Request Object

Here's an example of the request object for a prompt with two input variables:

{ 
"userId": "9hhsOa6pGHes5BCDpCDeLD2i0kw2", //optional
"flow": {
"inputs": {
"name": "Andres",
"lastName": "Lopez"
}
}
}

Attributes of the Request Object:


inputs hash

Set of key-value pairs of all the prompt's input variables.


userId string Optional: A unique identifier of the final end-user who made the call. Could be a hash of their UID or email address, so it's not identifiable.


Context Parameter

In certain cases, you may need to override the folders and tags that are selected in specific step when the context option is enabled in a prompt. For this purpose, you can use the context property, structured as follows:


{
...body,
steps: {

step1: {
context: {
folders: {
ids: ["folder1"], // string[]
names: ["my folder"] // string[]
},
tags: {
ids: ["tag1"], // string[]
names: ["my tag"] // string[]
}
}
}

}
}

When you provide only the ids property, processing is faster since they are sent directly for filtering. When you use names, the system performs a database lookup to resolve them.

If you want to include all folders or tags, simply send an empty array in the ids or names property

Result Object

Here's an example of a result object after invoking a prompt:

{
"code": 200,
"message": "OK",
"error": false,
"results": {
"result": "Why did the developer need glasses? Because he couldn't C#!",
"logId": "Z2gV2otfCKIt17t76KFJ",
}
}

Attributes of the Result Object:


code number

Response code. 200 if everything went OK, otherwise the HTTP response code.


message string

"OK" if everything went well. If not, contains the detailed error message.


error boolean

Shows if an error occurred during the request.


results object

Detailed results of the invocation of the flow.

result string | array

Final generated output of the flow, according to the Result Type.

logId string

Unique ID of this invocation.

Did this answer your question?