Skip to content
Start here

Create PCAP request

client.MagicTransit.PCAPs.New(ctx, params) (*PCAPNewResponse, error)
POST/accounts/{account_id}/pcaps

Create new PCAP request for 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
Accepted Permissions (at least one required)
Magic Firewall Packet Captures - Write PCAPs API
ParametersExpand Collapse
params PCAPNewParams
AccountID param.Field[string]

Path param: Identifier.

maxLength32
PacketLimit param.Field[float64]

Body param: The limit of packets contained in a packet capture.

maximum10000
minimum1

Body param: The system used to collect packet captures.

const PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleSystemMagicTransit PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleSystem = "magic-transit"
TimeLimit param.Field[float64]

Body param: The packet capture duration in seconds.

maximum300
minimum1

Body param: The type of packet capture. Simple captures sampled packets, and full captures entire payloads and non-sampled packets.

const PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleTypeSimple PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleType = "simple"
const PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleTypeFull PCAPNewParamsMagicVisibilityPCAPsPCAPsRequestSimpleType = "full"
FilterV1 param.Field[PCAPFilter]optional

Body param: The packet capture filter. When this field is empty, all packets are captured.

OffsetTime param.Field[Time]optional

Body param: The RFC 3339 offset timestamp from which to query backwards for packets. Must be within the last 24h. When this field is empty, defaults to time of request.

formatdate-time
ReturnsExpand Collapse
type PCAPNewResponse interface{…}
One of the following:
type PCAP struct{…}
ID stringoptional

The ID for the packet capture.

maxLength32
minLength32
FilterV1 PCAPFilteroptional

The packet capture filter. When this field is empty, all packets are captured.

DestinationAddress stringoptional

The destination IP address of the packet.

DestinationPort float64optional

The destination port of the packet.

Protocol float64optional

The protocol number of the packet.

SourceAddress stringoptional

The source IP address of the packet.

SourcePort float64optional

The source port of the packet.

OffsetTime Timeoptional

The RFC 3339 offset timestamp from which to query backwards for packets. Must be within the last 24h. When this field is empty, defaults to time of request.

formatdate-time
Status PCAPStatusoptional

The status of the packet capture request.

One of the following:
const PCAPStatusUnknown PCAPStatus = "unknown"
const PCAPStatusSuccess PCAPStatus = "success"
const PCAPStatusPending PCAPStatus = "pending"
const PCAPStatusRunning PCAPStatus = "running"
const PCAPStatusConversionPending PCAPStatus = "conversion_pending"
const PCAPStatusConversionRunning PCAPStatus = "conversion_running"
const PCAPStatusComplete PCAPStatus = "complete"
const PCAPStatusFailed PCAPStatus = "failed"
Submitted stringoptional

The RFC 3339 timestamp when the packet capture was created.

System PCAPSystemoptional

The system used to collect packet captures.

TimeLimit float64optional

The packet capture duration in seconds.

maximum300
minimum1
Type PCAPTypeoptional

The type of packet capture. Simple captures sampled packets, and full captures entire payloads and non-sampled packets.

One of the following:
const PCAPTypeSimple PCAPType = "simple"
const PCAPTypeFull PCAPType = "full"
type PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFull struct{…}
ID stringoptional

The ID for the packet capture.

maxLength32
minLength32
ByteLimit float64optional

The maximum number of bytes to capture. This field only applies to full packet captures.

maximum1000000000
minimum1
ColoName stringoptional

The name of the data center used for the packet capture. This can be a specific colo (ord02) or a multi-colo name (ORD). This field only applies to full packet captures.

DestinationConf stringoptional

The full URI for the bucket. This field only applies to full packet captures.

ErrorMessage stringoptional

An error message that describes why the packet capture failed. This field only applies to full packet captures.

FilterV1 PCAPFilteroptional

The packet capture filter. When this field is empty, all packets are captured.

DestinationAddress stringoptional

The destination IP address of the packet.

DestinationPort float64optional

The destination port of the packet.

Protocol float64optional

The protocol number of the packet.

SourceAddress stringoptional

The source IP address of the packet.

SourcePort float64optional

The source port of the packet.

PacketsCaptured int64optional

The number of packets captured.

Status PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusoptional

The status of the packet capture request.

One of the following:
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusUnknown PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "unknown"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusSuccess PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "success"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusPending PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "pending"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusRunning PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "running"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionPending PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_pending"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusConversionRunning PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "conversion_running"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusComplete PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "complete"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatusFailed PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullStatus = "failed"
StopRequested Timeoptional

The RFC 3339 timestamp when stopping the packet capture was requested. This field only applies to full packet captures.

formatdate-time
Submitted stringoptional

The RFC 3339 timestamp when the packet capture was created.

System PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullSystemoptional

The system used to collect packet captures.

TimeLimit float64optional

The packet capture duration in seconds.

maximum86400
minimum1
Type PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullTypeoptional

The type of packet capture. Simple captures sampled packets, and full captures entire payloads and non-sampled packets.

One of the following:
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullTypeSimple PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullType = "simple"
const PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullTypeFull PCAPNewResponseMagicVisibilityPCAPsPCAPsResponseFullType = "full"

Create PCAP request

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/magic_transit"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  pcap, err := client.MagicTransit.PCAPs.New(context.TODO(), magic_transit.PCAPNewParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Body: magic_transit.PCAPNewParamsBodyMagicVisibilityPCAPsPCAPsRequestSimple{
      PacketLimit: cloudflare.F(10000.000000),
      System: cloudflare.F(magic_transit.PCAPNewParamsBodyMagicVisibilityPCAPsPCAPsRequestSimpleSystemMagicTransit),
      TimeLimit: cloudflare.F(300.000000),
      Type: cloudflare.F(magic_transit.PCAPNewParamsBodyMagicVisibilityPCAPsPCAPsRequestSimpleTypeSimple),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", pcap)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "66802ca5668e47a2b82c2e6746e45037",
    "filter_v1": {
      "destination_address": "1.2.3.4",
      "destination_port": 80,
      "protocol": 6,
      "source_address": "1.2.3.4",
      "source_port": 123
    },
    "offset_time": "2020-01-01T08:00:00Z",
    "status": "success",
    "submitted": "2020-01-01T08:00:00Z",
    "system": "magic-transit",
    "time_limit": 300,
    "type": "simple"
  },
  "success": true
}
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"
      }
    }
  ],
  "result": {
    "id": "66802ca5668e47a2b82c2e6746e45037",
    "filter_v1": {
      "destination_address": "1.2.3.4",
      "destination_port": 80,
      "protocol": 6,
      "source_address": "1.2.3.4",
      "source_port": 123
    },
    "offset_time": "2020-01-01T08:00:00Z",
    "status": "success",
    "submitted": "2020-01-01T08:00:00Z",
    "system": "magic-transit",
    "time_limit": 300,
    "type": "simple"
  },
  "success": true
}