KosmoKrator

authentication

reCAPTCHA Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write No credentials auth

Lua Namespace

Agents call this integration through app.integrations.recaptcha.*. Use lua_read_doc("integrations.recaptcha") 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.

Google reCAPTCHA Enterprise — Lua API Reference

All reCAPTCHA tools are available under app.integrations.recaptcha.

list_assessments

List reCAPTCHA Enterprise assessments for a Google Cloud project. Returns assessment names, scores, token properties, and event details.

Parameters

NameTypeRequiredDescription
parentstringyesThe project resource name, e.g. "projects/my-project"
page_sizeintegernoMax assessments per page (default: 50, max: 100)
page_tokenstringnoPage token from a previous response

Response Fields

FieldTypeDescription
assessmentsarrayList of assessment objects
next_page_tokenstring|nullToken for the next page

Example

local result = app.integrations.recaptcha.list_assessments({
  parent = "projects/my-project",
  page_size = 20
})

for _, a in ipairs(result.assessments) do
  print(a.name .. " — score: " .. (a.score or "N/A"))
end

get_assessment

Get a single reCAPTCHA Enterprise assessment by its full resource name. Returns score, token properties, event details, and risk analysis.

Parameters

NameTypeRequiredDescription
namestringyesFull assessment resource name, e.g. "projects/my-project/assessments/12345678"

Example

local assessment = app.integrations.recaptcha.get_assessment({
  name = "projects/my-project/assessments/12345678"
})

print("Score: " .. (assessment.score or "N/A"))
if assessment.tokenProperties then
  print("Valid: " .. tostring(assessment.tokenProperties.valid))
end

create_assessment

Create a reCAPTCHA Enterprise assessment to evaluate a token. Provide the project parent, the token from the client widget, and the site key.

Parameters

NameTypeRequiredDescription
parentstringyesProject resource name, e.g. "projects/my-project"
tokenstringyesreCAPTCHA token from the client-side widget
site_keystringyesreCAPTCHA Enterprise site key
expected_actionstringnoExpected action name for action-based verification (e.g. "LOGIN")
hashed_account_idstringnoHashed user account ID for account defender assessment

Example

local result = app.integrations.recaptcha.create_assessment({
  parent = "projects/my-project",
  token = "TOKEN_FROM_CLIENT_WIDGET",
  site_key = "6Ld1234567890abcdef",
  expected_action = "LOGIN"
})

print("Score: " .. (result.score or "N/A"))
if result.tokenProperties then
  print("Token valid: " .. tostring(result.tokenProperties.valid))
  print("Action: " .. (result.tokenProperties.action or "N/A"))
end

list_keys

List reCAPTCHA Enterprise site keys for a Google Cloud project. Returns key names, display names, web settings, and integration type.

Parameters

NameTypeRequiredDescription
parentstringyesThe project resource name, e.g. "projects/my-project"
page_sizeintegernoMax keys per page (default: 50, max: 100)
page_tokenstringnoPage token from a previous response

Example

local result = app.integrations.recaptcha.list_keys({
  parent = "projects/my-project"
})

for _, key in ipairs(result.keys) do
  print(key.name .. " — " .. (key.display_name or "unnamed"))
end

get_key

Get a reCAPTCHA Enterprise site key by its full resource name. Returns the key configuration including web, Android, and iOS settings.

Parameters

NameTypeRequiredDescription
namestringyesFull key resource name, e.g. "projects/my-project/keys/my-key-id"

Example

local key = app.integrations.recaptcha.get_key({
  name = "projects/my-project/keys/my-key-id"
})

print("Display name: " .. (key.displayName or "N/A"))
if key.webSettings then
  print("Allowed domains: " .. table.concat(key.webSettings.allowedDomains or {}, ", "))
end

list_annotations

List annotations for a reCAPTCHA Enterprise assessment. Annotations provide feedback (LEGITIMATE, FRAUDULENT, etc.) to improve model accuracy.

Parameters

NameTypeRequiredDescription
parentstringyesAssessment resource name, e.g. "projects/my-project/assessments/12345678"
page_sizeintegernoMax annotations per page (default: 50, max: 100)
page_tokenstringnoPage token from a previous response

Example

local result = app.integrations.recaptcha.list_annotations({
  parent = "projects/my-project/assessments/12345678"
})

for _, ann in ipairs(result.annotations) do
  print(ann.name .. " — reason: " .. (ann.reason or "N/A"))
end

get_current_user

Get information about the current reCAPTCHA Enterprise API access. Returns accessible projects to verify connectivity.

Parameters

None.

Example

local info = app.integrations.recaptcha.get_current_user({})

if info.projects then
  for _, project in ipairs(info.projects) do
    print("Project: " .. (project.projectId or project.name or "unknown"))
  end
else
  print("API is reachable")
end

Common Patterns

Verify a login token

