> For the complete documentation index, see [llms.txt](https://docs.perkville.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perkville.com/features/redeeming-rules/using-middle-to-automate-rewards.md).

# Using Middle to automate rewards

Middle can automatically fulfill a reward when a customer redeems it in Perkville. Perkville sends a synchronous webhook request to the reward’s selected Middle workflow, waits for its response, and uses the result to determine the voucher status and whether an ordinary points redemption is completed. Work with a Perkville representative to complete the steps below.

{% hint style="info" %}
**What is Middle?**

Middle is an integration platform owned by Perkville that powers Perkville integrations and custom workflows with connected systems. See [Middle integration capabilities](https://docs.perkville.com/integrations/middle-integration-capabilities.md) for currently documented connectors and common use cases.
{% endhint %}

## Webhook reference

For workflow builders and troubleshooting:

* [Real-time redemption requests](https://docs.perkville.com/features/redeeming-rules/using-middle-to-automate-rewards/real-time-redemption-requests.md) covers the endpoint, authentication, transaction and member fields, and an example request.
* [Real-time redemption responses](https://docs.perkville.com/features/redeeming-rules/using-middle-to-automate-rewards/real-time-redemption-responses.md) covers the required response, point deductions, voucher statuses, and uncertain outcomes.

## Set up Middle redemption

{% stepper %}
{% step %}

### Create a Middle API key for your account

{% hint style="info" %}
Likely a Perkville representative will help you with this step
{% endhint %}

1. Open the account in Middle.
2. Select **API keys** in the account navigation.
3. Select **Add API key**.
4. Enter a descriptive name for the calling system, such as `Perkville Redemptions`.
5. Leave **Active** on and select **Save**.
6. Copy the secret immediately (you will enter it in Perkville)

The secret is shown only once. Middle cannot display it again after you leave or refresh the page. If it is lost, rotate the key or create a new key.

{% hint style="danger" %}
Treat the entire value as a secret. Do not put it in a URL, query parameter, source control, browser-side code, or logs.
{% endhint %}

{% embed url="<https://docs.middle.app/middle-docs/product/real-time-workflow-api#create-an-api-key>" %}
{% endstep %}

{% step %}

### Enter the Middle API key in Perkville

1. Go to the reward program's [advanced settings](https://docs.perkville.com/features/settings/advanced.md)
2. Scroll down to **Middle**
3. Toggle **Use Middle** on
4. Paste the Middle API key you just created
5. Scroll to the bottom and click **Save**

<figure><img src="https://2181708597-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSiE75SeColbiBVbet0NZ%2Fuploads%2FOmuc8y4XnjsvDljcztYx%2FScreenshot%202026-07-22%20at%201.34.55%E2%80%AFPM.png?alt=media&#x26;token=9019c8d6-a748-4006-972f-d874e2b5250b" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create a real-time workflow API endpoint

1. Go back to the business's Middle account and click on **Workflow Triggers** in the left-hand menu
2. Scroll to **Real-time workflow API endpoints from modules**
3. Click **Connect real-time workflow API endpoint from module**
4. Select the relevant module connection, workflow, and API key(s)
5. Click **Create**

The API key, endpoint, and workflow’s real-time API trigger must be active, and the workflow must have a live version eligible for the API. Its Return step must define boolean `success` and string `success_message` and `error_message` fields. See the [response contract](https://docs.perkville.com/features/redeeming-rules/using-middle-to-automate-rewards/real-time-redemption-responses.md#response-contract) for examples.
{% endstep %}

{% step %}

### Map the reward(s) to Middle

Go to the relevant reward perks you want to automatically credit through Middle.

1. Toggle **Use Middle to automate redemption** to **Yes**
2. Select the workflow this perk should map to
3. Click **Save**

Repeat these steps for each reward you want to set up.

Perkville loads the workflow choices from Middle using the business’s API key and filters them for the required output schema. If a workflow is missing, check that its endpoint is active, linked to the key, and configured with the required output fields.
{% endstep %}
{% endstepper %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.perkville.com/features/redeeming-rules/using-middle-to-automate-rewards.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
