MindStudio Docs
  • Get Started
    • Overview
    • MindStudio Chrome Extension
    • Quickstart Guide
    • What is an AI Agent?
    • AI Agent Use Cases
  • Free vs. Paid AI Agents
  • Building AI Agents
    • Editor Overview
    • Workflow Generator
    • Writing Prompts
      • Templating
    • AI Models
    • Variables
      • Working with JSON
      • Using Handlebars Templating
    • Dynamic Variables
    • Data Sources
    • Automations
      • Start Block
      • Generate Text Block
      • Generate Image Block
      • Generate Chart Block
      • Generate Asset Block
      • Display Content Block
      • Text to Speech Block
      • Analyze Image Block
      • User Input Block
      • User Context Block
      • Query Data Block
      • Run Function Block
      • Scrape URL Block
      • Extract Text from File Block
      • Post to Slack Block
      • Menu Block
      • Logic Block
      • Checkpoint Block
      • Jump Block
      • Run Workflow Block
      • Terminator Block
    • Integrations
      • Search Bluesky Posts
      • Scrape Facebook Page
      • Scrape Meta Threads Profile
      • Scrape Instagram Comments
      • Scrape Instagram Mentions
      • Scrape Instagram Posts
      • Scrape Instagram Profile
      • Scrape Instagram Reels
      • Create LinkedIn Post
      • Create X Post
      • Search X Posts
      • Search Google
      • Search Google Images
      • Search Google Trends
      • Search Google News
      • Create Google Doc
      • Fetch Google Doc
      • Update Google Doc
      • Create Google Sheet
      • Fetch Google Sheet
      • Update Google Sheet
      • Enrich Company via Domain
      • Find Contact Email for Website
      • Find Email
      • Verify Email
      • Enrich Person via Email
      • Fetch YouTube Captions
      • Fetch YouTube Channel
      • Fetch YouTube Comments
      • Fetch YouTube Video
      • Search YouTube
      • Search YouTube Trends
      • Create Notion Page
      • Update Notion Page
      • Apify
      • Run Scenario
      • Post to Slack
      • HTTP Request
      • Run Node
      • Create Contact
      • Add Note
      • Send Email
      • Send SMS
    • Publishing & Versioning
  • Embedding AI Agents
  • Using Webhooks
  • Workspace Management
    • Workspace Overview
    • Workspace Settings
    • Usage Explorer
    • Billing Settings
    • Account Settings
    • Team Settings & Access Controls
  • Test & Evaluate
    • Testing Suite Overview
    • Evaluations
    • Profiler
    • Debugger
  • Integration Guides
    • Zapier + MindStudio
    • Make.com + MindStudio
    • n8n + MindStudio
  • Developers
    • API Reference
    • NPM Package
    • Custom Workflow Functions
  • Additional Resources
    • Glossary
    • Allowing Access to Mindstudio From Your Network
  • Solutions
    • MindStudio Solutions Partners
    • MindStudio For Developers
    • MindStudio for Enterprises
Powered by GitBook
On this page
  • Overview
  • Run an app
  • Endpoint
  • Authentication
  • Response
  • Example usage
  • Load an app
  • Endpoint
  • Authentication
  • Response
  • Example usage
  • How to pass launch variables from an API request to a workflow
  • Example API request body
Export as PDF
  1. Developers

API Reference

Run AI Agents via API request.

Overview

With the MindStudio API you can enable the programmatically invocation of workflows. It allows for the integration of AI workflows as a step in larger automation processes.

Run an app

Executes a specified app with given variables and optional workflow.

Endpoint

POST /developer/v2/apps/run

Authentication

This endpoint requires Bearer token authentication.Request body

Field
Type
Description
Text

workflow

string

The workflow to run (without .flow extension)

No

variables

object

The variables to pass to the app

No

callbackUrl

string

The URL to receive the execution result

No

appId

string

The ID of the app to run

Yes

Response

Success response (200 OK)

The response will be one of two possible formats:

1 - For asynchronous execution (when callbackUrl is provided):

{
  "success": true,
  "callbackInProgress": true
}

2 - For synchronous execution:

{
  "success": true,
  "threadId": "string",
  "thread": {
    // Full thread object
  },
  "result": "string" // Content of the last system message
}

Error responses

400 Bad Request: The request was invalid or cannot be served.

500 Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request.

Example usage

const response = await fetch("https://api.mindstudio.ai/developer/v2/apps/run", {
  method: "POST",
  headers: {
    "Authorization": "Bearer {{YOUR_ACCESS_TOKEN}}",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "appId": "{{YOUR_APP_ID}}",
    "variables": {
      "key1": "value1",
      "key2": "value2"
    },
    "workflow": "optional-workflow-name",
    "callbackUrl": "https://your-callback-url.com/endpoint"
  })
});
const data = await response.json();
console.log(data);

Note: Replace YOUR_ACCESS_TOKEN and YOUR_APP_ID with your actual Bearer token and Agent ID, and adjust the request body according to your specific app requirements.

Load an app

Loads an app by ID. If the app is not found, it returns a 404 error.

Endpoint

GET /developer/v2/apps/load

Authentication

This endpoint requires Bearer token authentication.

Response

Success response (200 OK)

The response will be a JSON object containing the organization information.

{
  "orgId": "string",
  "orgName": "string"
}

Error response (404 Not Found)

The organization for the specified token was not found.

Example usage

const response = await fetch("https://api.mindstudio.ai/developer/v2/apps/load", {
  method: "GET",
  headers: {
    "Authorization": "Bearer {{YOUR_ACCESS_TOKEN}}"
  }
});
const data = await response.json();
console.log(data);

Note: Replace YOUR_ACCESS_TOKEN with your actual Bearer token.

How to pass launch variables from an API request to a workflow

The syntax for calling a launch variable will be different than calling a variable on runtime. Rather than using {{VARIABLE_NAME}} in your prompt, launch variables are called using {{$launchVariables->VARIABLE_NAME}} syntax.

This must be utilized anytime a launch variable is called within a workflow. In the following example, we will look at the body of an API request that passes a launch variable, topic, when running a MindStudio workflow.

Example API request body

Within the body request, the launch variable topic is assigned with the value “Dogs”.

{
  "appId": "{{YOUR_APP_ID}}",
  "variables": {
    "topic": "Dogs"
  },
  "workflow": "workflow-name",
  "callbackUrl": "https://your-callback-url.com/endpoint"
}

Note: Replace YOUR_APP_ID with your actual app ID.Example promptWithin a prompt area inside of Mindstudio, the topic launch variable is called using the launch variable syntax.

Assistant will write a blog post about the following topic:
{{$launchVariables->topic}}

Last updated 1 month ago