Skip to content
Start here

Create an account or zone dataset

client.logs.logExplorer.datasets.create(DatasetCreateParams { dataset, account_id, zone_id, 2 more } params, RequestOptionsoptions?): Dataset { created_at, dataset, dataset_id, 7 more }
POST/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets

Create a new Log Explorer dataset for the account or zone.

List available account or zone datasets to see the dataset types and fields you can use.

The fields property is optional. If not specified, all available fields will be enabled.

For dataset field definitions, see: https://developers.cloudflare.com/logs/logpush/logpush-job/datasets/

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Logs Write
ParametersExpand Collapse
params: DatasetCreateParams { dataset, account_id, zone_id, 2 more }
dataset: string

Body param: Dataset type name to create (e.g. http_requests).

account_id?: string

Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id?: string

Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

fields?: Array<Field>

Body param: Controls which fields the API ingests. Defaults to all available fields when absent.

enabled: boolean

Whether the API includes this field in log ingest.

name: string

Field name in lowercase.

filter?: string

Body param: Optional Logpush filter predicate to restrict which events are ingested. If provided, replaces the dataset’s default filter entirely. See Logpush filters for syntax and examples.

ReturnsExpand Collapse
Dataset { created_at, dataset, dataset_id, 7 more }

A Log Explorer dataset summary. List endpoints return this type and omit field configuration; use the single-dataset endpoint to retrieve it.

created_at: string

RFC3339 timestamp recording when the API created this dataset.

formatdate-time
dataset: string

Dataset type name (e.g. http_requests).

dataset_id: string

Unique dataset ID.

deletion_protection: boolean

Whether deletion is blocked. Set to false before deleting the dataset.

enabled: boolean

Whether log ingest is currently active for this dataset.

fields: Array<Field>

The field configuration for this dataset.

enabled: boolean

Whether the API includes this field in log ingest.

name: string

Field name in lowercase.

object_id: string

Public ID of the account or zone that owns this dataset.

object_type: "account" | "zone"

Whether this dataset belongs to an account or a zone.

One of the following:
"account"
"zone"
updated_at: string

RFC3339 timestamp recording when the API last updated this dataset.

formatdate-time
filter?: string

The Logpush filter predicate applied to this dataset. Omitted when no filter is set.

Create an account or zone dataset

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const dataset = await client.logs.logExplorer.datasets.create({
  dataset: 'dataset',
  account_id: 'account_id',
});

console.log(dataset.dataset_id);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "success": true,
  "result": {
    "created_at": "2019-12-27T18:11:19.117Z",
    "dataset": "dataset",
    "dataset_id": "dataset_id",
    "deletion_protection": true,
    "enabled": true,
    "fields": [
      {
        "enabled": true,
        "name": "name"
      }
    ],
    "object_id": "object_id",
    "object_type": "account",
    "updated_at": "2019-12-27T18:11:19.117Z",
    "filter": "filter"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "success": true,
  "result": {
    "created_at": "2019-12-27T18:11:19.117Z",
    "dataset": "dataset",
    "dataset_id": "dataset_id",
    "deletion_protection": true,
    "enabled": true,
    "fields": [
      {
        "enabled": true,
        "name": "name"
      }
    ],
    "object_id": "object_id",
    "object_type": "account",
    "updated_at": "2019-12-27T18:11:19.117Z",
    "filter": "filter"
  }
}