---
title: K2
---

[Skip to content](#_top)

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

Copy Markdown

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

---

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

# K2

#### K2Streams

##### [List K2 streams](https://developers.cloudflare.com/api/python/resources/k2/subresources/streams/methods/list)

k2.streams.list(StreamListParams\*\*kwargs) -> SyncV4PagePaginationArray\[[StreamListResponse](<https://developers.cloudflare.com/api/python/resources/k2#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)>)]

GET/accounts/{account\_id}/k2/streams

##### [Get K2 stream](https://developers.cloudflare.com/api/python/resources/k2/subresources/streams/methods/get)

k2.streams.get(strstream\_id, StreamGetParams\*\*kwargs) -> [StreamGetResponse](<https://developers.cloudflare.com/api/python/resources/k2#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)>)

GET/accounts/{account\_id}/k2/streams/{stream\_id}

##### [Create K2 stream](https://developers.cloudflare.com/api/python/resources/k2/subresources/streams/methods/create)

k2.streams.create(StreamCreateParams\*\*kwargs) -> [StreamCreateResponse](<https://developers.cloudflare.com/api/python/resources/k2#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)>)

POST/accounts/{account\_id}/k2/streams

##### [Update K2 stream](https://developers.cloudflare.com/api/python/resources/k2/subresources/streams/methods/update)

k2.streams.update(strstream\_id, StreamUpdateParams\*\*kwargs) -> [StreamUpdateResponse](<https://developers.cloudflare.com/api/python/resources/k2#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)>)

PATCH/accounts/{account\_id}/k2/streams/{stream\_id}

##### [Delete K2 stream](https://developers.cloudflare.com/api/python/resources/k2/subresources/streams/methods/delete)

k2.streams.delete(strstream\_id, StreamDeleteParams\*\*kwargs) -> object

DELETE/accounts/{account\_id}/k2/streams/{stream\_id}

##### ModelsExpand Collapse

<details>

<summary>

class StreamListResponse: …

</summary>

id: str

Specifies the public ID of the K2 stream.

maxLength32

minLength32

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

created\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

endpoint: str

Indicates the base HTTP endpoint for producing and consuming records.

formaturi

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20endpoint">Link to this property</a>

<details>

<summary>

http: HTTP

Configures the HTTP endpoint. Disabling HTTP keeps <code>authentication</code> and <code>cors</code>, so enabling it again restores them.

</summary>

enabled: bool

Indicates whether the HTTP endpoint accepts records.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20enabled">Link to this property</a>

authentication: Optional\[bool]

Indicates whether the HTTP endpoint requires an API token with K2 produce permission. When false, the endpoint accepts unauthenticated records. Defaults to true when HTTP is enabled without a stored value.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20authentication">Link to this property</a>

<details>

<summary>

cors: Optional\[HTTPCORS]

</summary>

origins: Optional\[List\[str]]

Allows browser requests from these HTTP or HTTPS origins. Use a wildcard only as the sole origin. An empty list blocks cross-origin browser requests. Defaults to <code>['*']</code> when HTTP is enabled without stored origins.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors%20%3E%20(property)%20origins">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20http">Link to this property</a>

modified\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

name: str

Indicates the name of the K2 stream.

maxLength128

minLength1

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

retention\_seconds: int

Shows the configured record retention period from 1 hour (3600 seconds) to 30 days (2592000 seconds), inclusive.

maximum2592000

minimum3600

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20retention_seconds">Link to this property</a>

<details>

<summary>

worker\_binding: WorkerBinding

</summary>

enabled: bool

Indicates whether Workers bindings can produce records to the stream.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding%20%3E%20(property)%20enabled">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding">Link to this property</a>

</details>

[Link to this property](<#(resource)%20k2.streams%20%3E%20(model)%20stream_list_response%20%3E%20(schema)>)

<details>

<summary>

class StreamGetResponse: …

</summary>

id: str

Specifies the public ID of the K2 stream.

maxLength32

minLength32

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

created\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

endpoint: str

Indicates the base HTTP endpoint for producing and consuming records.

formaturi

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20endpoint">Link to this property</a>

<details>

<summary>

http: HTTP

Configures the HTTP endpoint. Disabling HTTP keeps <code>authentication</code> and <code>cors</code>, so enabling it again restores them.

</summary>

enabled: bool

Indicates whether the HTTP endpoint accepts records.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20enabled">Link to this property</a>

authentication: Optional\[bool]

Indicates whether the HTTP endpoint requires an API token with K2 produce permission. When false, the endpoint accepts unauthenticated records. Defaults to true when HTTP is enabled without a stored value.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20authentication">Link to this property</a>

<details>

<summary>

cors: Optional\[HTTPCORS]

</summary>

origins: Optional\[List\[str]]

Allows browser requests from these HTTP or HTTPS origins. Use a wildcard only as the sole origin. An empty list blocks cross-origin browser requests. Defaults to <code>['*']</code> when HTTP is enabled without stored origins.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors%20%3E%20(property)%20origins">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20http">Link to this property</a>

modified\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

name: str

Indicates the name of the K2 stream.

maxLength128

minLength1

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

retention\_seconds: int

Shows the configured record retention period from 1 hour (3600 seconds) to 30 days (2592000 seconds), inclusive.

maximum2592000

minimum3600

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20retention_seconds">Link to this property</a>

<details>

<summary>

worker\_binding: WorkerBinding

</summary>

enabled: bool

Indicates whether Workers bindings can produce records to the stream.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding%20%3E%20(property)%20enabled">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding">Link to this property</a>

</details>

[Link to this property](<#(resource)%20k2.streams%20%3E%20(model)%20stream_get_response%20%3E%20(schema)>)

<details>

<summary>

class StreamCreateResponse: …

</summary>

id: str

Specifies the public ID of the K2 stream.

maxLength32

minLength32

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

created\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

endpoint: str

Indicates the base HTTP endpoint for producing and consuming records.

formaturi

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20endpoint">Link to this property</a>

<details>

<summary>

http: HTTP

Configures the HTTP endpoint. Disabling HTTP keeps <code>authentication</code> and <code>cors</code>, so enabling it again restores them.

</summary>

enabled: bool

Indicates whether the HTTP endpoint accepts records.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20enabled">Link to this property</a>

authentication: Optional\[bool]

Indicates whether the HTTP endpoint requires an API token with K2 produce permission. When false, the endpoint accepts unauthenticated records. Defaults to true when HTTP is enabled without a stored value.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20authentication">Link to this property</a>

<details>

<summary>

cors: Optional\[HTTPCORS]

</summary>

origins: Optional\[List\[str]]

Allows browser requests from these HTTP or HTTPS origins. Use a wildcard only as the sole origin. An empty list blocks cross-origin browser requests. Defaults to <code>['*']</code> when HTTP is enabled without stored origins.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors%20%3E%20(property)%20origins">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20http">Link to this property</a>

modified\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

name: str

Indicates the name of the K2 stream.

maxLength128

minLength1

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

retention\_seconds: int

Shows the configured record retention period from 1 hour (3600 seconds) to 30 days (2592000 seconds), inclusive.

maximum2592000

minimum3600

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20retention_seconds">Link to this property</a>

<details>

<summary>

worker\_binding: WorkerBinding

</summary>

enabled: bool

Indicates whether Workers bindings can produce records to the stream.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding%20%3E%20(property)%20enabled">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding">Link to this property</a>

</details>

[Link to this property](<#(resource)%20k2.streams%20%3E%20(model)%20stream_create_response%20%3E%20(schema)>)

<details>

<summary>

class StreamUpdateResponse: …

</summary>

id: str

Specifies the public ID of the K2 stream.

maxLength32

minLength32

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

created\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

endpoint: str

Indicates the base HTTP endpoint for producing and consuming records.

formaturi

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20endpoint">Link to this property</a>

<details>

<summary>

http: HTTP

Configures the HTTP endpoint. Disabling HTTP keeps <code>authentication</code> and <code>cors</code>, so enabling it again restores them.

</summary>

enabled: bool

Indicates whether the HTTP endpoint accepts records.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20enabled">Link to this property</a>

authentication: Optional\[bool]

Indicates whether the HTTP endpoint requires an API token with K2 produce permission. When false, the endpoint accepts unauthenticated records. Defaults to true when HTTP is enabled without a stored value.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20authentication">Link to this property</a>

<details>

<summary>

cors: Optional\[HTTPCORS]

</summary>

origins: Optional\[List\[str]]

Allows browser requests from these HTTP or HTTPS origins. Use a wildcard only as the sole origin. An empty list blocks cross-origin browser requests. Defaults to <code>['*']</code> when HTTP is enabled without stored origins.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors%20%3E%20(property)%20origins">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20http%20%3E%20(property)%20cors">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20http">Link to this property</a>

modified\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

name: str

Indicates the name of the K2 stream.

maxLength128

minLength1

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

retention\_seconds: int

Shows the configured record retention period from 1 hour (3600 seconds) to 30 days (2592000 seconds), inclusive.

maximum2592000

minimum3600

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20retention_seconds">Link to this property</a>

<details>

<summary>

worker\_binding: WorkerBinding

</summary>

enabled: bool

Indicates whether Workers bindings can produce records to the stream.

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding%20%3E%20(property)%20enabled">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)%20%3E%20(property)%20worker_binding">Link to this property</a>

</details>

[Link to this property](<#(resource)%20k2.streams%20%3E%20(model)%20stream_update_response%20%3E%20(schema)>)

#### K2StreamsSubscriptions

##### [List subscriptions with consumer lag](https://developers.cloudflare.com/api/python/resources/k2/subresources/streams/subresources/subscriptions/methods/list)

k2.streams.subscriptions.list(strstream\_id, SubscriptionListParams\*\*kwargs) -> SyncSinglePage\[[SubscriptionListResponse](<https://developers.cloudflare.com/api/python/resources/k2#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)>)]

GET/accounts/{account\_id}/k2/streams/{stream\_id}/subscriptions

##### ModelsExpand Collapse

<details>

<summary>

class SubscriptionListResponse: …

</summary>

id: str

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

created\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20created_at">Link to this property</a>

<details>

<summary>

lag: Lag

</summary>

records: Optional\[str]

Decimal-string distance from the subscription’s committed position to the observed exclusive stream tail, in records. Includes in-flight records and may include expired records or records acknowledged beyond an earlier gap. Null unless status is available.

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20lag%20%3E%20(property)%20records">Link to this property</a>

<details>

<summary>

status: Literal\["available", "unsupported", "unavailable"]

Unsupported means the subscription or stream topology cannot be measured; unavailable means a required observation failed or was inconsistent.

</summary>

One of the following:

"available"

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20lag%20%3E%20(property)%20status%20%3E%20(member)%200">Link to this property</a>

"unsupported"

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20lag%20%3E%20(property)%20status%20%3E%20(member)%201">Link to this property</a>

"unavailable"

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20lag%20%3E%20(property)%20status%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20lag%20%3E%20(property)%20status">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20lag">Link to this property</a>

modified\_at: datetime

formatdate-time

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20modified_at">Link to this property</a>

name: str

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

start\_at: StartAt

</summary>

<details>

<summary>

type: Literal\["earliest", "latest"]

</summary>

One of the following:

"earliest"

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20start_at%20%3E%20(property)%20type%20%3E%20(member)%200">Link to this property</a>

"latest"

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20start_at%20%3E%20(property)%20type%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20start_at%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)%20%3E%20(property)%20start_at">Link to this property</a>

</details>

[Link to this property](<#(resource)%20k2.streams.subscriptions%20%3E%20(model)%20subscription_list_response%20%3E%20(schema)>)

#### K2Data

#### K2DataSubscriptions

#### K2DataSubscriptionsBatches