> For the complete documentation index, see [llms.txt](https://docs.middle.app/middle-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.middle.app/middle-docs/guides/app-reference/hubspot/calling-real-time-workflows-from-hubspot.md).

# Calling real time workflows from HubSpot

Using HubSpot's **Send a webhook** workflow action, you can call Middle in real-time to execute a synchronous workflow and provide a response to HubSpot.

{% hint style="info" %}
This allows you to integrate Middle's integrations and flexibility into your HubSpot workflows
{% endhint %}

{% content-ref url="/pages/b9dc7e9a8b7e86216473a5dfe538a6151ce71077" %}
[Real-time Workflow API](/middle-docs/real-time-workflow-api.md)
{% endcontent-ref %}

## How to call Middle from a HubSpot workflow

{% stepper %}
{% step %}

### Create a **HubSpot workflow that sends a webhook**

Create a workflow in HubSpot and a **Send a webhook** step
{% endstep %}

{% step %}

### Configure your webhook step

Configure your **Send a webhook** step as follows:

#### Method

Select **POST.** The endpoint to run a workflow in Middle is a POST endpoint.

#### Webhook URL

The **Invoke URL** from your [real-time workflow API endpoint](/middle-docs/real-time-workflow-api.md#configure-a-real-time-workflow-api-endpoint).

It will look something like this:

`https://integrate.middle.app/api/workflow-invoke/239j4023r2323rimno32r/`

#### Authentication type

Select **API Key**.

#### API key

Click to create a new HubSpot secret. Enter the [API key](/middle-docs/real-time-workflow-api.md#create-an-api-key) for the relevant Middle account with "Bearer " prefixed to the key.

If your API key is `1234abcd56789efghij` then you'd enter `Bearer 239j4023r2323rimno32r`.

#### API key location

Select **Request header**.

#### Request body

Build out the properties and static values for your request to match the input variables in the begin step of the workflow you want to call.
{% endstep %}

{% step %}

### Test your webhook action

Use HubSpot's webhook testing to run a test call to your workflow. You can then review the workflow executions for the workflow in Middle.
{% endstep %}
{% endstepper %}

## Error troubleshooting

### 401

If you receive a `401` response from Middle, ensure that you correctly filled out the inputs in the previous step. Ensure that you prefixed your Middle API key with "Bearer " when creating your HubSpot secreat.

### 404

If Middle returns a `404`, make sure the webhook URL matches the **Invoke URL** in the real-time trigger for your Middle workflow.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.middle.app/middle-docs/guides/app-reference/hubspot/calling-real-time-workflows-from-hubspot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
