Example of implementation

Example using Remote control API

This guide provides a practical use case example for implementing the Web Experimentation Resource Loader API. It demonstrates how to create a complete A/B test campaign with variations and modifications using a single API call.

Overview

The Resource Loader API allows you to create, update, or delete multiple related resources (campaigns, variations, modifications, folders, audiences) in a single HTTP POST request. This approach ensures data consistency and simplifies the creation of complex experimentation setups.

API Endpoint

POST https://resource-loader-api.abtasty.com/v1/web-exp/resource-loader

Headers

Content-Type: application/json
Authorization: Bearer YOUR_API_TOKEN

Use Case Example: Creating an A/B Test Campaign

This example demonstrates creating a complete A/B test setup that includes:

  • A folder to organize campaigns

  • An audience segment for targeting

  • An A/B test campaign with two variations

  • Modifications for each variation

Complete Resource Loader Payload

Step-by-Step Implementation

Step 1: Prepare Your Payload

Create a JSON file (e.g., campaign-setup.json) with your resource loader configuration. Use the $_ref notation to reference resources created earlier in the same request.

Step 2: Make the API Request

Using cURL

Using JavaScript (Fetch API)

Step 3: Handle the Response

The API will return a response containing the IDs of all created resources:

Advanced Use Cases

Updating Existing Resources

To update an existing campaign, use the update action and provide the resource ID:

Deleting Resources

To delete a resource:

Using Reference Injection

You can inject existing resource IDs from command-line flags when using the AB Tasty CLI:

Then reference it in your JSON:

Best Practices

  1. Use Meaningful References: Choose descriptive $_ref names that clearly indicate what each resource represents.

  2. Organize Hierarchically: Structure your resources in parent-child relationships using the nested resources array for better readability.

  3. Test with Paused Status: Always create campaigns with "status": "pause" initially, then activate them after verification.

  4. Validate Before Sending: Ensure all required fields are present and references are correct to avoid partial failures.

  5. Handle Errors Gracefully: Check the response status for each resource, as some may succeed while others fail.

  6. Use Folders for Organization: Group related campaigns in folders for easier management.

  7. Start Simple: Begin with a small test payload before creating complex nested structures.

Support

For questions or issues with the Resource Loader API, consult the main Resource Loader documentation or contact AB Tasty support.

Last updated

Was this helpful?