Skip to content

Trigger Inbound Rules

Greg Svoboda edited this page Mar 4, 2026 · 1 revision

Trigger Inbound Rules

Inbound rule triggers allow you to block or filter inbound messages by sender address or domain. These are managed through ServerClient. You will need a server API token.

import postmark

client = postmark.ServerClient("your-server-token")

List Inbound Rules

import asyncio

async def main():
    result = await client.inbound_rules.list()

    print(f"Total inbound rules: {result.total}")
    for rule in result.items:
        print(f"  [{rule.id}] {rule.rule}")

asyncio.run(main())

Create an Inbound Rule

Block inbound messages from a specific address or domain.

import asyncio

async def main():
    # Block a specific address
    rule = await client.inbound_rules.create("spam@example.com")
    print(f"Created rule: [{rule.id}] {rule.rule}")

    # Block an entire domain
    rule = await client.inbound_rules.create("@spammydomain.com")
    print(f"Created rule: [{rule.id}] {rule.rule}")

asyncio.run(main())

Delete an Inbound Rule

import asyncio

async def main():
    result = await client.inbound_rules.delete(trigger_id=1234)
    print(result.message)

asyncio.run(main())

Further Reading

Clone this wiki locally