Skip to content
Start here

Create account commands

client.zeroTrust.dex.commands.create(CommandCreateParams { account_id, commands } params, RequestOptionsoptions?): CommandCreateResponse { commands }
POST/accounts/{account_id}/dex/commands

Initiate commands for up to 10 devices per account.

Security
API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
User Service Key

Used when interacting with the Origin CA certificates API. View/change your key.

Example:X-Auth-User-Service-Key: v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719
Accepted Permissions (at least one required)
Cloudflare DEX Write
ParametersExpand Collapse
params: CommandCreateParams { account_id, commands }
account_id: string

Path param: Unique identifier linked to an account.

maxLength32
commands: Array<Command>

Body param: List of device-level commands to execute

device_id: string

Unique identifier for the physical device

type: "pcap" | "speed-test" | "warp-diag"

Type of command to execute on the device

One of the following:
"pcap"
"speed-test"
"warp-diag"
user_email: string

Email tied to the device

args?: WARPDiagArgs { test-all-routes } | PCAPArgs { max-file-size-mb, packet-size-bytes, time-limit-min } | SpeedTestArgs { interfaces }

Command arguments. Allowed fields depend on type.

One of the following:
WARPDiagArgs { test-all-routes }
"test-all-routes"?: boolean

Test an IP address from all included or excluded ranges. Essentially the same as running ‘route get ’ and collecting the results. This option may increase the time taken to collect the warp-diag.

PCAPArgs { max-file-size-mb, packet-size-bytes, time-limit-min }
"max-file-size-mb"?: number

Maximum file size (in MB) for the capture file. If the capture artifact exceeds the specified max file size, it will NOT be uploaded.

minimum1
"packet-size-bytes"?: number

Maximum number of bytes to save for each packet

minimum1
"time-limit-min"?: number

Limit on capture duration (in minutes)

minimum1
SpeedTestArgs { interfaces }
interfaces?: Array<"default" | "tunnel">

List of interfaces to run the speed test on

One of the following:
"default"
"tunnel"
registration_id?: string

Unique identifier for the device registration. Required for multi-user devices to target the correct user session.

ReturnsExpand Collapse
CommandCreateResponse { commands }
commands?: Array<Command>

List of created commands

id?: string

Unique identifier for the command

args?: Record<string, string>

Command arguments

device_id?: string

Identifier for the device associated with the command

registration_id?: string

Unique identifier for the device registration

status?: "PENDING_EXEC" | "PENDING_UPLOAD" | "SUCCESS" | "FAILED"

Current status of the command

One of the following:
"PENDING_EXEC"
"PENDING_UPLOAD"
"SUCCESS"
"FAILED"
type?: string

Type of the command (e.g., “pcap”, “speed-test”, or “warp-diag”)

Create account commands

import Cloudflare from 'cloudflare';

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

const command = await client.zeroTrust.dex.commands.create({
  account_id: '01a7362d577a6c3019a474fd6f485823',
  commands: [
    {
      device_id: 'device_id',
      type: 'pcap',
      user_email: 'user_email',
    },
  ],
});

console.log(command.commands);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "commands": [
      {
        "id": "id",
        "args": {
          "foo": "string"
        },
        "device_id": "device_id",
        "registration_id": "registration_id",
        "status": "PENDING_EXEC",
        "type": "type"
      }
    ]
  },
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "commands": [
      {
        "id": "id",
        "args": {
          "foo": "string"
        },
        "device_id": "device_id",
        "registration_id": "registration_id",
        "status": "PENDING_EXEC",
        "type": "type"
      }
    ]
  },
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}