Collect PCAPs
Last updated Apr 17, 2026
After a packet capture is requested and the capture is collected, the output is contained within one or more files in PCAP file format. Before starting a full type packet capture, you must first follow instructions for configuring a bucket.
Note
Packet captures are available for Cloudflare Advanced Network Firewall users. For access, contact your account team.
Send a packet capture request
Currently, when a packet capture is requested, packets flowing at Cloudflare's global network through the Magic Transit system are captured. The default API field for this is "system": "magic-transit", both for the request and response.
Note
For help determining which data center to select for a packet capture, visit https://cloudflare.com/cdn-cgi/trace ↗︎ and refer to the colo field. Note some data centers can be regional such as ORD while other names may be more specific like ord02. Either of these names can be used for this same field.
Packet capture limits
Sample and full
packet_limit: The minimum value is1packet and maximum value is10000packets.
Sample
time_limit: The minimum value is1seconds and maximum value is300seconds.
Full
time_limit: The minimum value is1seconds and maximum value is86400seconds.-
byte_limit: The minimum value is1byte and maximum value is1000000000bytes. -
In the Cloudflare dashboard, go to Network health ↗︎.
- Select Diagnostics, then select Start a capture.
- Choose the type of capture you want to perform, and select Next.
- Fill out the required fields to begin the capture and then select Start.
The main Packet captures page displays a list of captures.
The PCAPs API needs both system and type to be specified to start a capture. A PCAP's system is the product or logical subsystem where packets are captured, and a PCAP's type is how the captured packets are built into a PCAP file.
Currently, you can only send one collect request per minute for sample PCAPs, and you can only have one running or pending full PCAP at a time.
<details>
<summary>
Full PCAP
</summary>
For full PCAP requests, refer to the required parameters listed at <a href="https://developers.cloudflare.com/api/resources/magic_transit/subresources/pcaps/methods/create/">Create full PCAP requests</a>. Note that full packet captures require two more parameters than sample packets.
The full PCAP request endpoint also contains optional fields you can use to limit the amount of packets captured. Both full and sample packet requests contain an optional <code>filter_v1</code> parameter you can use to filter packets by IPv4 Source address, for example. For a full list of the filter options, refer to the parameter lists above.
Leave <code>filter_v1</code> empty to collect all packets without any filtering.
Full PCAP example requestbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/pcaps \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '{
"filter_v1": {},
"time_limit": 300,
"packet_limit": 10000,
"byte_limit": 100000000,
"type": "full",
"colo": "ORD",
"system": "magic-transit",
"destination_conf": "${BUCKET}"
}'
While the collection is in progress, the response returns the <code>status</code> field as <code>pending</code>. You must wait for the PCAP collection to complete before downloading the file. When the PCAP is ready to download, the status changes to <code>success</code>.
Full PCAP example responsejson
{
"result": {
"id": "7d7c88382f0b4d5daa9587aa45a1a877",
"submitted": "2022-06-02T18:38:22.269047Z",
"filter_v1": {},
"time_limit": 300,
"status": "pending",
"type": "full",
"system": "magic-transit",
"packet_limit": 10000,
"byte_limit": 100000000,
"colo": "ORD",
"destination_conf": "gs://<bucket-name>" // Ensure you use a bucket that you created and registered in the Cloudflare dashboard
},
"success": true,
"errors": [],
"messages": []
}
</details>
<details>
<summary>
Sample PCAP
</summary>
To create a sample PCAP request, send a JSON body with the required parameter listed at <a href="https://developers.cloudflare.com/api/resources/magic_transit/subresources/pcaps/methods/create/">Create sample PCAP request</a>.
Leave <code>filter_v1</code> to collect all packets without any filtering.
Sample PCAP example requestbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/pcaps \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '{
"filter_v1": {
"source_address": "1.2.3.4",
"source_port": 123,
"destination_address": "5.6.7.8",
"destination_port": 80,
"protocol": 6
},
"time_limit": 300,
"packet_limit": 10000,
"type": "simple",
"system": "magic-transit"
}'
The response is a JSON body that contains the details of the job running to build the packet capture. The response contains a unique identifier for the packet capture request along with the details sent in the request.
Sample PCAP example responsejson
{
"result": {
"id": "6d1f0aac13cd40e3900d29f5dd0e8a2b",
"submitted": "2021-12-20T17:29:20.641845Z",
"filter_v1": {
"source_address": "1.2.3.4",
"source_port": 123,
"destination_address": "5.6.7.8",
"destination_port": 80,
"protocol": 6
},
"time_limit": 60,
"status": "pending",
"packets_remaining": 0,
"type": "simple",
"system": "magic-transit"
},
"success": true,
"errors": [],
"messages": []
}
</details>
Check packet capture status
- In the Cloudflare dashboard, go to Network health ↗︎.
- Select Diagnostics.
- Locate your capture under Network packet captures.
To check the status of a running job, send a request to the endpoint and specify the PCAP identifier. The PCAP identifier is received in the response of a collect request as shown in the previous step.
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/pcaps/{pcap_id} \
--header 'X-Auth-Email: <EMAIL>' \
--header 'X-Auth-Key: <API_KEY>'
The response will be similar to the one received when requesting a PCAP collection.
Sample PCAP example resultjson
{
"result": {
"id": "6d1f0aac13cd40e3900d29f5dd0e8a2b",
"submitted": "2021-12-20T17:29:20.641845Z",
"filter_v1": {
"source_address": "1.2.3.4",
"source_port": 123,
"destination_address": "5.6.7.8",
"destination_port": 80,
"protocol": 6
},
"time_limit": 120,
"status": "success",
"packets_remaining": 0,
"type": "simple",
"system": "magic-transit"
},
"success": true,
"errors": [],
"messages": []
}
The capture status displays one of the following options:
- Complete: The capture request is done and ready for download.
- In progress: The capture request was captured but still processing.
- Failure: The capture failed. If this occurs, verify your ownership information.
Download packet captures
After your request finishes processing, you can download your packet captures.
- In the Cloudflare dashboard, go to Network health ↗︎.
- Select Diagnostics.
- Locate your packet capture you want to download, and select Download.
Packet captures are available to download when the Status displays Success.
For more information on how to process multiple saved capture files into a single output file, refer to Wireshark's mergecap documentation ↗︎.
Full PCAPs
To obtain full PCAPs, download the files from the bucket specified in destination_conf after the PCAP's status is success. You may find multiple files named pcap_<pcap_id>.pcap per capture as captures can occur across multiple machines.
Sample PCAPs
Once the sample PCAP collection is complete, you can download the PCAP by specifying the PCAP identifier used earlier.
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/pcaps/{pcap_id}/download \
--header 'X-Auth-Email: <EMAIL>' \
--header 'X-Auth-Key: <API_KEY>' \
--output download.pcap
List packet captures
- In the Cloudflare dashboard, go to Network health ↗︎.
- Select Diagnostics > Network packet captures.
The list of packet captures associated with your account displays.
To view a list of sent requests, use the following command:
List request examplebash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/pcaps \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>"
The response returns an array that includes up to 50 sent requests, which includes completed and ongoing requests.
List response examplejson
{
"result": [
{
"id": "43adab5adeca4dab9c51f4b7f70f2ec3",
"submitted": "2021-12-15T03:04:09.277394Z",
"filter_v1": {},
"time_limit": 120,
"status": "success",
"packets_remaining": 0,
"type": "simple",
"system": "magic-transit"
}
],
"success": true,
"errors": [],
"messages": []
}
Best practices
Due to the nature of Cloudflare network, your traffic may traverse various physical machines within a single Cloudflare location.
- Multiple PCAP Files: A single full PCAP capture may produce many small PCAP files, as a capture is taken for each physical server your traffic traverses in a Cloudflare location.
- You can get more granular by applying packet-specific filters like protocol, port (and more) to target the traffic you need.
- Merging for Analysis: To view the traffic as a single flow, you can use a tool like mergecap to combine the individual files into one larger file for analysis in Wireshark. Refer to the Wireshark mergecap documentation ↗︎ for instructions.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/cloudflare-network-firewall/packet-captures/collect-pcaps/#page","headline":"Collect PCAPs","description":"Collect packet captures for traffic analysis.","url":"https://developers.cloudflare.com/cloudflare-network-firewall/packet-captures/collect-pcaps/","inLanguage":"en","image":"https://developers.cloudflare.com/cloudflare-network-firewall/packet-captures/collect-pcaps/og.png?v=1067e4665e2a055f","dateModified":"2026-04-17","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Configure a storage bucket for packet captures. title: PCAPs bucket setup image: https://developers.cloudflare.com/cloudflare-network-firewall/packet-captures/pcaps-bucket-setup/og.png?v=91f09b482231e0de
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/cloudflare-network-firewall/llms.txt
Use this file to discover all available pages before exploring further.
Docs