---
title: "Test the API response"
slug: "test-the-api-response-of-a-headless-experience"
abstract: "Learn how to test the API response for a headless personalization or A/B/n test before publishing it."
---
# Test the API response

> [!important]
> Feature availability is part of a phased rollout. Your organization may not see this functionality yet. It will become available when your environment is included in the rollout.

After you configure a headless experience, click **Preview API** to test the response before you start it.

The **Preview API** option lets you test the experience for a specific visitor and check the JSON that SitecoreAI returns. There is no page preview, because a headless experience does not render itself.

The Preview API dialog has two tabs:
- **Test Scenario** - provide a guest reference and build the request body.
- **Response** - inspect the formatted JSON returned for that scenario.

> [!tip]
> Test at least twice using an identified visitor and an anonymous visitor. Anonymous visitors might have missing profile data, which can reveal issues in your response code.

To test the API response:

1. On the **Configuration** page, click **Preview API**.

2. On the **Test Scenario** tab, optionally provide any required request details such as **Analytics identifier**, **Headers**, and **Parameters**.

3. In **Profile**, choose one of the following:
   - **Load profile** - enter the visitor's client ID or profile ID. To retrieve these IDs, use [inspect mode](https://doc.sitecore.com/sai/en/users/sitecoreai/audience-and-insights/profiles/view-profile-details.html#use-inspect-mode "Use inspect mode").
   - **Generate profile** - use AI to generate a test profile from a natural-language prompt.

4. If you selected **Generate profile**:
   - Enter a description of the profile you want to test.

     Example: *A visitor from Copenhagen*

   - Click **Generate**.

   After the profile is loaded or generated, optionally click **View JSON** to review the profile data.

5. Click **Run test**.

6. On the **Response** tab, verify that the response contains the values your application expects and handles missing profile data safely.

## Next step

After the response behaves as expected, [publish the headless experience](https://doc.sitecore.com/sai/en/users/sitecoreai/headless-personalization-and-abn-testing/publish-a-headless-experience.html) to start it now or schedule it for later.
