Skip to content

POST /v1/modify

POST /v1/modify

Modifies a document using natural language instructions. The AI analyzes your request and applies appropriate changes to the HTML.

This endpoint supports two modes:

  1. Session-based (recommended) - Uses a sessionId from /v1/preview
  2. Direct - Passes HTML directly for one-off modifications
{
"sessionId": "550e8400-e29b-41d4-a716-446655440000",
"prompt": "Make the header navy blue and add our company logo",
"region": "header"
}
ParameterTypeRequiredDescription
sessionIdstringYesSession ID from /v1/preview or /v1/create. Accepts UUID format or development session IDs (dev_*)
promptstringYesNatural language modification instruction (max 1000 chars)
regionstringNoTarget region for focused modifications
dryRunbooleanNoWhen true, runs the modification but does not persist changes to the session. Default: false
RegionDescription
headerCompany branding, logo, document title
metaQuote number, dates, reference info
client-infoRecipient name, company, contact
line-itemsProducts, services, prices table
totalsSubtotal, tax, discount, total
notesAdditional notes section
footerTerms, conditions, signatures

For one-off modifications without session management:

{
"html": "<!DOCTYPE html><html>...</html>",
"instruction": "Change the background color to light gray",
"context": {
"documentType": "quote",
"company": "Acme Corp"
}
}
ParameterTypeRequiredDescription
htmlstringYesHTML content to modify
instructionstringYesModification instruction
contextobjectNoAdditional context for the AI
{
"html": "<!DOCTYPE html><html>...</html>",
"changes": [
"Changed header background color to navy blue (#1e3a5f)",
"Added company logo in the header section"
],
"selfCheckPassed": true,
"tokensUsed": 1250,
"usage": {
"tokensUsed": 1250,
"inputTokens": 800,
"outputTokens": 450
}
}
FieldTypeDescription
htmlstringModified HTML document
changesarrayList of changes made
selfCheckPassedbooleanWhether the AI guardrail self-check validator approved the changes
tokensUsednumberAI tokens consumed (session mode only)
usageobjectDetailed token usage breakdown
usage.tokensUsednumberTotal tokens used
usage.inputTokensnumberInput/prompt tokens
usage.outputTokensnumberOutput/completion tokens
validationWarningsarrayOptional warnings about modifications

400 Bad Request - Invalid prompt or validation error

{
"error": "Invalid prompt",
"code": "GUARDRAIL_VIOLATION",
"details": {
"category": "unsafe_content"
}
}

404 Not Found - Session not found

{
"error": "Session not found",
"code": "HTTP_ERROR"
}

410 Gone - Session expired

{
"error": "Session expired",
"code": "HTTP_ERROR"
}

Here are effective prompts for common modifications:

{
"sessionId": "...",
"prompt": "Apply a professional navy blue and gold color scheme"
}
{
"sessionId": "...",
"prompt": "Make the totals section larger and more prominent with bold styling",
"region": "totals"
}
{
"sessionId": "...",
"prompt": "Use a more compact layout with less whitespace"
}
{
"sessionId": "...",
"prompt": "Move the client information to the right side",
"region": "client-info"
}
{
"sessionId": "...",
"prompt": "Add a 10% discount row to the totals",
"region": "totals"
}
{
"sessionId": "...",
"prompt": "Add a note that payment is due within 30 days",
"region": "notes"
}
Terminal window
curl -X POST https://api.glyph.you/v1/modify \
-H "Authorization: Bearer gk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"sessionId": "550e8400-e29b-41d4-a716-446655440000",
"prompt": "Make the header more professional with a darker blue color",
"region": "header"
}'
const response = await fetch('https://api.glyph.you/v1/modify', {
method: 'POST',
headers: {
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
sessionId: '550e8400-e29b-41d4-a716-446655440000',
prompt: 'Add a company logo placeholder in the header',
region: 'header'
})
});
const { html, changes } = await response.json();
console.log('Changes made:', changes);
import requests
response = requests.post(
'https://api.glyph.you/v1/modify',
headers={
'Authorization': 'Bearer gk_your_api_key',
'Content-Type': 'application/json'
},
json={
'sessionId': '550e8400-e29b-41d4-a716-446655440000',
'prompt': 'Emphasize the total amount with larger font',
'region': 'totals'
}
)
data = response.json()
print(f"Changes: {data['changes']}")

The API includes safety guardrails to prevent:

  • Script injection - No JavaScript, event handlers, or iframes
  • External content - Limited external resource loading
  • Structural damage - Prevents breaking the document structure
  • Inappropriate content - Blocks harmful or offensive modifications

If a modification violates these guardrails, the content is automatically sanitized and a warning is returned:

{
"html": "...",
"changes": ["Modified header styling"],
"validationWarnings": ["Removed potentially unsafe content"]
}
  1. Be specific - “Make the header navy blue” works better than “make it look better”
  2. Use regions - Target specific sections when possible
  3. Iterate - Multiple small changes often work better than one large change
  4. Review changes - Check the changes array to understand what was modified