Skip to main content

Overview

Cloudflare Logpush sends logs of HTTP requests, Spectrum events, firewall events, and more to cloud storage destinations. Use the Logpush API to manage jobs, validate destinations, and configure log fields.

Initialize the client

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: 'your-api-token',
});

Jobs

Manage Logpush jobs.

Create a job

Create a new Logpush job.
const job = await client.logpush.jobs.create({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  destination_conf: 's3://bucket/path?region=us-west-2',
  dataset: 'http_requests',
  logpull_options: 'fields=ClientIP,EdgeStartTimestamp',
});
account_id
string
required
Account identifier (use zone_id for zone-scoped jobs)
destination_conf
string
required
Destination configuration string (e.g., S3 bucket URL with credentials)
dataset
string
required
Dataset to push (e.g., http_requests, firewall_events, spectrum_events)
logpull_options
string
Configuration string specifying fields to include and other options
enabled
boolean
Whether the job is enabled (default: true)
frequency
string
How often logs are pushed (e.g., high, low)
name
string
Job name
id
number
Job identifier
enabled
boolean
Whether the job is active
destination_conf
string
Destination configuration

Update a job

Update an existing Logpush job.
const job = await client.logpush.jobs.update(
  jobId,
  {
    account_id: '023e105f4ecef8ad9ca31a8372d0c353',
    enabled: false,
  }
);

List jobs

List all Logpush jobs.
const jobs = await client.logpush.jobs.list({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
});

Get a job

Get details of a specific Logpush job.
const job = await client.logpush.jobs.get(
  jobId,
  { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }
);

Delete a job

Delete a Logpush job.
await client.logpush.jobs.delete(
  jobId,
  { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }
);

Ownership

Manage ownership validation for Logpush destinations.

Create ownership challenge

Generate an ownership challenge for a destination.
const challenge = await client.logpush.ownership.create({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  destination_conf: 's3://bucket/path?region=us-west-2',
});
destination_conf
string
required
Destination configuration to validate
filename
string
Name of the file to upload for validation
message
string
Contents to include in the validation file
valid
boolean
Whether the ownership is already validated

Validate ownership

Validate ownership of a destination.
const result = await client.logpush.ownership.validate({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  destination_conf: 's3://bucket/path?region=us-west-2',
  ownership_challenge: 'challenge-token',
});
destination_conf
string
required
Destination configuration
ownership_challenge
string
required
Ownership challenge token

Validate

Validate Logpush destinations and origin configurations.

Validate destination

Check if a destination configuration is valid.
const result = await client.logpush.validate.destination({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  destination_conf: 's3://bucket/path?region=us-west-2',
  logpull_options: 'fields=ClientIP,EdgeStartTimestamp',
});

Check if destination exists

Check if a destination exists and is accessible.
const result = await client.logpush.validate.destinationExists({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  destination_conf: 's3://bucket/path?region=us-west-2',
});

Validate origin

Validate origin configuration for Logpush.
const result = await client.logpush.validate.origin(params);

Datasets

Get information about available datasets.
const datasets = client.logpush.datasets;
The datasets resource provides methods to retrieve information about available log datasets and their fields.

Edge

Manage instant Logpush jobs for edge locations.
const edge = client.logpush.edge;
Instant Logpush jobs provide on-demand access to logs from specific edge locations.

Create instant job

const job = await client.logpush.edge.create({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  // configuration
});

Get instant job

const job = await client.logpush.edge.get(
  jobId,
  { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }
);

Types

LogpushJob

id
number
Job identifier
enabled
boolean
Whether the job is active
name
string
Job name
dataset
string
Dataset being pushed
destination_conf
string
Destination configuration
logpull_options
string
Log field and option configuration
frequency
string
Push frequency
last_complete
string
Timestamp of last successful push
last_error
string
Timestamp of last error

OutputOptions

Output formatting options for logs.
field_delimiter
string
Delimiter between fields
record_delimiter
string
Delimiter between records
timestamp_format
string
Format for timestamps

Build docs developers (and LLMs) love