---
title: Request Trace
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/python)

[Rules Trace](https://developers.cloudflare.com/api/python/resources/request_tracers)

[Traces](https://developers.cloudflare.com/api/python/resources/request_tracers/subresources/traces)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Request Trace

request\_tracers.traces.create(TraceCreateParams\*\*kwargs) -> [TraceCreateResponse](<https://developers.cloudflare.com/api/python/resources/request_tracers#(resource)%20request_tracers.traces%20%3E%20(model)%20trace_create_response%20%3E%20(schema)>)

POST/accounts/{account\_id}/request-tracer/trace

Traces a simulated HTTP request through Cloudflare’s edge to analyze how rules, settings, and configurations would process the request. Useful for debugging firewall rules, page rules, and other request transformations without sending actual traffic. Supports custom headers, cookies, body content, and geolocation context.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



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

**Example:**<code>X-Auth-Email: user@example.com</code>

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

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Allow Request Tracer Read`

##### ParametersExpand Collapse

account\_id: str

Identifier.

maxLength32

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20account_id%20%3E%20(schema)>)

method: str

HTTP Method of tracing request

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20method%20%3E%20(schema)>)

url: str

URL to which perform tracing request

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20url%20%3E%20(schema)>)

<details>

<summary>

body: Optional\[<a href="https://developers.cloudflare.com/api/python/resources/request_tracers/subresources/traces/methods/create#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)">Body</a>]

</summary>

base64: Optional\[str]

Base64 encoded request body

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(property)%20base64">Link to this property</a>

json: Optional\[object]

Arbitrary json as request body

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(property)%20json">Link to this property</a>

plain\_text: Optional\[str]

Request body as plain text

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(property)%20plain_text">Link to this property</a>

</details>

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20body%20%3E%20(schema)>)

<details>

<summary>

context: Optional\[<a href="https://developers.cloudflare.com/api/python/resources/request_tracers/subresources/traces/methods/create#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)">Context</a>]

Additional request parameters

</summary>

bot\_score: Optional\[int]

Bot score used for evaluating tracing request processing

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20bot_score">Link to this property</a>

<details>

<summary>

geoloc: Optional\[ContextGeoloc]

Geodata for tracing request

</summary>

city: Optional\[str]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20city">Link to this property</a>

continent: Optional\[str]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20continent">Link to this property</a>

is\_eu\_country: Optional\[bool]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20is_eu_country">Link to this property</a>

iso\_code: Optional\[str]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20iso_code">Link to this property</a>

latitude: Optional\[float]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20latitude">Link to this property</a>

longitude: Optional\[float]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20longitude">Link to this property</a>

postal\_code: Optional\[str]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20postal_code">Link to this property</a>

region\_code: Optional\[str]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20region_code">Link to this property</a>

subdivision\_2\_iso\_code: Optional\[str]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20subdivision_2_iso_code">Link to this property</a>

timezone: Optional\[str]

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc%20%3E%20(property)%20timezone">Link to this property</a>

</details>

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20geoloc">Link to this property</a>

skip\_challenge: Optional\[bool]

Whether to skip any challenges for tracing request (e.g.: captcha)

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20skip_challenge">Link to this property</a>

threat\_score: Optional\[int]

Threat score used for evaluating tracing request processing

<a href="#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)%20%3E%20(property)%20threat_score">Link to this property</a>

</details>

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20context%20%3E%20(schema)>)

cookies: Optional\[Dict\[str, str]]

Cookies added to tracing request

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20cookies%20%3E%20(schema)>)

headers: Optional\[Dict\[str, str]]

Headers added to tracing request

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20headers%20%3E%20(schema)>)

protocol: Optional\[str]

HTTP Protocol of tracing request

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20protocol%20%3E%20(schema)>)

skip\_response: Optional\[[bool](<https://developers.cloudflare.com/api/python/resources/request_tracers/subresources/traces/methods/create#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20skip_response%20%3E%20(schema)>)]

Skip sending the request to the Origin server after all rules evaluation

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20skip_response%20%3E%20(schema)>)

##### ReturnsExpand Collapse

<details>

<summary>

class TraceCreateResponse: …

Trace result with an origin status code

</summary>

status\_code: Optional\[int]

HTTP Status code of zone response

<a href="#(resource)%20request_tracers.traces%20%3E%20(model)%20trace_create_response%20%3E%20(schema)%20%3E%20(property)%20status_code">Link to this property</a>

trace: Optional\[Trace]

<a href="#(resource)%20request_tracers.traces%20%3E%20(model)%20trace_create_response%20%3E%20(schema)%20%3E%20(property)%20trace">Link to this property</a>

</details>

[Link to this property](<#(resource)%20request_tracers.traces%20%3E%20(model)%20trace_create_response%20%3E%20(schema)>)

### Request Trace

Python

HTTPTypeScriptPythonGoTerraform

```
import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
trace = client.request_tracers.traces.create(
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
    method="PUT",
    url="https://some.zone/some_path",
    body={
        "base64": "c29tZV9yZXF1ZXN0X2JvZHk="
    },
    context={
        "geoloc": {
            "city": "London"
        },
        "skip_challenge": True,
    },
    cookies={
        "cookie_name_1": "cookie_value_1",
        "cookie_name_2": "cookie_value_2",
    },
    headers={
        "header_name_1": "header_value_1",
        "header_name_2": "header_value_2",
    },
    protocol="HTTP/1.1",
)
print(trace.status_code)
```

200 example

```
{
  "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": {
    "status_code": 0,
    "trace": [
      {
        "action": "execute",
        "action_parameters": {
          "id": "4814384a9e5d4991b9815dcfc25d2f1f"
        },
        "description": "some rule",
        "expression": "ip.src ne 1.1.1.1",
        "kind": "zone",
        "matched": true,
        "name": "some ruleset name",
        "step_name": "rule_id01",
        "type": "rule"
      }
    ]
  }
}
```

##### Returns Examples

200 example

```
{
  "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": {
    "status_code": 0,
    "trace": [
      {
        "action": "execute",
        "action_parameters": {
          "id": "4814384a9e5d4991b9815dcfc25d2f1f"
        },
        "description": "some rule",
        "expression": "ip.src ne 1.1.1.1",
        "kind": "zone",
        "matched": true,
        "name": "some ruleset name",
        "step_name": "rule_id01",
        "type": "rule"
      }
    ]
  }
}
```