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 sharedcomponent_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’schildren[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
ThecomponentId 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.
Creation Flow (4 Steps)
Step 1 — Create the formula
Create the formula withstructure: []. 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 inchildren[0].text is the seed variant — it is automatically created as the first alternate for that slot.
Step 4 — Add the remaining alternates
Add all remaining alternates using eitherPOST /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.
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
/review, /approve, /archive) to progress a formula.