local result = app.integrations.recaptcha.create_assessment({
  parent = "projects/my-project",
  token = "USER_TOKEN_HERE",
  site_key = "6Ld1234567890abcdef",
  expected_action = "LOGIN"
})

if result.score and result.score >= 0.5 and result.tokenProperties and result.tokenProperties.valid then
  print("Login is legitimate (score: " .. result.score .. ")")
else
  print("Suspicious activity detected")
end

Paginate through all assessments

local page_token = ""
repeat
  local result = app.integrations.recaptcha.list_assessments({
    parent = "projects/my-project",
    page_size = 100,
    page_token = page_token
  })

  for _, a in ipairs(result.assessments) do
    print(a.name .. " score=" .. (a.score or "?"))
  end

  page_token = result.next_page_token or ""
until page_token == ""
Raw agent markdown
# Google reCAPTCHA Enterprise — Lua API Reference

All reCAPTCHA tools are available under `app.integrations.recaptcha`.

## list_assessments

List reCAPTCHA Enterprise assessments for a Google Cloud project. Returns assessment names, scores, token properties, and event details.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | The project resource name, e.g. `"projects/my-project"` |
| `page_size` | integer | no | Max assessments per page (default: 50, max: 100) |
| `page_token` | string | no | Page token from a previous response |

### Response Fields

| Field | Type | Description |
|-------|------|-------------|
| `assessments` | array | List of assessment objects |
| `next_page_token` | string\|null | Token for the next page |

### Example

```lua
local result = app.integrations.recaptcha.list_assessments({
  parent = "projects/my-project",
  page_size = 20
})

for _, a in ipairs(result.assessments) do
  print(a.name .. " — score: " .. (a.score or "N/A"))
end
```

---

## get_assessment

Get a single reCAPTCHA Enterprise assessment by its full resource name. Returns score, token properties, event details, and risk analysis.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Full assessment resource name, e.g. `"projects/my-project/assessments/12345678"` |

### Example

```lua
local assessment = app.integrations.recaptcha.get_assessment({
  name = "projects/my-project/assessments/12345678"
})

print("Score: " .. (assessment.score or "N/A"))
if assessment.tokenProperties then
  print("Valid: " .. tostring(assessment.tokenProperties.valid))
end
```

---

## create_assessment

Create a reCAPTCHA Enterprise assessment to evaluate a token. Provide the project parent, the token from the client widget, and the site key.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | Project resource name, e.g. `"projects/my-project"` |
| `token` | string | yes | reCAPTCHA token from the client-side widget |
| `site_key` | string | yes | reCAPTCHA Enterprise site key |
| `expected_action` | string | no | Expected action name for action-based verification (e.g. `"LOGIN"`) |
| `hashed_account_id` | string | no | Hashed user account ID for account defender assessment |

### Example

```lua
local result = app.integrations.recaptcha.create_assessment({
  parent = "projects/my-project",
  token = "TOKEN_FROM_CLIENT_WIDGET",
  site_key = "6Ld1234567890abcdef",
  expected_action = "LOGIN"
})

print("Score: " .. (result.score or "N/A"))
if result.tokenProperties then
  print("Token valid: " .. tostring(result.tokenProperties.valid))
  print("Action: " .. (result.tokenProperties.action or "N/A"))
end
```

---

## list_keys

List reCAPTCHA Enterprise site keys for a Google Cloud project. Returns key names, display names, web settings, and integration type.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | The project resource name, e.g. `"projects/my-project"` |
| `page_size` | integer | no | Max keys per page (default: 50, max: 100) |
| `page_token` | string | no | Page token from a previous response |

### Example

```lua
local result = app.integrations.recaptcha.list_keys({
  parent = "projects/my-project"
})

for _, key in ipairs(result.keys) do
  print(key.name .. " — " .. (key.display_name or "unnamed"))
end
```

---

## get_key

Get a reCAPTCHA Enterprise site key by its full resource name. Returns the key configuration including web, Android, and iOS settings.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Full key resource name, e.g. `"projects/my-project/keys/my-key-id"` |

### Example

```lua
local key = app.integrations.recaptcha.get_key({
  name = "projects/my-project/keys/my-key-id"
})

print("Display name: " .. (key.displayName or "N/A"))
if key.webSettings then
  print("Allowed domains: " .. table.concat(key.webSettings.allowedDomains or {}, ", "))
end
```

---

## list_annotations

List annotations for a reCAPTCHA Enterprise assessment. Annotations provide feedback (LEGITIMATE, FRAUDULENT, etc.) to improve model accuracy.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `parent` | string | yes | Assessment resource name, e.g. `"projects/my-project/assessments/12345678"` |
| `page_size` | integer | no | Max annotations per page (default: 50, max: 100) |
| `page_token` | string | no | Page token from a previous response |

### Example

