Tests

Create, change, delete and copy A/B and multi-variant tests from an agent.

A test lives in one environment. Paths start with /api/agent/organizations/{organizationId}/{environment}/tests. Reading needs any role; creating, changing, deleting and copying need editor or higher.

Create an A/B test

curl -X POST https://improve.obelism.studio/api/agent/organizations/$ORG/staging/tests \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Hero copy",
    "options": [
      { "name": "Control", "split": 50 },
      { "name": "Bold", "value": "Try it free", "split": 50 }
    ],
    "events": {
      "start": { "event": "page_view", "scope": "/" },
      "conversion": { "event": "sign_up", "scope": "hero" }
    }
  }'
FieldDefault
nameRequired
slugThe slugified name. The SDK looks tests up by it
typeab-test
statedraft. Only active tests are served
audienceIdnull, everyone. Or an audience id
allocation100, the percentage of matching visitors in the test
optionsControl and Variation, 50/50
defaultValueThe first option's slug, served to visitors outside the test
eventsNone. Set them before going live, or there are no results

events says what counts: start is the event that enters a visitor in the funnel, conversion is the goal, and metrics are optional steps in between. Each is an { "event", "scope" } pair, the same names your code tracks.

Create a multi-variant test

A multi-variant test has variants instead of options: dimensions whose values are combined. Every combination is an option, with an equal split.

{
	"name": "Buy button",
	"type": "multi-variant-test",
	"variants": [
		{ "name": "Colour", "values": ["red", "blue"] },
		{ "name": "Size", "values": ["small", "large"] }
	]
}

This serves red-small, red-large, blue-small and blue-large. Its defaultValue is the first combination.

Change a test

PATCH .../tests/{testId} changes the fields you send. To start a test:

curl -X PATCH https://improve.obelism.studio/api/agent/organizations/$ORG/staging/tests/$TEST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"state":"active"}'
  • options and variants are the full new list. An item with an id updates it, one without is added, and items you leave out are deleted.
  • Changing type needs the new list, for example variants to switch to a multi-variant test.
  • events merges: start, metrics and conversion you leave out keep their value. Changing events recalculates the results.

The whole body is checked before anything is saved, so an invalid field changes nothing.

Copy tests to another environment

Copies tests with their state, options and events, like Sync in the dashboard. Results are not copied.

curl -X POST https://improve.obelism.studio/api/agent/organizations/$ORG/staging/tests/sync \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"testIds":["test_01H8XYZ"],"targetEnvironment":"production"}'
{ "created": 1, "overwritten": 0 }

When a test with the same slug already exists in the target, nothing is copied and the answer is 409 slug_conflict, with a conflicts list. Send "overwrite": true to replace them.

Other operations

MethodPathDoes
GET/testsList the tests, without options and variants
GET/tests/{testId}Get one test with its options or variants
DELETE/tests/{testId}Delete the test and its exposures (204)

On this page