API Documentation
Running Visual Layer within an iframe
Embedding Visual Layer Search with Seamless Authentication
You can easily integrate Visual Layer’s powerful visual search engine into your web application via an iframe.
This guide also explains how to automatically authenticate your users when embedding the search engine.
Step 1: Basic Iframe Integration
Embed Visual Layer into your web page with a simple iframe:
What this does:
- Displays the Visual Layer search engine inside your app.
- Fills the width of the container (
width="100%"
). - Uses a custom domain
vl.customer.com
for seamless authentication (see Step 2).
Step 2: Cross-Domain Authentication Setup
To automatically authenticate your users into Visual Layer without requiring a manual login:
DNS Configuration
- Create a CNAME DNS record:
This allows the iframe source to stay under the same parent domain (.customer.com
).
Authentication Cookie
When a user accesses your app (vl.customer.com/vl
), you need to set a special cookie:
- Cookie Name:
VL_AUTH
- Cookie Domain:
vl.customer.com
- Cookie Value:
An encrypted token consisting of:
Cookie Encryption
Use Fernet symmetric encryption for securing the cookie value.
Example in Python
Example in PHP
🔒 Make sure both sides (your server and Visual Layer) share the same encryption key securely.
Visual Layer Server Setup
- Create a read-only Visual Layer user limited to a specific dataset.
- Visual Layer will validate the
VL_AUTH
cookie for iframe sessions.
Full Example Flow
- User logs into
customer.com
. - Your app sets the encrypted
VL_AUTH
cookie. - User navigates to a page with the Visual Layer iframe.
- Visual Layer reads the cookie, decrypts it, and logs the user in automatically.
- User enjoys seamless visual search!