# Log Explorer # Query ## Run a log query `client.logs.logExplorer.query.sql(QuerySqlParamsparams, RequestOptionsoptions?): SinglePage` **post** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/query/sql` Run a SQL query against account or zone-level datasets. Timestamp fields are RFC3339 strings. Filter with: WHERE {timestamp_field} >= now() - INTERVAL '30' DAY WHERE {timestamp_field} >= '2026-04-01T00:00:00Z' WHERE {timestamp_field} BETWEEN '2026-04-01T00:00:00Z' AND '2026-04-30T23:59:59Z' List configured account or zone datasets to see enabled account or zone-level datasets. Zone-level datasets will not appear here. List available account or zone datasets to inspect their schemas and timestamp fields. For more information about the datasets, and the meaning of each field, check out https://developers.cloudflare.com/logs/logpush/logpush-job/datasets/ ### Parameters - `params: QuerySqlParams` - `body: Uploadable` Body param: SQL query to execute. - `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. ### Returns - `QuerySqlResponse = Record` ### Example ```typescript import fs from 'fs'; import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const querySqlResponse of client.logs.logExplorer.query.sql({ body: fs.createReadStream('path/to/file'), account_id: 'account_id', })) { console.log(querySqlResponse); } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true, "result": [ { "foo": "bar" } ] } ``` ## Domain Types ### Query Sql Response - `QuerySqlResponse = Record` # Datasets ## List account or zone datasets `client.logs.logExplorer.datasets.list(DatasetListParamsparams?, RequestOptionsoptions?): SinglePage` **get** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets` Returns all Log Explorer datasets configured for the account or zone. Pass `include_zones=true` to also include zone-level datasets that belong to this account or zone. List responses omit the `fields` property; use the single-dataset endpoint to retrieve field configuration. ### Parameters - `params: DatasetListParams` - `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. - `include_zones?: boolean` Query param: Set to true to include zone-scoped datasets belonging to this account. ### Returns - `DatasetSummary` 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. - `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. - `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. - `"account"` - `"zone"` - `updated_at: string` RFC3339 timestamp recording when the API last updated this dataset. ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const datasetSummary of client.logs.logExplorer.datasets.list({ account_id: 'account_id', })) { console.log(datasetSummary.dataset_id); } ``` #### Response ```json { "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, "object_id": "object_id", "object_type": "account", "updated_at": "2019-12-27T18:11:19.117Z" } ] } ``` ## Get an account or zone dataset `client.logs.logExplorer.datasets.get(stringdatasetID, DatasetGetParamsparams?, RequestOptionsoptions?): Dataset` **get** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets/{dataset_id}` Retrieve a single Log Explorer dataset by ID for the account or zone. ### Parameters - `datasetID: string` - `params: DatasetGetParams` - `account_id?: string` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `zone_id?: string` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `Dataset` 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. - `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` 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. - `"account"` - `"zone"` - `updated_at: string` RFC3339 timestamp recording when the API last updated this dataset. - `filter?: string` The Logpush filter predicate applied to this dataset. Omitted when no filter is set. ### Example ```typescript 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.get('dataset_id', { account_id: 'account_id', }); console.log(dataset.dataset_id); ``` #### Response ```json { "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" } } ``` ## Create an account or zone dataset `client.logs.logExplorer.datasets.create(DatasetCreateParamsparams, RequestOptionsoptions?): Dataset` **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/ ### Parameters - `params: DatasetCreateParams` - `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` 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](https://developers.cloudflare.com/logs/reference/filters/) for syntax and examples. ### Returns - `Dataset` 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. - `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` 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. - `"account"` - `"zone"` - `updated_at: string` RFC3339 timestamp recording when the API last updated this dataset. - `filter?: string` The Logpush filter predicate applied to this dataset. Omitted when no filter is set. ### Example ```typescript 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); ``` #### Response ```json { "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" } } ``` ## Update an account or zone dataset `client.logs.logExplorer.datasets.update(stringdatasetID, DatasetUpdateParamsparams, RequestOptionsoptions?): Dataset` **put** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets/{dataset_id}` Updates the enabled state and/or field configuration of an account or zone dataset. ### Parameters - `datasetID: string` - `params: DatasetUpdateParams` - `enabled: boolean` Body param: Whether to enable or disable log ingest for this dataset. - `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. - `deletion_protection?: boolean` Body param: Set to `false` to allow deletion of this dataset. - `fields?: Array` Body param: Controls which fields the API ingests after the update. 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 | null` Body param: Optional Logpush filter predicate to restrict which events are ingested. If omitted, the existing filter is left unchanged. Set to an empty string (`""`) to clear the filter. Otherwise, replaces the dataset's filter entirely. See [Logpush filters](https://developers.cloudflare.com/logs/reference/filters/) for syntax and examples. ### Returns - `Dataset` 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. - `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` 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. - `"account"` - `"zone"` - `updated_at: string` RFC3339 timestamp recording when the API last updated this dataset. - `filter?: string` The Logpush filter predicate applied to this dataset. Omitted when no filter is set. ### Example ```typescript 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.update('dataset_id', { enabled: true, account_id: 'account_id', }); console.log(dataset.dataset_id); ``` #### Response ```json { "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" } } ``` ## Delete an account or zone dataset `client.logs.logExplorer.datasets.delete(stringdatasetID, DatasetDeleteParamsparams?, RequestOptionsoptions?): Dataset` **delete** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets/{dataset_id}` Deletes a Log Explorer dataset for the account or zone. Dataset deletion must not be protected. ### Parameters - `datasetID: string` - `params: DatasetDeleteParams` - `account_id?: string` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `zone_id?: string` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `Dataset` 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. - `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` 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. - `"account"` - `"zone"` - `updated_at: string` RFC3339 timestamp recording when the API last updated this dataset. - `filter?: string` The Logpush filter predicate applied to this dataset. Omitted when no filter is set. ### Example ```typescript 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.delete('dataset_id', { account_id: 'account_id', }); console.log(dataset.dataset_id); ``` #### Response ```json { "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" } } ``` ## Domain Types ### Create Request - `CreateRequest` - `dataset: string` Dataset type name to create (e.g. `http_requests`). - `fields?: Array` 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` Optional Logpush filter predicate to restrict which events are ingested. If provided, replaces the dataset's default filter entirely. See [Logpush filters](https://developers.cloudflare.com/logs/reference/filters/) for syntax and examples. ### Dataset - `Dataset` 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. - `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` 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. - `"account"` - `"zone"` - `updated_at: string` RFC3339 timestamp recording when the API last updated this dataset. - `filter?: string` The Logpush filter predicate applied to this dataset. Omitted when no filter is set. ### Dataset Summary - `DatasetSummary` 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. - `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. - `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. - `"account"` - `"zone"` - `updated_at: string` RFC3339 timestamp recording when the API last updated this dataset. ### Update Request - `UpdateRequest` - `enabled: boolean` Whether to enable or disable log ingest for this dataset. - `deletion_protection?: boolean` Set to `false` to allow deletion of this dataset. - `fields?: Array` Controls which fields the API ingests after the update. 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 | null` Optional Logpush filter predicate to restrict which events are ingested. If omitted, the existing filter is left unchanged. Set to an empty string (`""`) to clear the filter. Otherwise, replaces the dataset's filter entirely. See [Logpush filters](https://developers.cloudflare.com/logs/reference/filters/) for syntax and examples. # Available ## List available account or zone datasets `client.logs.logExplorer.datasets.available.list(AvailableListParamsparams?, RequestOptionsoptions?): SinglePage` **get** `/{accounts_or_zones}/{account_or_zone_id}/logs/explorer/datasets/available` Returns all dataset types that this account or zone can create. Each entry includes the dataset schema and timestamp field. The schema shows all possible fields for a dataset. However, not all fields may be available for your account or zone. When creating or updating a dataset, only fields available to your account or zone can be enabled. If you request a field that is not available, you will receive an error. ### Parameters - `params: AvailableListParams` - `account_id?: string` The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - `zone_id?: string` The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ### Returns - `AvailableDataset` A dataset type that the account or zone can create. - `dataset: string` Dataset type name (e.g. `http_requests`). - `object_type: "account" | "zone"` Whether this dataset type is account-scoped or zone-scoped. - `"account"` - `"zone"` - `schema: Schema` JSON Schema that describes the fields this dataset exposes. - `properties?: Record` - `required?: Array` - `type?: "object"` - `"object"` - `timestamp_field: string` The primary timestamp field name for this dataset. ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const availableDataset of client.logs.logExplorer.datasets.available.list({ account_id: 'account_id', })) { console.log(availableDataset.dataset); } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ "string" ], "success": true, "result": [ { "dataset": "dataset", "object_type": "account", "schema": { "properties": { "foo": "bar" }, "required": [ "string" ], "type": "object" }, "timestamp_field": "timestamp_field" } ] } ``` ## Domain Types ### Available Dataset - `AvailableDataset` A dataset type that the account or zone can create. - `dataset: string` Dataset type name (e.g. `http_requests`). - `object_type: "account" | "zone"` Whether this dataset type is account-scoped or zone-scoped. - `"account"` - `"zone"` - `schema: Schema` JSON Schema that describes the fields this dataset exposes. - `properties?: Record` - `required?: Array` - `type?: "object"` - `"object"` - `timestamp_field: string` The primary timestamp field name for this dataset. ### Available List - `AvailableList` - `errors: Array` - `code: number` - `message: string` - `documentation_url?: string` - `source?: Source` - `pointer?: string` - `messages: Array` - `success: boolean` - `result?: Array | null` - `dataset: string` Dataset type name (e.g. `http_requests`). - `object_type: "account" | "zone"` Whether this dataset type is account-scoped or zone-scoped. - `"account"` - `"zone"` - `schema: Schema` JSON Schema that describes the fields this dataset exposes. - `properties?: Record` - `required?: Array` - `type?: "object"` - `"object"` - `timestamp_field: string` The primary timestamp field name for this dataset.