REST API Reference
Teams Included on the Teams plan. Not available on the Lite version. Upgrade →
ABSPLITTEST REST API Documentation
The ABSPLITTEST plugin provides a comprehensive REST API for programmatic access to A/B testing functionality. All endpoints require authentication and the edit_posts capability.
Base URL
https://your-site.com/wp-json/bt-bb-ab/v1/
Authentication
Use WordPress Application Passwords for authentication:
- Go to Users → Profile
- Scroll to Application Passwords
- Create a new application password
- Use Basic Auth with your username and application password
Available Endpoints
1. Create Test
POST /wp-json/bt-bb-ab/v1/create-test
Request Body:
{
"test_title": "My A/B Test",
"test_type": "magic",
"status": "draft",
"magic_definition": [
{
"original": "Old Text",
"variations": ["New Text 1", "New Text 2"]
}
],
"conversion_type": "click",
"conversion_selector": ".buy-button"
}
Response:
{
"success": true,
"test_id": 123,
"test_type": "magic",
"edit_url": "https://your-site.com/wp-admin/post.php?post=123&action=edit",
"message": "Test created successfully"
}
2. List Tests
GET /wp-json/bt-bb-ab/v1/list-tests
Response:
{
"success": true,
"count": 5,
"tests": [
{
"id": 123,
"title": "Homepage Hero Test",
"type": "magic",
"status": "publish",
"visits": 1500,
"conversions": 75,
"conversion_rate": 5.0
}
]
}
3. Get Test Results
GET /wp-json/bt-bb-ab/v1/test-results/{id}
Response:
{
"success": true,
"test": {
"id": 123,
"title": "Homepage Hero Test",
"type": "magic",
"status": "publish",
"visits": 1500,
"conversions": 75,
"conversion_rate": 5.0,
"variations": {
"control": {
"visits": 750,
"conversions": 30,
"conversion_rate": 4.0
},
"variation_1": {
"visits": 750,
"conversions": 45,
"conversion_rate": 6.0
}
}
}
}
4. Update Test Status
POST /wp-json/bt-bb-ab/v1/update-test-status
Request Body:
{
"test_id": 123,
"status": "publish"
}
Response:
{
"success": true,
"test_id": 123,
"status": "publish",
"message": "Test status updated successfully"
}
5. Duplicate Test
POST /wp-json/bt-bb-ab/v1/duplicate-test
Copies a test’s settings, variations, goals, targeting and audiences into a new test. Results, winners and public report links are not copied.
Request Body:
{
"test_id": 123,
"title": "Homepage Hero, round 2",
"status": "draft"
}
test_id is required. title is optional (default: the original title with “(Copy)” added). status is optional: idea, draft, publish, pending or complete (default: draft, or idea when you duplicate an idea).
Response:
{
"success": true,
"test_id": 456,
"source_test_id": 123,
"test_type": "magic",
"status": "draft",
"title": "Homepage Hero, round 2",
"edit_url": "https://your-site.com/wp-admin/post.php?post=456&action=edit"
}
6. Plugin Settings
GET /wp-json/bt-bb-ab/v1/settings and POST /wp-json/bt-bb-ab/v1/update-settings
From version 2.6.0 every site-wide plugin setting can be read and updated as a single settings object (administrator only, secrets returned masked). See Managing Plugin Settings via REST API, WP-CLI and MCP for the full reference.
Example: cURL Request
curl -X POST https://your-site.com/wp-json/bt-bb-ab/v1/create-test
-u "username:application_password"
-H "Content-Type: application/json"
-d '{
"test_title": "My Test",
"test_type": "magic",
"status": "draft"
}'
Example: JavaScript/Fetch
const response = await fetch('https://your-site.com/wp-json/bt-bb-ab/v1/list-tests', {
headers: {
'Authorization': 'Basic ' + btoa('username:application_password')
}
});
const data = await response.json();
Error Handling
All endpoints return standard HTTP status codes:
- 200 - Success
- 400 - Bad Request (invalid parameters)
- 401 - Unauthorized (authentication failed)
- 403 - Forbidden (insufficient permissions)
- 404 - Not Found (test doesn’t exist)
- 500 - Server Error
Rate Limiting
The REST API follows WordPress core rate limiting. For high-volume usage, consider implementing request throttling on your end.