> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pocketflows.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Give businesses pre-built campaigns, triggers and emails

> Build a campaign, trigger or email once and offer it to every business as a template

Templates let every business start from content you have already built. This
guide publishes a campaign template, then covers the differences for trigger and
email templates. For the model behind this, see
[How pre-built templates work](https://docs.pocketflows.com/concepts/templates.md).

## Prerequisites

* A business in your project to build the content in. A business you use only
  for building templates works well.
* For a trigger template, the event it listens for. See
  [Send messages when something happens in your product](https://docs.pocketflows.com/how-to/trigger-messages-from-events.md).

## 1. Build the campaign

[Create an embed](https://docs.pocketflows.com/how-to/render-an-embed.md) for the business and build the
campaign the way a business would, with the steps and messages you want every
business to start from.

Write the messages so they work for any business. Use variables such as
`{{ business.name }}` and `{{ customer.first_name }}` rather than typing a name.
See [How personalization variables work](https://docs.pocketflows.com/concepts/personalization-variables.md).

## 2. Make it a template

1. In the dashboard, open
   [Resources > Businesses](https://dashboard.pocketflows.com/resources/businesses)
   and select the business.
2. Find the campaign and select **Make template**.

The template appears under
[Resources > Campaign Templates](https://dashboard.pocketflows.com/resources/campaign_templates).
It is a copy of the campaign, so you can keep changing the original without
affecting it.

## 3. Name and enable it

Give the template a title and description that tell a business when to use it,
then enable it. A new template is disabled until you do.

Once enabled, the template is offered to every business in the project when it
creates a campaign in the embed.

## 4. Use it for a business

A business can pick the template itself in the embed. To create the campaign for
a business from your own product instead, use the API:

```
POST /campaign_templates/:id/campaigns

Body
{
  "business": "bu_XXXXX"
}
```

The response is the new campaign, which belongs to that business and has not
been sent. To find the template's `id`, list the enabled templates with
`GET /campaign_templates`.

## Trigger templates

The steps are the same, with these differences:

* Build a trigger instead of a campaign, then select **Make template** on the
  trigger. It appears under
  [Resources > Trigger Templates](https://dashboard.pocketflows.com/resources/trigger_templates).
* List enabled templates with `GET /trigger_templates`.
* Create a trigger for a business with:

  ```
  POST /trigger_templates/:id/trigger_drafts

  Body
  {
    "business": "bu_XXXXX"
  }
  ```

  The response is a draft trigger. It does not run until it is activated.

## Email templates

To offer a single email design rather than a whole campaign:

* Create it under
  [Resources > Project Email Templates](https://dashboard.pocketflows.com/resources/project_email_templates),
  then enable it. From the same page you can copy a template you built in test
  mode into your live project.
* List them with `GET /project_email_templates`.
* Copy one into a business with:

  ```
  POST /project_email_templates/:id/copy

  Body
  {
    "business": "bu_XXXXX"
  }
  ```

  The response is the business's new email template.

## Update a template

Changing a template affects businesses that use it from then on. Copies that
businesses have already made are not changed. To change the title or description
shown to businesses, edit the template in the dashboard or send the new values
to `POST /campaign_templates/:id` or `POST /trigger_templates/:id`.

## Related

* [How pre-built templates work](https://docs.pocketflows.com/concepts/templates.md) for why using a template
  makes a copy.
* [How personalization variables work](https://docs.pocketflows.com/concepts/personalization-variables.md) for
  writing messages that work for every business.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.