Skip to main content

Overview

A formula is a reusable message template that drives a campaign. It defines the channel (push, SMS, email, etc.), message slots, and the labeled alternates Aampe uses to personalize each send. Formulas start in Draft status and must go through a review/approval workflow before going live.

Core Concepts

Slots vs. Alternates

The structure defines slots — one position per section (header, body). It does not list all alternates inline. Alternates for a slot are linked by a shared component_id.

Component IDs — two distinct concepts

There are two different IDs called “component ID” and confusing them is the most common source of errors:

Seed variant

When you put text in a variant node’s children[0].text, that text is automatically created as the first alternate for that slot. Do not re-submit it via the bulk endpoint — it will create a duplicate.

componentId — component type UUIDs

The componentId in a structure variant node is the component type UUID from GET /component-types: Fetch the live list at any time:

Labels and variant_type

When associating a label with a variant, the label’s variant_type must exactly match the data_key of the component type.
A label created with variant_type: "Offering" cannot be used on a ValueProposition variant, and vice versa. Create separate labels for each component type you need.

Creation Flow (4 Steps)

Step 1 — Create the formula

Create the formula with structure: []. The message structure is set separately on the message-content record in Step 3.

Step 2 — Fetch the message-content ID

When a formula is created, the API automatically creates a message-content record for it. Fetch its ID:

Step 3 — Set the structure

Pre-generate a UUID for each slot. That UUID is the component instance ID — it links all of that slot’s alternates together and must be referenced when creating variants in Step 4. The text in children[0].text is the seed variant — it is automatically created as the first alternate for that slot.
Each slot must have exactly one variant node in the structure. Do not add multiple sibling variant nodes — they render as separate inline components, not as alternatives for the same slot.

Step 4 — Add the remaining alternates

Add all remaining alternates using either POST /variants/create/bulk (multiple at once) or POST /variants (one at a time). Use the component instance IDs you generated in Step 3. Do not include the seed variants — they were already created in Step 3.
After this call the formula has 3 header alternates × 2 body alternates = 6 unique message combinations.

Endpoint Reference

POST /formulas

Creates a new formula. labels item:

PUT /message-contents/{id}

Sets the message structure and seed variants on the message-content record. Variant node fields:

POST /variants/create/bulk

Creates multiple variants in a single request. Use this when you have several alternates to add at once.

POST /variants

Creates a single variant. Use this for one-off additions. Accepts the same fields as a bulk item, plus formula_id and message_content_id for context.

Formula Lifecycle

Use the state-transition endpoints (/review, /approve, /archive) to progress a formula.