# n8n + MindStudio

MindStudio Agents can be triggered directly from [n8n](https://n8n.io/) using an HTTP Request node to run custom workflows. This guide walks you through the full setup.

{% embed url="<https://www.youtube.com/embed/-rI6e--hf4Q>" %}

## Prerequisites

Before you start:

* You must have a **MindStudio account** with a published AI Agent.
* You'll need your **Agent ID** and an **API key** from the MindStudio Developer Portal.
* Your agent must have **Launch Variables** setup in the Start Block.
* (optional) Set your Terminator Block to the End behavior to output JSON&#x20;

### How to find your Agent ID

1. Open the Agent you'd like to call via API
2. In the Editor, click the top folder to open the Agent Settings
3. On the Metadata tab, you'll find the Agent ID at the bottom.
4. Click on the Agent ID to copy it to your clipboard.

<figure><img src="/files/GxZZOINK1gFPjgvX7LyJ" alt=""><figcaption><p>Agent ID in Metadta Tab</p></figcaption></figure>

### How to get an API Key

1. Go to <https://app.mindstudio.ai/developer/api-keys>
2. Click on "Create Key"
3. Name your Key
4. Click on the key to copy it to your clipboard

<figure><img src="/files/ZHWNv5sWqvOl8VHpQuyo" alt=""><figcaption><p>Create an API Key</p></figcaption></figure>

### How to create Launch Variables

1. Open the Agent you'd like to call via API
2. In the automations tab, click on the **Start Block**
3. Make sure your **Run Mode** is set to **On-Demand**
4. At the top of the configuration panel click to add new launch variables

<figure><img src="/files/6y4Qg1L7tL7ex5DDVmd1" alt=""><figcaption><p>Creating Launch Variables</p></figcaption></figure>

## Step-by-Step Setup in n8n

#### 1. **Add an HTTP Request Node**

* Click the “+” button in n8n
* Search for and select **HTTP Request**
* Double-click on the node to open configuration settings

#### 2. Click on Import cURL button at the top right of the&#x20;

<figure><img src="/files/wWZa8WgS2QZp4skVTBLh" alt=""><figcaption><p>Import cURL Button</p></figcaption></figure>

#### **3. Paste in this cURL command**

Make sure to change **`YOUR_API_KEY`** - [See section above get your API key](#how-to-get-an-api-key)

```bash
curl -X POST https://v1.mindstudio-api.com/developer/v2/agents/run \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
  
```

#### 5. Click on `IMPORT`

#### 6. Once imported, change the `Specify Body` setting to `Using JSON`

<figure><img src="/files/agKVlv3hwtAZycac6j3I" alt=""><figcaption><p>Send Body Section</p></figcaption></figure>

#### 7. Paste the following code into the `JSON` area

```json
{{
{
    "workerId": "YOUR_AGENT_ID",
    "variables": {
      "LAUNCH_VARAIBLE_1": VALUE_1,
      "LAUNCH_VARAIBLE_2": VALUE_2,
    },
    "workflow": "YOUR_WORKFLOW_NAME.flow"
  }
}}
```

#### 8. In the `JSON`, replace the following with your own data:

* **`YOUR_AGENT_ID`** - [See section above to get your AGENT ID](#how-to-find-your-agent-id)
* **`LAUNCH_VARIABLES`** - [See section above to learn how to create launch variables](#how-to-create-launch-variables)
* **`VALUES`** - These values will come from your n8n instance. You can clack and drag any input from the left into the JSON area to bring it into your code. When you drag an input in, it should look like this: `$json['Value']` . If you are not using inputs from n8n, then make sure to wrap your value in quotation marks like this: `"value"`&#x20;
* **`YOUR_WORKFLOW_NAME`** - The name of the workflow you want to trigger (Ex: `Main.flow`)

***

## Test & Debug

Run the workflow manually with sample data. If there’s an error, check the `HTTP Response Code` and `body` message. You may also consider using n8n's built in assistant to help debug.

### Common issues:

* Invalid API Key → Ensure your key is copied correctly from MindStudio.
* Invalid Agent ID → Only use published Agent IDs.
* Missing variables → Ensure all required launch variables are included.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://university.mindstudio.ai/docs/integration-guides/n8n-+-mindstudio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
