Skip to main content
Embeds provide a complete user experience for editing campaigns, email templates, and other marketing primitives available within Pocketflows. For when to use them, see Businesses, customers, and embeds. The work is split between your server, which creates the embed, and your frontend, which displays it. Before you start, read How embeds are secured: the embed’s URL works without a login, so who receives it matters.

1. On your server: create the embed

Add an endpoint to your application that your frontend calls when a business owner opens your marketing page. In it:
  1. Check the user’s session, and look up which business they belong to from your own records. Don’t accept a business ID from the browser.
  2. Find that business’s Pocketflows ID, which you saved when you synced the business.
  3. Create an embed for it, using your secret key:
  4. Return the url to your frontend, and nothing else from the response.
Create a new embed each time the page opens, rather than storing a URL and reusing it.

2. In your frontend: display it

Pass the url as the src of an iframe:
We recommend that the iframe take up as much of the viewport as possible.

3. Handle expiry

An embed expires 7 days after it’s created. If a business owner keeps the page open past expires_at, the embed tells them their session has expired. Reloading your page fetches a new URL from step 1, so no extra handling is needed if your page always creates a new embed when it loads.