```lua
local result = app.integrations.recaptcha.list_annotations({
  parent = "projects/my-project/assessments/12345678"
})

for _, ann in ipairs(result.annotations) do
  print(ann.name .. " — reason: " .. (ann.reason or "N/A"))
end
```

---

## get_current_user

Get information about the current reCAPTCHA Enterprise API access. Returns accessible projects to verify connectivity.

### Parameters

None.

### Example

```lua
local info = app.integrations.recaptcha.get_current_user({})

if info.projects then
  for _, project in ipairs(info.projects) do
    print("Project: " .. (project.projectId or project.name or "unknown"))
  end
else
  print("API is reachable")
end
```

---

## Common Patterns

### Verify a login token

```lua
local result = app.integrations.recaptcha.create_assessment({
  parent = "projects/my-project",
  token = "USER_TOKEN_HERE",
  site_key = "6Ld1234567890abcdef",
  expected_action = "LOGIN"
})

if result.score and result.score >= 0.5 and result.tokenProperties and result.tokenProperties.valid then
  print("Login is legitimate (score: " .. result.score .. ")")
else
  print("Suspicious activity detected")
end
```

### Paginate through all assessments

```lua
local page_token = ""
repeat
  local result = app.integrations.recaptcha.list_assessments({
    parent = "projects/my-project",
    page_size = 100,
    page_token = page_token
  })

  for _, a in ipairs(result.assessments) do
    print(a.name .. " score=" .. (a.score or "?"))
  end

  page_token = result.next_page_token or ""
until page_token == ""
```

Metadata-Derived Lua Example

local result = app.integrations.recaptcha.recaptcha_list_assessments({
  parent = "example_parent",
  page_size = 1,
  page_token = "example_page_token"
})
print(result)

Functions

recaptcha_list_assessments

List reCAPTCHA Enterprise assessments for a Google Cloud project. Returns assessment names, scores, token properties, and event details. Supports pagination with page size and page token.

Operation
Read read
Full name
recaptcha.recaptcha_list_assessments
ParameterTypeRequiredDescription
parent string yes The project resource name, e.g. "projects/my-project".
page_size integer no Maximum number of assessments to return per page (default: 50, max: 100).
page_token string no Page token from a previous list response to fetch the next page.

recaptcha_get_assessment

Get a single reCAPTCHA Enterprise assessment by its full resource name. Returns the score, token properties, event details, and risk analysis.

Operation
Read read
Full name
recaptcha.recaptcha_get_assessment
ParameterTypeRequiredDescription
name string yes The full assessment resource name, e.g. "projects/my-project/assessments/12345678".

recaptcha_create_assessment

Create a reCAPTCHA Enterprise assessment to evaluate a reCAPTCHA token. Provide the project parent, the token to evaluate, and the site key. Returns score, token validity, and action verification.

Operation
Write write
Full name
recaptcha.recaptcha_create_assessment
ParameterTypeRequiredDescription
parent string yes The project resource name, e.g. "projects/my-project".
token string yes The reCAPTCHA token to evaluate (obtained from the client-side widget).
site_key string yes The reCAPTCHA Enterprise site key associated with the token.
expected_action string no The expected action name for action-based verification (e.g. "LOGIN", "SIGNUP").
hashed_account_id string no Optional hashed user account ID for account defender assessment.

recaptcha_list_keys

List reCAPTCHA Enterprise site keys for a Google Cloud project. Returns key names, display names, web settings, and integration type. Supports pagination.

Operation
Read read
Full name
recaptcha.recaptcha_list_keys
ParameterTypeRequiredDescription
parent string yes The project resource name, e.g. "projects/my-project".
page_size integer no Maximum number of keys to return per page (default: 50, max: 100).
page_token string no Page token from a previous list response to fetch the next page.

recaptcha_get_key

Get a reCAPTCHA Enterprise site key by its full resource name. Returns the key configuration including web, Android, and iOS settings.

Operation
Read read
Full name
recaptcha.recaptcha_get_key
ParameterTypeRequiredDescription
name string yes The full key resource name, e.g. "projects/my-project/keys/my-key-id".

recaptcha_list_annotations

List annotations for a reCAPTCHA Enterprise assessment. Annotations provide feedback on assessment results (LEGITIMATE, FRAUDULENT, etc.) to improve model accuracy. Supports pagination.

Operation
Read read
Full name
recaptcha.recaptcha_list_annotations
ParameterTypeRequiredDescription
parent string yes The assessment resource name, e.g. "projects/my-project/assessments/12345678".
page_size integer no Maximum number of annotations to return per page (default: 50, max: 100).
page_token string no Page token from a previous list response to fetch the next page.

recaptcha_get_current_user

Get information about the current reCAPTCHA Enterprise API access. Returns the list of accessible projects to verify connectivity.

Operation
Read read
Full name
recaptcha.recaptcha_get_current_user
ParameterTypeRequiredDescription
No parameters.