> For the complete documentation index, see [llms.txt](https://docs.userlane.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.userlane.com/developers/analytics-api/using-the-analytics-api.md). Agents can also search and read this documentation through its [MCP server](https://docs.userlane.com/~gitbook/mcp).

# Using the Analytics API

These conventions apply to every Analytics API endpoint. Each "Getting started" guide covers what is specific to its endpoint.

## Base URL

All requests go to `https://api.userlane.com/analytics`, followed by the endpoint path. For example:

```
https://api.userlane.com/analytics/public/nps/property_id/{property_id}/responses
```

## Pagination

Endpoints page their results in one of two ways.

**Page numbers** (HEART, Enduser events, Guide progress, NPS responses, Survey responses, Tags):

| Parameter | Default | Description                                 |
| --------- | ------- | ------------------------------------------- |
| `page`    | `1`     | Page number, starting at 1                  |
| `limit`   | `1000`  | Number of records per page, from 1 to 5,000 |

The response contains a `pagination` object with `page`, `limit`, `totalElements`, and `totalPages`.

**Cursors** (Tasks, Tooltip engagement, Validators):

| Parameter | Default | Description                                                                       |
| --------- | ------- | --------------------------------------------------------------------------------- |
| `cursor`  |         | The `nextCursor` value from the previous response. Omit it to get the first page. |
| `limit`   | `1000`  | Maximum number of records per page, from 1 to 5,000                               |

Keep requesting with the latest `nextCursor` until the response has none. Treat the cursor as opaque: pass it back exactly as you received it.

## Sorting

Endpoints with a `sort` parameter (NPS responses and Survey responses) take a direction prefix and a field name, for example `-timestamp` for newest first. `-` sorts descending and `+` sorts ascending.

In a URL, a literal `+` is read as a space, so send ascending sorts as `%2B`: `sort=%2Btimestamp`, not `sort=+timestamp`. Most HTTP libraries do this for you when you pass parameters separately rather than building the URL by hand.

## Users without an ID mapping

Every record carries `user.applicationUserId`, the user ID your application sends to Userlane. When Userlane has no mapping for a user, the field is an empty string (`""`), not `null`. Check for both when you join on it.

## Errors

| Status                     | What happened                                                      |
| -------------------------- | ------------------------------------------------------------------ |
| `401 Unauthorized`         | The API token is missing, malformed, expired, or has been revoked. |
| `422 Unprocessable Entity` | One or more parameters failed validation.                          |
| `429 Too Many Requests`    | You exceeded the rate limit.                                       |

A `422` returns one entry per parameter that failed, naming the parameter and the reason. For example, a request without a required `start`:

```json
{
  "detail": [
    {
      "type": "missing",
      "loc": ["query", "start"],
      "msg": "Field required",
      "input": null
    }
  ]
}
```

A request that matches no data is not an error: it returns `200` with an empty list. Check the list rather than relying on the status code.

Responses carry an `x-request-id` header. Quote it when you contact support, since it identifies the request in our logs.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.userlane.com/developers/analytics-api/using-the-analytics-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
