Skip to main content
The Macros service allows you to create and manage custom SQL macros that can be used in permission rules. Macros provide reusable SQL fragments that help you write more complex and dynamic permission logic.

Overview

Most macro operations require superadmin authentication.

List Macros

Retrieve all available macros, including built-in ones:
The response includes both built-in macros (provided by SnackBase) and custom macros created for your account.

Get a Macro

Get details for a specific macro:

Create a Macro

Create a new custom macro:
The template property uses {{parameter_name}} syntax for parameter substitution.

Update a Macro

Update an existing custom macro:
Built-in macros cannot be updated.

Delete a Macro

Delete a custom macro:
You cannot delete built-in macros or macros that are currently in use by permission rules.

Test a Macro

Test a macro with specific parameters:
This is useful for validating that your macro generates the correct SQL before using it in production rules.

Built-in Macros

SnackBase provides several built-in macros:

Using Macros in Rules

Macros can be referenced in permission rules using the {{macro_name}} syntax:

Next Steps