> ## 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.

# How embeds are secured

> What an embed URL grants, how long it lasts, and what your application must check

An embed lets a business owner use Pocketflows inside your application without a Pocketflows login.
Your server creates the embed with your secret key, and the business owner's browser loads it from the
URL in the response. To set one up, see [Render an embed](https://docs.pocketflows.com/how-to/render-an-embed.md).

## The URL is the credential

The embed's URL contains a long random token, and that token is all the browser needs. Anyone who has
the URL can use the embed as that business, with no further login, until it expires. Treat the URL like
a password:

* Create it on your server, after you have checked who the signed-in user is.
* Choose the business from your own session data. Never take the business ID from the browser, or one
  user could open another business's marketing.
* Give the URL only to that user's browser. Don't put it in logs, analytics, emails or links that can
  be shared.

Your secret key never reaches the browser: the embed's token stands in for it, and it is limited to
one business.

## What an embed can do

An embed made with `POST /businesses/:id/embeds` can see and change everything that business has in
Pocketflows: its customers, segments, campaigns, triggers, templates and settings. It can't reach other
businesses in your project.

Narrower embeds open a single editor for one record, such as an email template
(`POST /email_templates/:id/embeds`) or an SMS template (`POST /sms_templates/:id/embeds`). Use them
when the user should only edit that one thing.

## How long an embed lasts

* A business embed expires 7 days after it's created, at its `expires_at` time. Email and SMS template
  embeds accept `expires_in`, in seconds, to set a different lifetime.
* Until it expires, the URL can be loaded any number of times.
* Creating a new embed doesn't cancel earlier ones, and there is no way to revoke an embed before it
  expires.
* When an embed expires while it's open, the page tells the user their session has expired. Loading
  an expired URL again doesn't work.

Because of this, create a new embed each time the user opens the page that shows it, rather than
storing a URL and reusing it.


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