API reference · Template builder & AI
Convert HTML to a builder document
POST
https://api.pidgely.com/template-builder/convertScale plan. Converts simple e-mail HTML to a builder document, only when the conversion is lossless (every text, link and image survives); otherwise convertible is false and reasons says why.
convertible is true only when every text, link and image of the HTML survives and no styling the builder cannot express was found; reasons explains otherwise. Scale plan.
Authorization: Bearer pdg_…. An API key with full_access. A sending_access key gets 401 restricted_api_key.
Body parameters
JSON object.
| Name | Type | Required | Description |
|---|---|---|---|
html |
string | Yes | HTML body. html or text is required (unless you send with a template). |
Request
This endpoint is in the Node.js SDK; the other SDKs don't cover it yet, so call it over HTTP from them.
import { Pidgely } from 'pidgely';
const pidgely = new Pidgely(process.env.PIDGELY_API_KEY);
const { data, error } = await pidgely.templateBuilder.convert({
html: '<h1>Hello</h1><p>Welcome to <strong>Acme</strong>.</p>',
});
console.log(data ?? error);curl -X POST 'https://api.pidgely.com/template-builder/convert' \
-H "Authorization: Bearer $PIDGELY_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"html": "<h1>Hello</h1><p>Welcome to <strong>Acme</strong>.</p>"
}'Response
200 OK
{
"object": "template_builder",
"convertible": false,
"reasons": [
"reason"
],
"document": null
}Response fields
| Name | Type | Required | Description |
|---|---|---|---|
object |
string | Yes | Object type. One of template_conversion. |
convertible |
boolean | Yes | — |
reasons |
string[] | Yes | — |
document |
object | null | Yes | — |
Errors
Errors have the shape {"statusCode", "name", "message"}. See Errors for the full list.
| Status | Name | When |
|---|---|---|
| 401 | missing_api_key, restricted_api_key |
No Authorization: Bearer header, or a sending_access key called an endpoint that needs full_access. |
| 403 | invalid_api_key, validation_error |
The API key is invalid or revoked, or the request is not allowed for this account (unverified domain, plan limit, paused account). |
| 422 | validation_error |
A field is missing or invalid; message names it. |
| 429 | rate_limit_exceeded |
Too many requests per second. Wait for Retry-After seconds. |