Skip to main content
The embed endpoint delivers published schemas as a ready-to-render HTML string instead of JSON. The response contains one or more <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.

Endpoint

Query parameters

string
required
The UUID of your client site. You can find your Client ID in Settings → Client in the SchemaGen dashboard.
string
required
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 returns 200 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

If multiple schemas are published for the URL, they are concatenated with no separator:

Response headers

Code examples

WordPress usage

Call the embed API in your theme’s functions.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. All error responses still include the X-Schemagen-ID header so you can trace the request.
Because the embed endpoint returns an empty string when no schemas match the URL (rather than an error), you can safely output its response in every page template without a null check. Pages with no published schemas will simply have no extra output.