The embed endpoint delivers published schemas as a ready-to-render HTML string instead of JSON. The response contains one or moreDocumentation Index
Fetch the complete documentation index at: https://docs.schemagen.io/llms.txt
Use this file to discover all available pages before exploring further.
<script type="application/ld+json"> tags that you can insert directly into the <head> or <body> of any HTML page. This makes it the right choice for server-side rendering environments where you cannot run JavaScript to inject schemas at runtime.
This endpoint requires no authentication. It is a public CORS-enabled endpoint safe to call from any server environment.
When to use embed vs. inject
Use/api/embed when you are rendering pages on the server and want schemas included in the initial HTML response — for example, in a PHP template, a WordPress theme, a Shopify Liquid file, or an AMP page.
Use /api/inject (or the SchemaGen JavaScript SDK) when you are rendering pages in the browser and can inject schemas dynamically after the page loads.
| Scenario | Recommended endpoint |
|---|---|
| PHP or server-side templates | /api/embed |
| WordPress theme or plugin | /api/embed |
| Shopify Liquid templates | /api/embed |
| AMP pages | /api/embed |
| JavaScript SPAs or static sites with JS SDK | /api/inject |
Endpoint
Query parameters
The UUID of your client site. You can find your Client ID in Settings → Client in the SchemaGen dashboard.
The absolute URL of the page you want to fetch schemas for. Must include the protocol (e.g.,
https://example.com/products/widget).Response
A successful request returns200 with a Content-Type of text/html; charset=utf-8. The body is an HTML string containing one <script type="application/ld+json"> tag per published schema. If no schemas are published for the given URL, the body is an empty string.
Example response body
Response headers
| Header | Description |
|---|---|
X-Schemagen-Duration | Server-side processing time in milliseconds. |
X-Schemagen-ID | A unique UUID identifying this request. |
Content-Type | Always text/html; charset=utf-8. |
Cache-Control | Responses are cached. Unlike /api/inject, embed responses may be served from cache to improve server rendering performance. |
Code examples
WordPress usage
Call the embed API in your theme’sfunctions.php and output the result in the <head> using the wp_head action:
Error responses
When the request is invalid or an error occurs, the embed endpoint returns an empty body with the appropriate HTTP status code. It does not return a JSON error body.| Status | Cause |
|---|---|
400 | clientId or url is missing or invalid. |
500 | An unexpected server error occurred. |
X-Schemagen-ID header so you can trace the request.