---
title: "Set up Retention Messaging"
description: "Connect Adapty to Apple's Retention Messaging: configure it in sandbox, pass Apple's performance test, then switch to production."
---

Before subscribers can see your retention messages, Apple needs a way to reach Adapty when someone cancels. This article shows how to set up that connection — first in sandbox mode, then in production.

## Before you begin

- Add an [App Store Connect API key](app-store-connection-configuration) to Adapty. Adapty uses it to register the realtime URL and communicate with Apple.
- Request access to [Apple's Retention Messaging program](https://developer.apple.com/documentation/retentionmessaging) and wait for Apple's approval. Without approval, Apple rejects the connection.

## Sandbox setup

Apple requires you to test the connection in a sandbox environment first, so you can verify its reliability before sending production messages.

### Configure Sandbox URL

Click **Configure Sandbox URL** to begin the setup.

Adapty connects your App Store Connect account to its own realtime endpoint. If a different URL is already set in App Store Connect, the button shows **Replace URL** instead.

When the connection succeeds, Adapty confirms with "Sandbox URL has been configured."

### Test the connection

Before you can send production messages, Apple performs a test to confirm that Adapty is quick to respond to its requests.

1. Purchase one of your products with [a sandbox account](test-purchases-in-sandbox). The test needs a transaction to cancel.
2. Click **Start Test**. The test takes a few minutes, and you can retry it in case of failure.

## Switch to production

After you set up the sandbox environment, Adapty allows you to switch the **Sandbox mode** toggle off, and enter production mode.

Click **Configure URL**. Adapty registers its endpoint with Apple for production and confirms with "Production URL has been configured." If a different production URL is already set in App Store Connect, click **Replace URL** instead.  

## Next steps

- [Create a retention message](retention-messaging-create) that subscribers see when they cancel.