KosmoKrator

marketing

Tapfiliate Lua API for KosmoKrator Agents

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

5 functions 4 read 1 write API key auth

Lua Namespace

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

Tapfiliate — Lua API Reference

list_affiliates

List all affiliates in your Tapfiliate account.

Parameters

NameTypeRequiredDescription
limitintegernoResults per page (default: 25, max: 100)
pageintegernoPage number (default: 1)

Example

local affiliates = app.integrations.tapfiliate.list_affiliates({ limit = 50, page = 1 })

for _, aff in ipairs(affiliates) do
  print(aff.id .. ": " .. (aff.email or "no email"))
end

get_affiliate

Get details for a specific affiliate.

Parameters

NameTypeRequiredDescription
idstringyesThe affiliate ID

Example

local aff = app.integrations.tapfiliate.get_affiliate({ id = "aff_12345" })
print("Name: " .. (aff.first_name or "") .. " " .. (aff.last_name or ""))
print("Email: " .. (aff.email or ""))
print("Status: " .. (aff.status or ""))

list_conversions

List conversions with optional filters and pagination.

Parameters

NameTypeRequiredDescription
affiliate_idstringnoFilter by affiliate ID
campaign_idstringnoFilter by campaign ID
external_idstringnoFilter by external reference ID
statusstringnoFilter: "approved", "pending", or "rejected"
from_datestringnoStart date (ISO 8601, e.g., "2025-01-01")
to_datestringnoEnd date (ISO 8601, e.g., "2025-12-31")
limitintegernoResults per page (default: 25, max: 100)
pageintegernoPage number (default: 1)

Example

-- Get approved conversions for a specific affiliate
local conversions = app.integrations.tapfiliate.list_conversions({
  affiliate_id = "aff_12345",
  status = "approved",
  from_date = "2025-01-01",
  to_date = "2025-12-31"
})

for _, conv in ipairs(conversions) do
  print(conv.id .. ": $" .. conv.amount .. " (" .. conv.status .. ")")
end

create_conversion

Create a new conversion for an affiliate.

Parameters

NameTypeRequiredDescription
affiliate_idstringyesThe affiliate to credit
amountnumberyesConversion amount (e.g., 29.99)
external_idstringyesUnique external reference (e.g., order ID)
campaign_idstringnoCampaign to associate with
commission_typestringno"default" or "fixed"
commission_amountnumbernoOverride commission amount (if fixed type)
meta_dataobjectnoKey-value metadata

Example

local conversion = app.integrations.tapfiliate.create_conversion({
  affiliate_id = "aff_12345",
  amount = 99.00,
  external_id = "order_67890",
  campaign_id = "camp_abc"
})
print("Created conversion: " .. conversion.id)

get_current_user

Get the currently authenticated Tapfiliate user.

Parameters

None.

Example

local user = app.integrations.tapfiliate.get_current_user({})
print("Logged in as: " .. (user.email or "unknown"))

Common Workflows

Check top affiliates

local affiliates = app.integrations.tapfiliate.list_affiliates({ limit = 10 })

for _, aff in ipairs(affiliates) do
  local conversions = app.integrations.tapfiliate.list_conversions({
    affiliate_id = aff.id,
    status = "approved"
  })
  local total = 0
  for _, c in ipairs(conversions) do
    total = total + (c.amount or 0)
  end
  print(aff.email .. ": $" .. total .. " in conversions")
end

Record a conversion from an order

app.integrations.tapfiliate.create_conversion({
  affiliate_id = "aff_12345",
  amount = 149.99,
  external_id = "ORD-2025-0042",
  meta_data = {
    product = "Pro Plan",
    customer_email = "[email protected]"
  }
})

Multi-Account Usage

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

-- Default account (always works)
app.integrations.tapfiliate.list_affiliates({})

-- Explicit default (portable across setups)
app.integrations.tapfiliate.default.list_affiliates({})

-- Named accounts
app.integrations.tapfiliate.work.list_affiliates({})
app.integrations.tapfiliate.partner.list_affiliates({})

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

Raw agent markdown
# Tapfiliate — Lua API Reference

## list_affiliates

List all affiliates in your Tapfiliate account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Results per page (default: 25, max: 100) |
| `page` | integer | no | Page number (default: 1) |

### Example

```lua
local affiliates = app.integrations.tapfiliate.list_affiliates({ limit = 50, page = 1 })

for _, aff in ipairs(affiliates) do
  print(aff.id .. ": " .. (aff.email or "no email"))
end
```

---

## get_affiliate

Get details for a specific affiliate.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The affiliate ID |

### Example

```lua
local aff = app.integrations.tapfiliate.get_affiliate({ id = "aff_12345" })
print("Name: " .. (aff.first_name or "") .. " " .. (aff.last_name or ""))
print("Email: " .. (aff.email or ""))
print("Status: " .. (aff.status or ""))
```

---

## list_conversions

List conversions with optional filters and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `affiliate_id` | string | no | Filter by affiliate ID |
| `campaign_id` | string | no | Filter by campaign ID |
| `external_id` | string | no | Filter by external reference ID |
| `status` | string | no | Filter: `"approved"`, `"pending"`, or `"rejected"` |
| `from_date` | string | no | Start date (ISO 8601, e.g., `"2025-01-01"`) |
| `to_date` | string | no | End date (ISO 8601, e.g., `"2025-12-31"`) |
| `limit` | integer | no | Results per page (default: 25, max: 100) |
| `page` | integer | no | Page number (default: 1) |

