---
title: "Streams"
description: "<p>Get metrics and events for data streams in your Lytics account.</p>"
url: "https://www.contentstack.com/docs/developers/apis/lytics-api/streams"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-05"
---

# Streams

Get metrics and events for data streams in your Lytics account.

## List Streams

### List Streams

**GET** `/v2/stream`

List all streams in the account

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "account_id": "string",
      "aid": 0,
      "anomaly_rule": {
        "aid": 0,
        "checks": [
          {
            "allowable_violations": 0,
            "interval": "string",
            "lookback_count": 0,
            "max_threshold": 0,
            "metric_type": "string",
            "min_threshold": 0,
            "type": "string",
            "variance_pct": 0
          }
        ],
        "created": "string",
        "id": "string",
        "subject_id": "string",
        "subject_type": "string",
        "updated": "string"
      },
      "avg_event_size": 0,
      "channel": "string",
      "count": 0,
      "created": "2019-08-24T14:15:22Z",
      "description": "string",
      "hidden": true,
      "id": "string",
      "internal": true,
      "jobs": [
        "string"
      ],
      "label": "string",
      "last_msg_ts": "2019-08-24T14:15:22Z",
      "last_received_ts": "2019-08-24T14:15:22Z",
      "last_update_ts": "2019-08-24T14:15:22Z",
      "method": "string",
      "name": "string",
      "providers": [
        "string"
      ],
      "slug": "string",
      "tables": [
        "string"
      ],
      "updated": "2019-08-24T14:15:22Z"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## List Stream rules

### List Stream rules

**GET** `/v2/stream/rule`

List all stream rules in the account

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "account_id": "string",
      "active": true,
      "aid": 0,
      "created": "string",
      "expression": "string",
      "id": "string",
      "input": "string",
      "modified": "string",
      "name": "string",
      "output": "string",
      "priority": 0
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Create stream rule

### Create stream rule

**POST** `/v2/stream/rule`

Create a stream rule

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "active": true,
    "aid": 0,
    "created": "string",
    "expression": "string",
    "id": "string",
    "input": "string",
    "modified": "string",
    "name": "string",
    "output": "string",
    "priority": 0
  },
  "request_id": "string",
  "status": 0
}
```

## Get Stream rule

### Get Stream rule

**GET** `/v2/stream/rule/{id}`

Get stream rule by id

#### URL Parameters

- **id** (required)
  Stream rule id

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "active": true,
    "aid": 0,
    "created": "string",
    "expression": "string",
    "id": "string",
    "input": "string",
    "modified": "string",
    "name": "string",
    "output": "string",
    "priority": 0
  },
  "request_id": "string",
  "status": 0
}
```

## Update stream rule

### Update stream rule

**POST** `/v2/stream/rule/{id}`

Update a stream rule

#### URL Parameters

- **id** (required)
  Stream rule id to update

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "active": true,
    "aid": 0,
    "created": "string",
    "expression": "string",
    "id": "string",
    "input": "string",
    "modified": "string",
    "name": "string",
    "output": "string",
    "priority": 0
  },
  "request_id": "string",
  "status": 0
}
```

## Update stream rule

### Update stream rule

**PUT** `/v2/stream/rule/{id}`

Update a stream rule

#### URL Parameters

- **id** (required)
  Stream rule id to update

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "active": true,
    "aid": 0,
    "created": "string",
    "expression": "string",
    "id": "string",
    "input": "string",
    "modified": "string",
    "name": "string",
    "output": "string",
    "priority": 0
  },
  "request_id": "string",
  "status": 0
}
```

## Delete stream rule

### Delete stream rule

**DELETE** `/v2/stream/rule/{id}`

Delete stream rule by id

#### URL Parameters

- **id** (required)
  Stream rule id

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "active": true,
    "aid": 0,
    "created": "string",
    "expression": "string",
    "id": "string",
    "input": "string",
    "modified": "string",
    "name": "string",
    "output": "string",
    "priority": 0
  },
  "request_id": "string",
  "status": 0
}
```

## Get Stream

### Get Stream

**GET** `/v2/stream/{name}`

Get stream by name

#### URL Parameters

- **name** (required)
  The Stream Name

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "aid": 0,
    "anomaly_rule": {
      "aid": 0,
      "checks": [
        {
          "allowable_violations": 0,
          "interval": "string",
          "lookback_count": 0,
          "max_threshold": 0,
          "metric_type": "string",
          "min_threshold": 0,
          "type": "string",
          "variance_pct": 0
        }
      ],
      "created": "string",
      "id": "string",
      "subject_id": "string",
      "subject_type": "string",
      "updated": "string"
    },
    "avg_event_size": 0,
    "channel": "string",
    "count": 0,
    "created": "2019-08-24T14:15:22Z",
    "description": "string",
    "hidden": true,
    "id": "string",
    "internal": true,
    "jobs": [
      "string"
    ],
    "label": "string",
    "last_msg_ts": "2019-08-24T14:15:22Z",
    "last_received_ts": "2019-08-24T14:15:22Z",
    "last_update_ts": "2019-08-24T14:15:22Z",
    "method": "string",
    "name": "string",
    "providers": [
      "string"
    ],
    "slug": "string",
    "tables": [
      "string"
    ],
    "updated": "2019-08-24T14:15:22Z"
  },
  "request_id": "string",
  "status": 0
}
```

## Get Stream Events

### Get Stream Events

**GET** `/v2/stream/{name}/events`

Get a list of recent events in the stream

#### URL Parameters

- **name** (required)
  The Stream Name

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {}
  ],
  "request_id": "string",
  "status": 0
}
```

## Get Stream Stats

### Get Stream Stats

**GET** `/v2/stream/{name}/stats`

Get stats for all fields in the stream

#### URL Parameters

- **name** (required)
  The Stream Name

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "avg": 0,
      "card": 0,
      "columns": [
        {
          "as": "string",
          "table": "string"
        }
      ],
      "first_seen": "2019-08-24T14:15:22Z",
      "hidden": true,
      "is_array": true,
      "last_seen": "string",
      "name": "string",
      "sample": [
        "string"
      ],
      "sumlen": 0,
      "type": "string",
      "usage": 0
    }
  ],
  "request_id": "string",
  "status": 0
}
```