KosmoKrator

cloud

Cloudflare Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Cloudflare KosmoKrator integration.

7 functions 6 read 1 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.cloudflare.*. Use lua_read_doc("integrations.cloudflare") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Cloudflare — Lua API Reference

list_zones

List all Cloudflare zones (domains).

Parameters

NameTypeRequiredDescription
namestringnoFilter by zone name (e.g., “example.com”)
statusstringnoFilter by status: active, pending, initializing, moved, deleted, deactivated
pageintegernoPage number for pagination (default: 1)
per_pageintegernoNumber of zones per page (default: 20, max: 50)

Examples

-- List all zones
local result = app.integrations.cloudflare.list_zones({})

for _, zone in ipairs(result.zones) do
  print(zone.name .. " (" .. zone.status .. ") - " .. zone.id)
end
-- Filter by name
local result = app.integrations.cloudflare.list_zones({
  name = "example.com"
})

get_zone

Get detailed information about a specific Cloudflare zone.

Parameters

NameTypeRequiredDescription
zone_idstringyesThe zone identifier

Examples

local result = app.integrations.cloudflare.get_zone({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

print("Zone: " .. result.name)
print("Status: " .. result.status)
print("Plan: " .. result.plan)

list_dns_records

List DNS records for a Cloudflare zone.

Parameters

NameTypeRequiredDescription
zone_idstringyesThe zone identifier
typestringnoFilter by record type: A, AAAA, CNAME, MX, TXT, NS, SRV, etc.
namestringnoFilter by record name
contentstringnoFilter by record content
pageintegernoPage number for pagination (default: 1)
per_pageintegernoNumber of records per page (default: 20, max: 100)

Examples

-- List all DNS records
local result = app.integrations.cloudflare.list_dns_records({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

for _, record in ipairs(result.records) do
  print(record.type .. " " .. record.name .. " -> " .. record.content)
end
-- Filter A records only
local result = app.integrations.cloudflare.list_dns_records({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  type = "A"
})

create_dns_record

Create a new DNS record in a Cloudflare zone.

Parameters

NameTypeRequiredDescription
zone_idstringyesThe zone identifier
typestringyesDNS record type: A, AAAA, CNAME, MX, TXT, NS, SRV, etc.
namestringyesDNS record name (e.g., “www.example.com” or ”@“)
contentstringyesDNS record content (e.g., “192.0.2.1”)
ttlintegernoTime to live in seconds (1 = Auto, default: 1)
proxiedbooleannoWhether proxied through Cloudflare (default: false)

Examples

-- Create an A record proxied through Cloudflare
local result = app.integrations.cloudflare.create_dns_record({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  type = "A",
  name = "www.example.com",
  content = "192.0.2.1",
  ttl = 1,
  proxied = true
})

print(result.message)
-- Create a CNAME record
local result = app.integrations.cloudflare.create_dns_record({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  type = "CNAME",
  name = "blog.example.com",
  content = "example.github.io",
  ttl = 3600,
  proxied = false
})

list_page_rules

List page rules for a Cloudflare zone.

Parameters

NameTypeRequiredDescription
zone_idstringyesThe zone identifier
statusstringnoFilter by status: active, disabled
pageintegernoPage number for pagination
per_pageintegernoNumber of rules per page

Examples

local result = app.integrations.cloudflare.list_page_rules({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

for _, rule in ipairs(result.rules) do
  print("Priority " .. rule.priority .. ": " .. rule.status)
  for _, target in ipairs(rule.targets) do
    print("  Target: " .. target.target)
  end
end

get_analytics

Get analytics dashboard data for a Cloudflare zone.

Parameters

NameTypeRequiredDescription
zone_idstringyesThe zone identifier
sincestringnoStart time: ISO 8601 or relative like “-30d”, “-7d”, “-24h” (default: “-30d”)
untilstringnoEnd time: ISO 8601 or “now” (default: “now”)
continuousstringnoInclude continuous data: “true” or “false” (default: “true”)

Examples

-- Last 30 days
local result = app.integrations.cloudflare.get_analytics({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

print("Total requests: " .. (result.totals.requests or 0))
print("Total bandwidth: " .. (result.totals.bandwidth or 0))
print("Total threats: " .. (result.totals.threats or 0))
print("Total pageviews: " .. (result.totals.pageviews or 0))
-- Last 7 days
local result = app.integrations.cloudflare.get_analytics({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  since = "-7d",
  until = "now"
})

-- Timeseries data
for _, entry in ipairs(result.timeseries or {}) do
  print(entry.until .. ": " .. (entry.requests or 0) .. " requests")
end

get_current_user

Get details of the currently authenticated Cloudflare user.

Parameters

None.

Examples

local result = app.integrations.cloudflare.get_current_user({})

print("User: " .. result.username .. " (" .. result.email .. ")")
print("2FA enabled: " .. tostring(result.two_factor_authentication))

Multi-Account Usage

If you have multiple Cloudflare accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.cloudflare.function_name({...})

-- Explicit default (portable across setups)
app.integrations.cloudflare.default.function_name({...})

-- Named accounts
app.integrations.cloudflare.production.function_name({...})
app.integrations.cloudflare.staging.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Cloudflare — Lua API Reference

## list_zones

List all Cloudflare zones (domains).

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | no | Filter by zone name (e.g., "example.com") |
| `status` | string | no | Filter by status: active, pending, initializing, moved, deleted, deactivated |
| `page` | integer | no | Page number for pagination (default: 1) |
| `per_page` | integer | no | Number of zones per page (default: 20, max: 50) |

### Examples

```lua
-- List all zones
local result = app.integrations.cloudflare.list_zones({})

for _, zone in ipairs(result.zones) do
  print(zone.name .. " (" .. zone.status .. ") - " .. zone.id)
end
```

```lua
-- Filter by name
local result = app.integrations.cloudflare.list_zones({
  name = "example.com"
})
```

---

## get_zone

Get detailed information about a specific Cloudflare zone.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `zone_id` | string | yes | The zone identifier |

### Examples

```lua
local result = app.integrations.cloudflare.get_zone({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

print("Zone: " .. result.name)
print("Status: " .. result.status)
print("Plan: " .. result.plan)
```

---

## list_dns_records

List DNS records for a Cloudflare zone.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `zone_id` | string | yes | The zone identifier |
| `type` | string | no | Filter by record type: A, AAAA, CNAME, MX, TXT, NS, SRV, etc. |
| `name` | string | no | Filter by record name |
| `content` | string | no | Filter by record content |
| `page` | integer | no | Page number for pagination (default: 1) |
| `per_page` | integer | no | Number of records per page (default: 20, max: 100) |

### Examples

```lua
-- List all DNS records
local result = app.integrations.cloudflare.list_dns_records({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

for _, record in ipairs(result.records) do
  print(record.type .. " " .. record.name .. " -> " .. record.content)
end
```

```lua
-- Filter A records only
local result = app.integrations.cloudflare.list_dns_records({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  type = "A"
})
```

---

## create_dns_record

Create a new DNS record in a Cloudflare zone.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `zone_id` | string | yes | The zone identifier |
| `type` | string | yes | DNS record type: A, AAAA, CNAME, MX, TXT, NS, SRV, etc. |
| `name` | string | yes | DNS record name (e.g., "www.example.com" or "@") |
| `content` | string | yes | DNS record content (e.g., "192.0.2.1") |
| `ttl` | integer | no | Time to live in seconds (1 = Auto, default: 1) |
| `proxied` | boolean | no | Whether proxied through Cloudflare (default: false) |

### Examples

```lua
-- Create an A record proxied through Cloudflare
local result = app.integrations.cloudflare.create_dns_record({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  type = "A",
  name = "www.example.com",
  content = "192.0.2.1",
  ttl = 1,
  proxied = true
})

print(result.message)
```

```lua
-- Create a CNAME record
local result = app.integrations.cloudflare.create_dns_record({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  type = "CNAME",
  name = "blog.example.com",
  content = "example.github.io",
  ttl = 3600,
  proxied = false
})
```

---

## list_page_rules

List page rules for a Cloudflare zone.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `zone_id` | string | yes | The zone identifier |
| `status` | string | no | Filter by status: active, disabled |
| `page` | integer | no | Page number for pagination |
| `per_page` | integer | no | Number of rules per page |

### Examples

```lua
local result = app.integrations.cloudflare.list_page_rules({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

for _, rule in ipairs(result.rules) do
  print("Priority " .. rule.priority .. ": " .. rule.status)
  for _, target in ipairs(rule.targets) do
    print("  Target: " .. target.target)
  end
end
```

---

## get_analytics

Get analytics dashboard data for a Cloudflare zone.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `zone_id` | string | yes | The zone identifier |
| `since` | string | no | Start time: ISO 8601 or relative like "-30d", "-7d", "-24h" (default: "-30d") |
| `until` | string | no | End time: ISO 8601 or "now" (default: "now") |
| `continuous` | string | no | Include continuous data: "true" or "false" (default: "true") |

### Examples

```lua
-- Last 30 days
local result = app.integrations.cloudflare.get_analytics({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353"
})

print("Total requests: " .. (result.totals.requests or 0))
print("Total bandwidth: " .. (result.totals.bandwidth or 0))
print("Total threats: " .. (result.totals.threats or 0))
print("Total pageviews: " .. (result.totals.pageviews or 0))
```

```lua
-- Last 7 days
local result = app.integrations.cloudflare.get_analytics({
  zone_id = "023e105f4ecef8ad9ca31a8372d0c353",
  since = "-7d",
  until = "now"
})

-- Timeseries data
for _, entry in ipairs(result.timeseries or {}) do
  print(entry.until .. ": " .. (entry.requests or 0) .. " requests")
end
```

---

## get_current_user

Get details of the currently authenticated Cloudflare user.

### Parameters

None.

### Examples

```lua
local result = app.integrations.cloudflare.get_current_user({})

print("User: " .. result.username .. " (" .. result.email .. ")")
print("2FA enabled: " .. tostring(result.two_factor_authentication))
```

---

## Multi-Account Usage

If you have multiple Cloudflare accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.cloudflare.function_name({...})

-- Explicit default (portable across setups)
app.integrations.cloudflare.default.function_name({...})

-- Named accounts
app.integrations.cloudflare.production.function_name({...})
app.integrations.cloudflare.staging.function_name({...})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.cloudflare.cloudflare_list_zones({
  name = "example_name",
  status = "example_status",
  page = 1,
  per_page = 1
})
print(result)

Functions

cloudflare_list_zones

List all Cloudflare zones (domains). Returns zone IDs, names, status, and plan info. Use this to discover zone identifiers needed for DNS and analytics operations.

Operation
Read read
Full name
cloudflare.cloudflare_list_zones
ParameterTypeRequiredDescription
name string no Filter by zone name (e.g., "example.com").
status string no Filter by status: active, pending, initializing, moved, deleted, deactivated.
page integer no Page number for pagination (default: 1).
per_page integer no Number of zones per page (default: 20, max: 50).

cloudflare_get_zone

Get detailed information about a specific Cloudflare zone, including its ID, name, status, nameservers, and plan.

Operation
Read read
Full name
cloudflare.cloudflare_get_zone
ParameterTypeRequiredDescription
zone_id string yes The zone identifier (e.g., "023e105f4ecef8ad9ca31a8372d0c353").

cloudflare_list_dns_records

List DNS records for a Cloudflare zone. Returns record IDs, types, names, content, TTL, and proxy status.

Operation
Read read
Full name
cloudflare.cloudflare_list_dns_records
ParameterTypeRequiredDescription
zone_id string yes The zone identifier.
type string no Filter by record type: A, AAAA, CNAME, MX, TXT, NS, SRV, etc.
name string no Filter by record name (e.g., "www.example.com").
content string no Filter by record content (e.g., an IP address).
page integer no Page number for pagination (default: 1).
per_page integer no Number of records per page (default: 20, max: 100).

cloudflare_create_dns_record

Create a new DNS record in a Cloudflare zone. Supports A, AAAA, CNAME, MX, TXT, NS, SRV, and other record types.

Operation
Write write
Full name
cloudflare.cloudflare_create_dns_record
ParameterTypeRequiredDescription
zone_id string yes The zone identifier.
type string yes DNS record type: A, AAAA, CNAME, MX, TXT, NS, SRV, etc.
name string yes DNS record name (e.g., "www.example.com" or "@" for the zone root).
content string yes DNS record content (e.g., "192.0.2.1" for an A record).
ttl integer no Time to live in seconds. Use 1 for automatic ("Auto" TTL). Default: 1.
proxied boolean no Whether the record is proxied through Cloudflare (orange cloud). Default: false.

cloudflare_list_page_rules

List page rules for a Cloudflare zone. Returns rule IDs, targets, actions, and priority.

Operation
Read read
Full name
cloudflare.cloudflare_list_page_rules
ParameterTypeRequiredDescription
zone_id string yes The zone identifier.
status string no Filter by status: active, disabled.
page integer no Page number for pagination (default: 1).
per_page integer no Number of rules per page (default: 20).

cloudflare_get_analytics

Get analytics dashboard data for a Cloudflare zone. Returns HTTP requests, bandwidth, threats, and pageview metrics over a time range.

Operation
Read read
Full name
cloudflare.cloudflare_get_analytics
ParameterTypeRequiredDescription
zone_id string yes The zone identifier.
since string no Start time: ISO 8601 date or relative offset like "-30d", "-7d", "-24h". Default: "-30d".
until string no End time: ISO 8601 date or "now". Default: "now".
continuous string no Whether to include continuous data ("true" or "false"). Default: "true".

cloudflare_get_current_user

Get details of the currently authenticated Cloudflare user. Returns user ID, email, username, and account info.

Operation
Read read
Full name
cloudflare.cloudflare_get_current_user
ParameterTypeRequiredDescription
No parameters.