### Example

```lua
-- Get approved conversions for a specific affiliate
local conversions = app.integrations.tapfiliate.list_conversions({
  affiliate_id = "aff_12345",
  status = "approved",
  from_date = "2025-01-01",
  to_date = "2025-12-31"
})

for _, conv in ipairs(conversions) do
  print(conv.id .. ": $" .. conv.amount .. " (" .. conv.status .. ")")
end
```

---

## create_conversion

Create a new conversion for an affiliate.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `affiliate_id` | string | yes | The affiliate to credit |
| `amount` | number | yes | Conversion amount (e.g., `29.99`) |
| `external_id` | string | yes | Unique external reference (e.g., order ID) |
| `campaign_id` | string | no | Campaign to associate with |
| `commission_type` | string | no | `"default"` or `"fixed"` |
| `commission_amount` | number | no | Override commission amount (if fixed type) |
| `meta_data` | object | no | Key-value metadata |

### Example

```lua
local conversion = app.integrations.tapfiliate.create_conversion({
  affiliate_id = "aff_12345",
  amount = 99.00,
  external_id = "order_67890",
  campaign_id = "camp_abc"
})
print("Created conversion: " .. conversion.id)
```

---

## get_current_user

Get the currently authenticated Tapfiliate user.

### Parameters

None.

### Example

```lua
local user = app.integrations.tapfiliate.get_current_user({})
print("Logged in as: " .. (user.email or "unknown"))
```

---

## Common Workflows

### Check top affiliates

```lua
local affiliates = app.integrations.tapfiliate.list_affiliates({ limit = 10 })

for _, aff in ipairs(affiliates) do
  local conversions = app.integrations.tapfiliate.list_conversions({
    affiliate_id = aff.id,
    status = "approved"
  })
  local total = 0
  for _, c in ipairs(conversions) do
    total = total + (c.amount or 0)
  end
  print(aff.email .. ": $" .. total .. " in conversions")
end
```

### Record a conversion from an order

```lua
app.integrations.tapfiliate.create_conversion({
  affiliate_id = "aff_12345",
  amount = 149.99,
  external_id = "ORD-2025-0042",
  meta_data = {
    product = "Pro Plan",
    customer_email = "[email protected]"
  }
})
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.tapfiliate.list_affiliates({})

-- Explicit default (portable across setups)
app.integrations.tapfiliate.default.list_affiliates({})

-- Named accounts
app.integrations.tapfiliate.work.list_affiliates({})
app.integrations.tapfiliate.partner.list_affiliates({})
```

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

Metadata-Derived Lua Example

local result = app.integrations.tapfiliate.tapfiliate_list_affiliates({
  limit = 1,
  page = 1
})
print(result)

Functions

tapfiliate_list_affiliates

List affiliates in your Tapfiliate account. Returns paginated results with affiliate IDs, emails, names, and status.

Operation
Read read
Full name
tapfiliate.tapfiliate_list_affiliates
ParameterTypeRequiredDescription
limit integer no Number of affiliates per page (default: 25, max: 100).
page integer no Page number for pagination (default: 1).

tapfiliate_get_affiliate

Get detailed information about a specific affiliate by their ID. Includes email, name, status, and metadata.

Operation
Read read
Full name
tapfiliate.tapfiliate_get_affiliate
ParameterTypeRequiredDescription
id string yes The affiliate ID.

tapfiliate_list_conversions

List conversions in your Tapfiliate account. Supports filtering by affiliate, campaign, date range, and status. Results are paginated.

Operation
Read read
Full name
tapfiliate.tapfiliate_list_conversions
ParameterTypeRequiredDescription
affiliate_id string no Filter by affiliate ID.
campaign_id string no Filter by campaign ID.
external_id string no Filter by external ID (e.g., order or transaction ID).
status string no Filter by status: "approved", "pending", or "rejected".
from_date string no Start date filter (ISO 8601, e.g., "2025-01-01").
to_date string no End date filter (ISO 8601, e.g., "2025-12-31").
limit integer no Number of results per page (default: 25, max: 100).
page integer no Page number for pagination (default: 1).

tapfiliate_create_conversion

Create a new conversion in Tapfiliate. Associates a revenue amount with an affiliate using a unique external ID (e.g., order ID or transaction reference).

Operation
Write write
Full name
tapfiliate.tapfiliate_create_conversion
ParameterTypeRequiredDescription
affiliate_id string yes The ID of the affiliate to credit.
amount number yes The conversion amount (e.g., 29.99).
external_id string yes A unique external reference (e.g., order ID, transaction ID).
campaign_id string no The campaign ID to associate the conversion with.
commission_type string no Commission type: "default" or "fixed".
commission_amount number no Override commission amount (if commission_type is "fixed").
meta_data object no Optional key-value metadata to attach to the conversion.

tapfiliate_get_current_user

Get the currently authenticated Tapfiliate user profile. Useful for verifying API credentials and checking account details.

Operation
Read read
Full name
tapfiliate.tapfiliate_get_current_user
ParameterTypeRequiredDescription
No parameters.