> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usehydra.co.za/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up access and actions

> Agree the program, connect your backend and map the actions you will report.

Before making calls, confirm your access and test environment with us.

## Agree the program and responsibilities

Agree with the merchant which activity qualifies and what members can earn.

For example, the merchant might configure a **Completed purchase** action worth
10 points and a non-repeatable points campaign with a goal of 30. If the member
enters that campaign with their first qualifying purchase, that purchase counts.
Three such purchases can reach the goal. The balance stays at 30 after the award;
a fourth purchase can bring it to 40 without awarding that campaign again.

Use the merchant's actual configuration for your integration. Campaigns can count
points, a selected action or joining, with their own audiences, windows and prerequisites.
Other qualifying activity at the business can contribute too; reporting purchases
does not make a points campaign purchase-specific.

| Who | Responsibility |
| - | - |
| You | Verify phone ownership, capture rewards consent, confirm activity and call Hydra from your backend. Display each member's progress and gifts privately. |
| The merchant | Defines qualifying behavior, goals, eligible members and rewards. Configures the program in Hydra. |
| Us | Confirm access and setup, provide your credential, configure delivery and help resolve delayed gifts. |
| Retailer | Validates the issued voucher at redemption under the offering's instructions. |

Confirm these details with the merchant and your Hydra contact:

| Item | What to record |
| - | - |
| Business and app | Business name, Hydra business reference, integrating app and backend owner. |
| Environment | Exact API base URL and whether external issuing/messaging can occur during testing. |
| Confirmed event | The backend event that proves the action happened, and when it becomes final enough to report. |
| Action mapping | App event name → Hydra action ID, current version, category and fixed points. |
| Campaign | Goal, audience, time window, prerequisites, repeatability and reward, configured in Hydra. |
| Gift arrangement | Confirmed retailer offering/value, funding responsibility and who resolves an unavailable offering. |
| Delivery mode | `app_only` or `app_and_whatsapp`, explicitly selected with Hydra. |
| Member consent | Where consent is captured, the wording identifier and who maintains the wording. |
| Account changes | Who handles phone changes, account conflicts and withdrawal requests. |
| Support | Named contacts for app/backend problems and Hydra reward/credential problems. |
| First exercise | Agreed test identities, test data, expected program behavior and permission for any external calls. |

A non-repeatable campaign awards once per member. Other campaigns can award
separately, and repeatable campaigns follow their configured rules. Use the API's
results to display progress rather than calculating campaign rules in your app.

## Prepare the business and connection

We'll confirm that the business, actions, campaigns and gift funding are ready
for your test, then provide a restricted credential through an agreed secret
channel. There is one integration per business.

Store the credential in your backend's secret store. Keep it out of mobile apps,
browser JavaScript and public configuration. Gift issuance also needs available
funding and an available retailer offering.

The credential authorizes business access. You still authenticate your users and
check ownership before returning member or gift details. Use the signed-in
account's saved Hydra member ID; a gift UUID alone is not proof of ownership.

### Choose how gifts reach the member

| Mode | Member experience |
| - | - |
| `app_only` | Display the gift in your app, with no direct WhatsApp delivery for that integration-earned gift. |
| `app_and_whatsapp` | Display the gift in your app and let Hydra send it through the business's permitted WhatsApp delivery. |

Choose the mode with us during setup. WhatsApp delivery still needs the business's
connection, templates and permissions; this setting does not grant marketing consent.
Changes apply to future qualifications. Gifts already earned keep their delivery
mode through delays or recovery. Separate staff gifts and messages are unaffected.

### Make backend requests

Use the `/v1` API prefix for the integration. Examples assume your environment has:

```text theme={null}
HYDRA_BASE_URL = the exact API URL ending in /v1, without a trailing slash
HYDRA_TOKEN = the restricted integration credential from your secret store
```

Every app call uses:

```http theme={null}
Authorization: Bearer <integration credential>
Content-Type: application/json
```

GET requests need no JSON body. JSON operations reject unsupported fields. Do not
send a business ID to select another business; the credential fixes that scope.

The examples use fictional identities and IDs. Replace them with your test data
and returned values. Load the credential securely and keep private response
bodies out of logs, screenshots and analytics.

Your HTTP client must check the HTTP status as well as the JSON body. Errors use
an `error` code, for example a `409` response:

```json theme={null}
{"error": "action_changed"}
```

Branch on the status and code, not human-readable message text. The examples show
response bodies separately; with curl, add `--write-out '\nHTTP %{http_code}\n'`
to inspect the status during the exercise. Record `X-Hydra-Trace-ID` for support
without logging the private response body.

## Read and map actions

An action is a merchant-defined behavior with fixed points. Your app confirms
that the behavior happened; Hydra owns its configured points and version.

```sh theme={null}
curl --silent --show-error \
  "$HYDRA_BASE_URL/integration/actions" \
  --header "Authorization: Bearer $HYDRA_TOKEN"
```

A successful response is `200`:

```json theme={null}
{
  "actions": [{
    "id": "7b9b1e00-2200-4000-8000-000000000001",
    "name": "Completed purchase",
    "category": "purchase",
    "points": 10,
    "active": true,
    "version": 1
  }]
}
```

Map the appropriate action to your confirmed event, such as an order moving
into its agreed completed state. Use the ID, not the display name, as the mapping.
Keep the current version with the mapping. Refresh when the merchant changes its
program or Hydra returns `action_changed` for an unaccepted occurrence.

A selected-action campaign counts only the action the merchant chose. Every
action contributes its awarded points to points campaigns. The merchant
chooses the action and its points. Your app cannot override points, category, campaign,
retailer or gift value in the activity request.

If `actions` is empty, check the configuration with the merchant or us.
`409 business_setup_required` means we need to finish business setup before you
can continue.

Next: [Link members](https://docs.usehydra.co.za/integrations/app-rewards/members.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.