---
title: "Traffic"
description: "<p>Per-URL request counts, HTTP status distribution, and cache hit and miss ratios.</p>"
url: "https://www.contentstack.com/docs/developers/apis/analytics-api/traffic"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-08-27"
---

# Traffic

Per-URL request counts, HTTP status distribution, and cache hit and miss ratios.

## Cache Usage

### Cache Usage

**GET** `/analytics/v2/hit-miss-ratio`

The Cache Usage request counts cache hits and misses, so you can see how much of your traffic the cache absorbs. A hit is a response served from cache; a miss is one that had to be read from the database.

Each row carries status, either HIT or MISS; type, the service, such as cdn; count, the number of responses; and date, the day they occurred.

Pass cache to restrict the result to HIT, to MISS, or to all.

#### Query Parameters

- **orgUid** (required)
  Enter the UID of your Organization.
- **from** (required)
  Specify the start date for the required data. Use the following date format: YYYY-MM-DD. It cannot be in the future.
- **duration** (optional)
  Determines the granularity of the data. Accepted values are sec, minute, hour, day, week, month, year, and historic; any other value returns a 400 error. If you omit duration, the response is not broken down by date.
- **to** (required)
  Enter the end date for the required data. The date format should be: YYYY-MM-DD. It must be on or after the from date and cannot be in the future.
- **services** (required)
  Specify the array of services for which you want statistics, such as: \["cma", "ui", "cdn", "graphql", "images", "assets", "automations", "launch", "cs-assets"\]. Pass either a JSON array of service names, for example \["cdn","cma"\], or a single service name on its own, for example automations. A comma-separated list is not supported and returns no data.
- **apiKey** (optional)
  Enter your stack API key to get data for that specific stack.
- **cache** (optional)
  Enter HIT to return only cached responses, MISS to return only responses served from the database, or all to return both. Any other value returns a 400 error.
- **space_uid** (optional)
  Enter a space UID to filter the response to that space, or all to include every space. The value is not case-sensitive. Only available when services is set to cs-assets on its own. Passing it alongside any other service returns a 400 error.
- **subService** (optional)
  Enter all, delivery-api, or management-api to filter the response to one part of the cs-assets service. The value is not case-sensitive; any other value returns a 400 error. Defaults to all. Like space\_uid, it can only be used when services is set to cs-assets on its own.

#### Headers

- **authorization** (optional)
  An OAuth access token from a machine-to-machine app, for server-to-server calls that need no user session.

Authentication is required. Pass either this header or authtoken, not both. The renderer lists them as separate optional headers, but a request with neither is rejected.
- **authtoken** (optional)
  A Contentstack authtoken, returned by the Log in to your account request on the Content Management API.

Authentication is required. Pass either this header or authorization, not both. The renderer lists them as separate optional headers, but a request with neither is rejected.

An account may hold at most 20 valid authtokens at a time; creating a twenty-first expires the oldest without warning. In an SSO-enabled organization, users who sign in through the identity provider do not receive an authtoken, so only the organization owner and users permitted to bypass SSO can call this API with one.

#### Sample Response

```json
{
  "jobId": "job_7******a-c**f-4**9-9**0-c**********6",
  "paginated": false
}
```

## Status Code

### Status Code

**GET** `/analytics/v2/http-statuses`

The Status Code request counts API requests by the HTTP status they returned, such as 200, 201, 400 or 404, so you can watch error rates alongside volume.

Each row carries status, the HTTP status as a string; type, the service that returned it, such as cma; count, how many requests ended that way; and date, the day they were made.

Pass httpStatusCode to narrow the result to a single status instead of all of them.

#### Query Parameters

- **from** (required)
  Specify the start date for the required data. Use the following date format: YYYY-MM-DD. It cannot be in the future.
- **to** (required)
  Enter the end date for the required data. The date format should be: YYYY-MM-DD. It must be on or after the from date and cannot be in the future.
- **duration** (optional)
  Determines the granularity of the data. Accepted values are sec, minute, hour, day, week, month, year, and historic; any other value returns a 400 error. If you omit duration, the response is not broken down by date.
- **orgUid** (required)
  Enter the UID of your Organization.
- **services** (required)
  Specify the array of services for which you want statistics, such as: \["cma", "ui", "cdn", "graphql", "images", "assets", "automations", "launch", "cs-assets"\]. Pass either a JSON array of service names, for example \["cdn","cma"\], or a single service name on its own, for example automations. A comma-separated list is not supported and returns no data.
- **httpStatusCode** (optional)
  Enter an HTTP status code to filter the response.
