# Results (/docs/api/agents/results)

Everything here is read-only and works for any role. Paths start with `/api/agent/organizations/{organizationId}/spaces/{spaceId}/{environment}`.

## Test results [#test-results]

```bash
curl https://improve.obelism.studio/api/agent/organizations/$ORG/production/tests/$TEST/results \
  -H "Authorization: Bearer $TOKEN"
```

```json
{
	"testId": "test_01H8XYZ",
	"status": "ready",
	"usageLimitReached": false,
	"results": {
		"summary": { "dateStart": "…", "dateUpdated": "…", "totalSessions": 2000 },
		"result": {
			"control": { "page_view": 1000, "sign_up": 100 },
			"bold": { "page_view": 1000, "sign_up": 140 }
		},
		"resultsByDate": []
	},
	"significance": {
		"method": "sequential",
		"confidence": 95,
		"control": "control",
		"significantVariants": ["bold"],
		"variants": {
			"bold": {
				"significantResult": true,
				"direction": "better",
				"percentile": 99,
				"pValue": 0.004,
				"difference": 0.02,
				"confidenceInterval": { "lower": 0.006, "upper": 0.034 },
				"zScore": 2.78,
				"standardErrorDifference": 0.014
			}
		}
	}
}
```

- `result` has the unique visitors per variant for each event of the test. The first event is the start, the last is the conversion.
- `value` and `orders` appear when events carry a `value`, such as an order total. They add up every event, including repeat purchases.
- `significance` compares each variant with the control, the first variant, at 95% confidence. `method` is `sequential`: `pValue` and the confidence interval stay valid however often you read the results, so they are safe to poll and to stop on. `percentile` is the strictest of 99, 95 and 90 that `pValue` clears. A variant is significant when it is clearly better **or** clearly worse; `direction` (`better`, `worse` or `none`) says which, so check it before calling a variant a winner.
- `status` is `pending`, and `results` is `null`, until the test has exposures.
- `sampleRatio` is the sample-ratio-mismatch check: when `mismatch` is `true`, visitors are not reaching the variants in the configured split, so do not trust the numbers until you find out why.
- `placements` counts the published Content entries that carry the test. With `status: pending` and `placements` above zero, the site is not reporting exposures yet.

Results are cached. A cached result comes back straight away and is recalculated in the background when it is older than 5 minutes. `POST` to the same path recalculates now. It answers `202` while there is nothing to calculate yet or a calculation is already running.

When the organization is past its event pool and the plan's buffer, results freeze at the last calculation: `usageLimitReached` is `true`, and a recalculation answers `402 usage_limit_reached`. Over the pool but within the buffer, results keep updating.

## Events [#events]

`GET .../events` lists every event and scope the environment has received, or a test refers to, with a `count` and `lastReceivedAt`. Use it to choose a test's [events](/docs/api/agents/tests).

## Visitor analytics [#visitor-analytics]

`GET .../analytics?timezone=Europe/Amsterdam` returns visitor charts for the environment ([Numbers](https://numbers.obelism.studio) shows the same and more in its dashboard):

- `visitors`: unique visitors per time bucket over the last `24h`, `7d`, `30d` and `90d`
- `popularPages`: the most viewed pages
- `countries`: visitors per country

`timezone` is an IANA time zone for the buckets, and defaults to `UTC`.
