---
title: "DataModels"
description: "<p>Create and manage data models and their record stores.</p>"
url: "https://www.contentstack.com/docs/developers/apis/lytics-api/datamodels"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-05"
---

# DataModels

Create and manage data models and their record stores.

## Get recordstore size for a list of datamodel

### Get recordstore size for a list of datamodel

**GET** `/v2/data/datamodel/size`

Get recordstore size for a list of datamodel

#### Query Parameters

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

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "id": "string",
      "name": "string",
      "record_store_size": 0,
      "slug_name": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Get recordstore size for a datamodel

### Get recordstore size for a datamodel

**GET** `/v2/data/datamodel/{id}/size`

Get recordstore size for a datamodel

#### URL Parameters

- **id** (required)
  The datamodel ID

#### Query Parameters

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

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "id": "string",
    "name": "string",
    "record_store_size": 0,
    "slug_name": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Get datamodels

### Get datamodels

**GET** `/v2/datamodel`

Get a list of all datamodels for the account

#### Query Parameters

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

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "account_id": "string",
      "activated_fields": [
        "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"
      },
      "author_id": "string",
      "connection_id": "string",
      "contextual_data": [
        "string"
      ],
      "create_profiles": true,
      "created": "string",
      "deleted": true,
      "description": "string",
      "health": {
        "details": "string",
        "status": "string"
      },
      "id": "string",
      "is_draft": true,
      "joined_to": {
        "foreign_key": "string",
        "foreign_table": "string",
        "primary_key": "string"
      },
      "name": "string",
      "needs_backfill": true,
      "primary_keys": [
        "string"
      ],
      "schedule": {
        "next_sync_time": "string",
        "prev_sync_time": "string",
        "sync_period": 0
      },
      "size": 0,
      "slug": "string",
      "sql": "string",
      "status": "string",
      "sync_errors": [
        {
          "error": "string",
          "time": "string"
        }
      ],
      "table": "string",
      "updated": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Create datamodel

### Create datamodel

**POST** `/v2/datamodel`

Create a datamodel

#### 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",
    "activated_fields": [
      "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"
    },
    "author_id": "string",
    "connection_id": "string",
    "contextual_data": [
      "string"
    ],
    "create_profiles": true,
    "created": "string",
    "deleted": true,
    "description": "string",
    "health": {
      "details": "string",
      "status": "string"
    },
    "id": "string",
    "is_draft": true,
    "joined_to": {
      "foreign_key": "string",
      "foreign_table": "string",
      "primary_key": "string"
    },
    "name": "string",
    "needs_backfill": true,
    "primary_keys": [
      "string"
    ],
    "schedule": {
      "next_sync_time": "string",
      "prev_sync_time": "string",
      "sync_period": 0
    },
    "size": 0,
    "slug": "string",
    "sql": "string",
    "status": "string",
    "sync_errors": [
      {
        "error": "string",
        "time": "string"
      }
    ],
    "table": "string",
    "updated": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Delete datamodels

### Delete datamodels

**DELETE** `/v2/datamodel`

Delete multiple datamodels

#### Query Parameters

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

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "deleted": true,
      "id": "string",
      "reason": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Get datamodel

### Get datamodel

**GET** `/v2/datamodel/{id}`

Get a datamodel by ID

#### URL Parameters

- **id** (required)
  The datamodel ID

#### Query Parameters

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

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "activated_fields": [
      "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"
    },
    "author_id": "string",
    "connection_id": "string",
    "contextual_data": [
      "string"
    ],
    "create_profiles": true,
    "created": "string",
    "deleted": true,
    "description": "string",
    "health": {
      "details": "string",
      "status": "string"
    },
    "id": "string",
    "is_draft": true,
    "joined_to": {
      "foreign_key": "string",
      "foreign_table": "string",
      "primary_key": "string"
    },
    "name": "string",
    "needs_backfill": true,
    "primary_keys": [
      "string"
    ],
    "schedule": {
      "next_sync_time": "string",
      "prev_sync_time": "string",
      "sync_period": 0
    },
    "size": 0,
    "slug": "string",
    "sql": "string",
    "status": "string",
    "sync_errors": [
      {
        "error": "string",
        "time": "string"
      }
    ],
    "table": "string",
    "updated": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Update datamodel

### Update datamodel

**PUT** `/v2/datamodel/{id}`

Update a datamodel

#### URL Parameters

- **id** (required)
  The datamodel 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",
    "activated_fields": [
      "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"
    },
    "author_id": "string",
    "connection_id": "string",
    "contextual_data": [
      "string"
    ],
    "create_profiles": true,
    "created": "string",
    "deleted": true,
    "description": "string",
    "health": {
      "details": "string",
      "status": "string"
    },
    "id": "string",
    "is_draft": true,
    "joined_to": {
      "foreign_key": "string",
      "foreign_table": "string",
      "primary_key": "string"
    },
    "name": "string",
    "needs_backfill": true,
    "primary_keys": [
      "string"
    ],
    "schedule": {
      "next_sync_time": "string",
      "prev_sync_time": "string",
      "sync_period": 0
    },
    "size": 0,
    "slug": "string",
    "sql": "string",
    "status": "string",
    "sync_errors": [
      {
        "error": "string",
        "time": "string"
      }
    ],
    "table": "string",
    "updated": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Delete datamodel

### Delete datamodel

**DELETE** `/v2/datamodel/{id}`

Delete a datamodel

#### URL Parameters

- **id** (required)
  The datamodel ID

#### 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 datamodel logs

### Get datamodel logs

**GET** `/v2/datamodel/{id}/logs`

Get datamodel logs

#### URL Parameters

- **id** (required)
  The datamodel ID

#### Query Parameters

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

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "id": "string",
      "message": "string",
      "timestamp": "2019-08-24T14:15:22Z",
      "verb": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Run a sync job for a datamodel

### Run a sync job for a datamodel

**GET** `/v2/datamodel/{id}/sync/{state}`

Run a sync job for a datamodel

#### URL Parameters

- **id** (required)
  The datamodel ID or slug
- **state** (required)
  Start or stop

#### 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",
    "activated_fields": [
      "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"
    },
    "author_id": "string",
    "connection_id": "string",
    "contextual_data": [
      "string"
    ],
    "create_profiles": true,
    "created": "string",
    "deleted": true,
    "description": "string",
    "health": {
      "details": "string",
      "status": "string"
    },
    "id": "string",
    "is_draft": true,
    "joined_to": {
      "foreign_key": "string",
      "foreign_table": "string",
      "primary_key": "string"
    },
    "name": "string",
    "needs_backfill": true,
    "primary_keys": [
      "string"
    ],
    "schedule": {
      "next_sync_time": "string",
      "prev_sync_time": "string",
      "sync_period": 0
    },
    "size": 0,
    "slug": "string",
    "sql": "string",
    "status": "string",
    "sync_errors": [
      {
        "error": "string",
        "time": "string"
      }
    ],
    "table": "string",
    "updated": "string"
  },
  "request_id": "string",
  "status": 0
}
```