> For the complete documentation index, see [llms.txt](https://docs.peakcommerce.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peakcommerce.com/developers/api-groups/sessions.md).

# Sessions

The **Sessions API** exposes read access to *journey sessions* — the per-visitor or per-user run-throughs of a configured journey. A journey session captures progress (current step, step history), context data collected along the way, and — since Task #2047 — a transaction **outcome** (`pending` / `success` / `failure`) plus a human-readable `outcomeReason` that records the specific business event (e.g. the operationType of the committing action or the terminal step label).

Key concepts:

* **`status`** tracks the session lifecycle: `active` (in progress), `completed` (reached a terminal step), `abandoned` (forcibly ended), `expired`.
* **`outcome`** is an independent axis that records the *transaction result* of the journey. A completed session can still have a `pending` outcome if the payment is being reconciled asynchronously.
* **`outcomeReason`** provides the specific cause — useful for analytics roll-ups and admin investigations.

All endpoints require an API key with the `read` scope.

See also: [Payments](/developers/api-groups/payments.md), [Subscriptions](/developers/api-groups/subscriptions.md).

## Endpoints

### `GET /api/v1/sessions`

{% openapi src="<https://api.peakcommerce.com/api/v1/openapi.json>" path="/sessions" method="get" %}
<https://api.peakcommerce.com/api/v1/openapi.json>
{% endopenapi %}

Returns journey sessions for the calling tenant, newest first (by `startedAt`). Use `?outcome=success` to retrieve only sessions that resulted in a purchase, or `?outcome=failure` to find sessions blocked by a payment or validation error.

The response shape per session:

| Field              | Type           | Description                                             |
| ------------------ | -------------- | ------------------------------------------------------- |
| `id`               | string         | UUID                                                    |
| `journeyId`        | string         | UUID of the parent journey                              |
| `status`           | string         | Lifecycle status                                        |
| `outcome`          | string         | Transaction outcome (`pending` / `success` / `failure`) |
| `outcomeReason`    | string \| null | Human-readable cause of the resolved outcome            |
| `visitorId`        | string \| null | Anonymous visitor identifier                            |
| `userId`           | string \| null | Authenticated user UUID                                 |
| `currentStepOrder` | integer        | Zero-based index of the current step                    |
| `startedAt`        | string         | ISO 8601 timestamp                                      |
| `completedAt`      | string \| null | ISO 8601 timestamp (null if still active)               |
| `lastActivityAt`   | string \| null | ISO 8601 timestamp                                      |

Requires the `read` scope.

### `GET /api/v1/sessions/{id}`

{% openapi src="<https://api.peakcommerce.com/api/v1/openapi.json>" path="/sessions/{id}" method="get" %}
<https://api.peakcommerce.com/api/v1/openapi.json>
{% endopenapi %}

Returns the full session record including `outcome` and `outcomeReason`. Useful for post-journey reconciliation — for example, polling after a webhook to confirm whether a specific session resolved to `success`.

Requires the `read` scope. Returns `404` for any session that is not scoped to the calling tenant's API key, regardless of whether the session ID exists.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.peakcommerce.com/developers/api-groups/sessions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
