KosmoKrator

productivity

Postmark Lua API for KosmoKrator Agents

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

Lua Namespace

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

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Postmark workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.postmark.list_messages({count = 1, offset = 1, recipient = "example_recipient", fromemail = "example_fromemail", subject = "example_subject", status = "example_status", tag = "example_tag"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("postmark"))' --json
kosmo integrations:lua --eval 'print(docs.read("postmark.list_messages"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local postmark = app.integrations.postmark
local result = postmark.list_messages({count = 1, offset = 1, recipient = "example_recipient", fromemail = "example_fromemail", subject = "example_subject", status = "example_status", tag = "example_tag"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.postmark, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.postmark.default.* or app.integrations.postmark.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Postmark, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

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

Postmark Integration

Authentication

The Postmark integration uses a Server API token for server-level operations. The token is sent via the X-Postmark-Server-Token header.

Find your Server API token: Postmark Dashboard → Server → API Tokens

For account-level operations, including postmark_list_servers, configure an Account API token. Those requests use the X-Postmark-Account-Token header.

Base URL

  • Default: https://api.postmarkapp.com

Response Format

Postmark API responses return JSON. For example, the message list returns:

{
  "TotalCount": 100,
  "Messages": [
    {
      "MessageID": "abc-123",
      "MessageStream": "outbound",
      "To": ["user@example.com"],
      "From": "sender@example.com",
      "Subject": "Hello",
      "Status": "Sent",
      "CreatedAt": "2024-01-01T00:00:00.0000000-00:00"
    }
  ]
}

Pagination

List endpoints support count and offset parameters for pagination.

  • count — Number of records to return (default 100, max 500)
  • offset — Number of records to skip

Common Workflows

Send an email

  1. postmark_send_email — Send an email with To, From, Subject, and TextBody or HtmlBody. Optionally add Cc, Bcc, Tag, and ReplyTo.

Track messages

  1. postmark_list_messages — List outbound messages. Filter by recipient, sender, subject, status, or tag.
  2. postmark_get_message — Get full details for a specific message by MessageID.

Manage templates

  1. postmark_list_templates — Browse all templates in the account.
  2. postmark_get_template — View template content including subject, HTML, and text body.

Server management

  1. postmark_list_servers — List servers in the account. Requires an Account API token and supports filtering by name.
  2. postmark_get_current_user — Get current server info and settings. Useful as a health check.

Message Statuses

Common message statuses for filtering:

  • queued — Message is queued for delivery
  • sent — Message was delivered to the recipient’s server
  • bounced — Message bounced
  • inbound — Message was received inbound
  • opened — Recipient opened the message (requires open tracking)
  • clicked — Recipient clicked a tracked link

Tags

You can attach a tag to outgoing emails for categorization. Pass a Tag string when sending an email. Tags can be used to filter messages in postmark_list_messages.

Sender Signatures

The From email address must correspond to a verified Sender Signature in your Postmark account. Create and verify sender signatures in the Postmark Dashboard.


Multi-Account Usage

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

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

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

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

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

Raw agent markdown
# Postmark Integration

## Authentication

The Postmark integration uses a Server API token for server-level operations.
The token is sent via the `X-Postmark-Server-Token` header.

Find your Server API token: **Postmark Dashboard → Server → API Tokens**

For account-level operations, including `postmark_list_servers`, configure an
Account API token. Those requests use the `X-Postmark-Account-Token` header.

## Base URL

- Default: `https://api.postmarkapp.com`

## Response Format

Postmark API responses return JSON. For example, the message list returns:

```json
{
  "TotalCount": 100,
  "Messages": [
    {
      "MessageID": "abc-123",
      "MessageStream": "outbound",
      "To": ["user@example.com"],
      "From": "sender@example.com",
      "Subject": "Hello",
      "Status": "Sent",
      "CreatedAt": "2024-01-01T00:00:00.0000000-00:00"
    }
  ]
}
```

## Pagination

List endpoints support `count` and `offset` parameters for pagination.

- `count` — Number of records to return (default 100, max 500)
- `offset` — Number of records to skip

## Common Workflows

### Send an email

1. `postmark_send_email` — Send an email with To, From, Subject, and TextBody or HtmlBody. Optionally add Cc, Bcc, Tag, and ReplyTo.

### Track messages

1. `postmark_list_messages` — List outbound messages. Filter by recipient, sender, subject, status, or tag.
2. `postmark_get_message` — Get full details for a specific message by MessageID.

### Manage templates

1. `postmark_list_templates` — Browse all templates in the account.
2. `postmark_get_template` — View template content including subject, HTML, and text body.

### Server management

1. `postmark_list_servers` — List servers in the account. Requires an Account API token and supports filtering by name.
2. `postmark_get_current_user` — Get current server info and settings. Useful as a health check.

## Message Statuses

Common message statuses for filtering:
- `queued` — Message is queued for delivery
- `sent` — Message was delivered to the recipient's server
- `bounced` — Message bounced
- `inbound` — Message was received inbound
- `opened` — Recipient opened the message (requires open tracking)
- `clicked` — Recipient clicked a tracked link

## Tags

You can attach a tag to outgoing emails for categorization. Pass a `Tag` string when sending an email. Tags can be used to filter messages in `postmark_list_messages`.

## Sender Signatures

The `From` email address must correspond to a verified Sender Signature in your Postmark account. Create and verify sender signatures in the Postmark Dashboard.

---

## Multi-Account Usage

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

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

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

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

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.postmark.list_messages({count = 1, offset = 1, recipient = "example_recipient", fromemail = "example_fromemail", subject = "example_subject", status = "example_status", tag = "example_tag"})
print(result)

Functions

list_messages Read

List outbound messages from Postmark. Supports filtering by recipient, sender, subject, status, and tag.

Lua path
app.integrations.postmark.list_messages
Full name
postmark.postmark_list_messages
ParameterTypeRequiredDescription
count integer no Number of messages to return per page (default 100, max 500).
offset integer no Number of messages to skip for pagination.
recipient string no Filter by recipient email address.
fromemail string no Filter by sender email address.
subject string no Filter by email subject.
status string no Filter by status (queued, sent, bounced, etc.).
tag string no Filter by tag.
get_message Read

Get details for a specific Postmark outbound message including body, recipients, and delivery status.

Lua path
app.integrations.postmark.get_message
Full name
postmark.postmark_get_message
ParameterTypeRequiredDescription
message_id string yes The Postmark message ID to look up.
send_email Write

Send an email through Postmark. Requires To, From, and Subject. Provide either TextBody or HtmlBody.

Lua path
app.integrations.postmark.send_email
Full name
postmark.postmark_send_email
ParameterTypeRequiredDescription
To string yes Recipient email address.
From string yes Sender email address (must be a verified sender signature).
Subject string yes Email subject line.
TextBody string no Plain-text body of the email.
HtmlBody string no HTML body of the email.
Cc string no CC recipient(s), comma-separated.
Bcc string no BCC recipient(s), comma-separated.
Tag string no Tag for categorization and tracking.
ReplyTo string no Reply-To email address.
send_template_email Write

Send an email using a Postmark template. Provide either a TemplateId or TemplateAlias along with the template model data.

Lua path
app.integrations.postmark.send_template_email
Full name
postmark.postmark_send_template
ParameterTypeRequiredDescription
From string yes Sender email address (must be a verified sender signature). Example: "sender@example.com" or "Sender Name <sender@example.com>".
To string yes Recipient email address. Multiple recipients separated by commas.
TemplateId integer no The template ID to use. Use this or TemplateAlias.
TemplateAlias string no The template alias to use. Use this or TemplateId.
TemplateModel array no Key-value pairs to fill the template variables. Example: {"name": "John", "company": "Acme"}.
Cc string no CC recipients (comma-separated).
Bcc string no BCC recipients (comma-separated).
ReplyTo string no Reply-to email address.
Tag string no Tag for categorization and analytics.
TrackOpens boolean no Enable open tracking (default: server setting).
TrackLinks string no Link tracking mode: "None", "HtmlAndText", "HtmlOnly", "TextOnly".
get_delivery_stats Read

Get email delivery statistics for your Postmark server, including counts of sent, bounced, and spam complaints.

Lua path
app.integrations.postmark.get_delivery_stats
Full name
postmark.postmark_get_delivery_stats
ParameterTypeRequiredDescription
No parameters.
list_templates Read

List all email templates in Postmark. Supports pagination.

Lua path
app.integrations.postmark.list_templates
Full name
postmark.postmark_list_templates
ParameterTypeRequiredDescription
count integer no Number of templates to return per page (default 100, max 500).
offset integer no Number of templates to skip for pagination.
get_template Read

Get details for a Postmark email template including subject, HTML body, and text body.

Lua path
app.integrations.postmark.get_template
Full name
postmark.postmark_get_template
ParameterTypeRequiredDescription
template_id string yes The Postmark template ID to look up.
list_servers Read

List servers in the Postmark account using an account API token. Supports filtering by name and pagination.

Lua path
app.integrations.postmark.list_servers
Full name
postmark.postmark_list_servers
ParameterTypeRequiredDescription
count integer no Number of servers to return per page (default 100, max 500).
offset integer no Number of servers to skip for pagination.
name string no Filter by server name.
get_current_server Read

Get the current Postmark server info including name, settings, and delivery stats. Useful as a health check.

Lua path
app.integrations.postmark.get_current_server
Full name
postmark.postmark_get_current_user
ParameterTypeRequiredDescription
No parameters.