Skip to main content
Penbox allows you to embed forms directly in your website using iframes, so your users never leave your application.

How It Works

Instead of redirecting users to a Penbox URL, you load the form inside an <iframe> on your own page. Penbox communicates back to your page using postMessage events.
1

Configure allowed origins

In your workspace Branding settings, add the origins (domains) that are allowed to embed Penbox forms. For example: https://app.yourcompany.com.
2

Enable embedding per form

On each form template, toggle Embedding on in the settings panel. Only forms with this toggle enabled can be embedded.
3

Add the iframe to your page

Use the form URL with the embed_v=1 query parameter:
4

Listen for events

Listen for postMessage events from the iframe to know when the form is ready and when it’s completed.

Configuration

Embedding requires a double opt-in:
  1. Workspace level: declare which origins are allowed to embed forms (in Settings > Branding)
  2. Form level: enable embedding on each individual form template
This prevents accidental exposure — a workspace with 50 forms won’t have them all embeddable just because one origin is configured.

Allowed Origins

Origins must be exact matches — no wildcards, no paths, no trailing slashes. HTTPS is required in production. http://localhost (with optional port) is allowed for development. You can configure up to 20 origins per workspace.
If the embedding toggle is on for a form but no origins are configured at workspace level, embedding will be blocked.

Query Parameters

A typical embedded URL looks like:

Events

Penbox sends events to the parent window using postMessage. All events share the same envelope:

ready

Sent when the form layout has mounted and is ready to be displayed.

completed

Sent exactly once when the form is submitted. Includes the request_id for reference.
The completed event fires regardless of whether an auto-redirect is configured on the form. It is sent before any redirect delay.

close

Sent when the user clicks the close action inside the form. Includes the request_id for reference.

Integration Example

Embed the forms of a case created through the API

When you create a case with POST /cases, the response carries embed_links: one link per contact who has the customer portal on that case. Put that link in an iframe to show the contact their forms on your own website.
The link is resolved when the iframe loads, not when the case is created. It works even when the first form is not ready yet, which is the case right after POST /cases: the steps of a case template start a few seconds after the API has answered. What the iframe shows:
  • The form is open: the form itself, without any access screen.
  • No form has started yet: a loader, which opens the form as soon as its step starts. After 25 seconds without one, a “not available yet” message with a Try again button.
  • The contact has nothing left to fill: a “your information has been sent” screen.
  • The link is no longer valid (contact or case closed, link expired): a neutral “not available” screen.

Conditions

embed_links is empty unless all of these hold:
  • The customer portal is enabled on the case (from its case template).
  • The contact’s role has the portal (portal: true on the role in the case template).
  • The case does not require a verification code. An embed link must not bypass the code.
Only the origins declared in Settings > Branding > Iframe may frame the link. The form-level embedding toggle does not apply to case forms.
An embed link opens the contact’s forms without asking for a code. Only show it to that contact, never on a public page.

Treat the URL as opaque

  • Read url from each API response (GET /cases/{id} returns it too). Never build it yourself: its host and path may change.
  • To filter postMessage events, trust new URL(url).origin, not a hard-coded domain:
The ready event is sent by the form itself, not by the loader that may precede it.

Security

Penbox uses the Content-Security-Policy: frame-ancestors header to control which origins can embed forms. When embedding is properly configured, the X-Frame-Options: DENY header is replaced with a CSP header listing only your allowed origins. If a page tries to embed a form from an unauthorized origin, the browser blocks it — the iframe will show an error or remain blank.
Always filter incoming postMessage events by checking event.data?.source === 'penbox' and event.origin === 'https://fill.penbox.io' to avoid processing unrelated messages.

Known Limitations

  • Exact origins only — wildcards and regex patterns are not supported. Each origin must be declared explicitly.
  • 20 origins max — contact support if you need more.
  • Token visible to parent — the parent page can read the iframe URL. This is standard iframe behavior and does not expose additional data.
  • Third-party cookie restrictions — Safari ITP and Chrome strict mode may block third-party cookies. Penbox uses sessionStorage-based authentication, so this is generally not an issue.
  • Custom form domains — embedding currently only works with fill.penbox.io URLs. Custom domain support is planned.

Next Steps

Form Security

Protect forms with access controls

Form Templates

Build and configure form templates