- **apiKey** (optional)
  Enter your stack API key to get data for that specific stack.
- **space_uid** (optional)
  Enter a space UID to filter the response to that space, or all to include every space. The value is not case-sensitive. Only available when services is set to cs-assets on its own. Passing it alongside any other service returns a 400 error.
- **subService** (optional)
  Enter all, delivery-api, or management-api to filter the response to one part of the cs-assets service. The value is not case-sensitive; any other value returns a 400 error. Defaults to all. Like space\_uid, it can only be used when services is set to cs-assets on its own.

#### Headers

- **authorization** (optional)
  An OAuth access token from a machine-to-machine app, for server-to-server calls that need no user session.

Authentication is required. Pass either this header or authtoken, not both. The renderer lists them as separate optional headers, but a request with neither is rejected.
- **authtoken** (optional)
  A Contentstack authtoken, returned by the Log in to your account request on the Content Management API.

Authentication is required. Pass either this header or authorization, not both. The renderer lists them as separate optional headers, but a request with neither is rejected.

An account may hold at most 20 valid authtokens at a time; creating a twenty-first expires the oldest without warning. In an SSO-enabled organization, users who sign in through the identity provider do not receive an authtoken, so only the organization owner and users permitted to bypass SSO can call this API with one.

#### Sample Response

```json
{
  "jobId": "job_7******a-c**f-4**9-9**0-c**********6",
  "paginated": false
}
```

## Top URLs

### Top URLs

**GET** `/analytics/v2/url`

The Top URLs request counts requests per URL for the services you name, so you can see which paths carry your traffic.

Each row carries url, the path that was accessed; type, the service that served it, such as cdn; and count, the number of requests. The result also carries urlDataSource, naming the store that answered the query. That value is set by the environment, can differ between requests, and is informational only.

Sort with sortBy, which accepts count or bandwidth, and orderBy, which accepts 1 for ascending or \-1 for descending.

includeTotalCount is ignored when limit is sent.

#### Query Parameters

- **orgUid** (required)
  Enter the UID of your Organization.
- **from** (required)
  Specify the start date for the required data. Use the following date format: YYYY-MM-DD. It cannot be in the future.
- **to** (required)
  Enter the end date for the required data. The date format should be: YYYY-MM-DD. It must be on or after the from date and cannot be in the future.
- **includeTotalCount** (optional)
  Set this parameter to true to include the total number of matching URLs in the response. If you also pass limit, the total is omitted from the response; request a page without limit to get it.
- **duration** (optional)
  Determines the granularity of the data. Accepted values are sec, minute, hour, day, week, month, year, and historic; any other value returns a 400 error. If you omit duration, the response is not broken down by date.
- **services** (optional)
  Specify the array of services for which you want statistics, such as: \["cma", "ui", "cdn", "graphql", "images", "assets", "automations", "launch"\]. Pass either a JSON array of service names, for example \["cdn","cma"\], or a single service name on its own, for example automations. A comma-separated list is not supported and returns no data.
- **apiKey** (optional)
  Enter the API key of the stack.
- **orderBy** (optional)
  Enter 1 to sort the response in ascending order by count or \-1 to sort it in descending order by count. By default, the value is set to \-1, which orders the response in descending order.
- **sortBy** (optional)
  Enter count to rank URLs by number of requests, or bandwidth to rank them by bandwidth consumed. Defaults to count.
- **limit** (optional)
  Specify the number of items you wish to fetch per request. This parameter must be passed together with skip; sending one without the other returns a 400 error. limit also has an upper bound set per environment; exceeding it returns a 400 error rather than a truncated result.
- **skip** (optional)
  Enter the number of items to skip. For example, a skip value of 10 will skip the first 10 items. This parameter must be passed together with limit; sending one without the other returns a 400 error.

#### Headers

- **authorization** (optional)
  An OAuth access token from a machine-to-machine app, for server-to-server calls that need no user session.

Authentication is required. Pass either this header or authtoken, not both. The renderer lists them as separate optional headers, but a request with neither is rejected.
- **authtoken** (optional)
  A Contentstack authtoken, returned by the Log in to your account request on the Content Management API.

Authentication is required. Pass either this header or authorization, not both. The renderer lists them as separate optional headers, but a request with neither is rejected.

An account may hold at most 20 valid authtokens at a time; creating a twenty-first expires the oldest without warning. In an SSO-enabled organization, users who sign in through the identity provider do not receive an authtoken, so only the organization owner and users permitted to bypass SSO can call this API with one.

#### Sample Response

```json
{
  "jobId": "job_7******a-c**f-4**9-9**0-c**********6",
  "paginated": true
}
```