This page shows complete cURL examples for the external Davix H2I API.
Requests are processed by the H2I engine (PixLab) through the public external endpoints:
/v1/h2i/v1/image/v1/pdf/v1/tools
External requests require API key authentication. Supported authentication methods are:
X-Api-KeyAuthorization: Bearer <key>
Optional idempotency headers are also supported:
Idempotency-KeyX-Idempotency-Key
In production environments, API keys must be sent in headers. Body and query-string API key transport is rejected.
Setup #
BASE="https://pixlab.davix.dev"
API_KEY="<YOUR_API_KEY>"
Authentication #
Use either of these patterns:
-H "X-Api-Key: $API_KEY"
or
-H "Authorization: Bearer $API_KEY"
Optional idempotency:
-H "Idempotency-Key: your-request-id-001"
Valid idempotency keys:
- length: 8 to 128
- allowed characters:
A-Z,a-z,0-9,.,_,:,-
A valid key is echoed back by the server as the Idempotency-Key response header.
Notes about outputs #
/v1/h2i,/v1/image, and/v1/pdfreturn generated outputs and signed URLs./v1/toolsreturns structured JSON analysis results instead of generated file URLs.- Static output fetches for
/h2i/*,/image/*, and/pdf/*are behind signed URL protection./tools/*is signed when signed output mode is enabled.
Endpoint #
POST /v1/h2i
Supported actions:
imagepdf
Action #
action=image
Converts HTML into an image.
curl -sS -X POST "$BASE/v1/h2i" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: h2i-image-001" \
-H "Content-Type: application/json" \
-d '{
"action": "image",
"html": "<div style=\"width:100%;height:100%;display:flex;align-items:center;justify-content:center\">Hello</div>",
"css": "body{margin:0}",
"width": 1200,
"height": 1600,
"format": "jpeg"
}'
Parameters
action— required, must beimagehtml— required HTML stringcss— optional CSS stringwidth— optional viewport width, default1000height— optional viewport height, default1500format— optional output format, defaultpng; onlyjpegproduces JPEG, other values become PNG
Notes
- If
width * heightexceeds the render pixel limit, the request fails withrender_size_exceeded.
Action #
action=pdf
Converts HTML into a PDF.
curl -sS -X POST "$BASE/v1/h2i" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-001" \
-H "Content-Type: application/json" \
-d '{
"action": "pdf",
"html": "<h1>Invoice</h1>",
"css": "body{font-family:sans-serif}",
"width": 1000,
"height": 1500,
"pdfFormat": "LETTER",
"pdfLandscape": false,
"pdfMargin": 24,
"preferCSSPageSize": true,
"scale": 1,
"printMode": false,
"printBackground": true
}'
Parameters
action— required, must bepdfhtml— required HTML stringcss— optional CSS stringwidth,height— optional viewport valuespdfFormat— optional, defaultA4; onlyLETTERmaps to LetterpdfLandscape— optional boolean, defaultfalsepdfMargin— optional integer, default24preferCSSPageSize— optional boolean, defaulttruescale— optional numeric, default1printMode— optional boolean, defaultfalseprintBackground— optional boolean, defaulttrue
Endpoint #
POST /v1/image
Supported actions:
formatresizecroptransformcompressenhancepaddingframebackgroundwatermarkpdfmetadatamultitask
The endpoint uses multipart/form-data.
Shared image parameters #
actionimageswatermarkImageformatwidth,height,enlargecropX,cropY,cropWidth,cropHeightrotate,flipH,flipVtargetSizeKB,qualitykeepMetadata,normalizeOrientationblur,sharpen,grayscale,sepiabrightness,contrast,saturationpad,padTop,padRight,padBottom,padLeft,padColorborder,borderColor,borderRadiusbackgroundColor,backgroundBlurwatermarkText,watermarkFontSize,watermarkColor,watermarkOpacity,watermarkPosition,watermarkMargin,watermarkScalepdfMode,pdfPageSize,pdfOrientation,pdfMargin,pdfEmbedFormat,pdfJpegQualitycolorSpaceincludeRawExif
Action #
action=format
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-002" \
-F "action=format" \
-F "images=@./samples/a.jpg" \
-F "format=webp"
Action #
action=resize
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-003" \
-F "action=resize" \
-F "images=@./samples/a.jpg" \
-F "width=1024" \
-F "height=768"
Action #
action=crop
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-004" \
-F "action=crop" \
-F "images=@./samples/a.jpg" \
-F "cropX=0" \
-F "cropY=0" \
-F "cropWidth=800" \
-F "cropHeight=600"
Action #
action=transform
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-005" \
-F "action=transform" \
-F "images=@./samples/a.jpg" \
-F "rotate=90" \
-F "flipH=true"
Action #
action=compress
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-006" \
-F "action=compress" \
-F "images=@./samples/a.jpg" \
-F "targetSizeKB=200" \
-F "quality=80"
Action #
action=enhance
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-007" \
-F "action=enhance" \
-F "images=@./samples/a.jpg" \
-F "sharpen=1" \
-F "contrast=1.1"
Action #
action=padding
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-008" \
-F "action=padding" \
-F "images=@./samples/a.jpg" \
-F "pad=20" \
-F "padColor=#ffffff"
Action #
action=frame
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-009" \
-F "action=frame" \
-F "images=@./samples/a.jpg" \
-F "border=4" \
-F "borderColor=#000000"
Action #
action=background
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-010" \
-F "action=background" \
-F "images=@./samples/a.png" \
-F "backgroundColor=#ffffff"
Action #
action=watermark
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-011" \
-F "action=watermark" \
-F "images=@./samples/a.jpg" \
-F "watermarkText=H2I"
Action #
action=pdf
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-012" \
-F "action=pdf" \
-F "images=@./samples/a.jpg" \
-F "format=pdf" \
-F "pdfMode=single"
Action #
action=metadata
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-013" \
-F "action=metadata" \
-F "images=@./samples/a.jpg" \
-F "normalizeOrientation=true" \
-F "includeRawExif=true"
Action #
action=multitask
curl -sS -X POST "$BASE/v1/image" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-014" \
-F "action=multitask" \
-F "images=@./samples/a.jpg" \
-F "width=1200" \
-F "format=webp" \
-F "watermarkText=H2I"
Any applicable shared image transformation fields may be combined in one request for action=multitask.
Endpoint #
POST /v1/pdf
Supported actions:
mergeto-imagescompressextract-imageswatermarkrotatemetadatareorderdelete-pagesextractflattenencryptdecryptsplit
The endpoint uses multipart/form-data. One optional watermarkImage upload is accepted, and for non-merge actions the first uploaded PDF is used as the primary input.
Shared PDF parameters #
actionfilessortByNamepagesformatqualitydensitywatermarkTextwatermarkImageopacitypositionfontSizecolorxydegreesorderpassworduserPasswordownerPasswordrangesprefix
Action #
action=merge
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-015" \
-F "action=merge" \
-F "files=@./samples/one.pdf" \
-F "files=@./samples/two.pdf" \
-F "sortByName=true"
Action #
action=to-images
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-016" \
-F "action=to-images" \
-F "files=@./samples/doc.pdf" \
-F "pages=all" \
-F "format=png" \
-F "density=144" \
-F "quality=85"
Action #
action=compress
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-017" \
-F "action=compress" \
-F "files=@./samples/doc.pdf"
Action #
action=extract-images
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-018" \
-F "action=extract-images" \
-F "files=@./samples/doc.pdf" \
-F "pages=all" \
-F "imageFormat=jpeg"
Action #
action=watermark
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-019" \
-F "action=watermark" \
-F "files=@./samples/doc.pdf" \
-F "watermarkText=CONFIDENTIAL" \
-F "opacity=0.3" \
-F "position=center"
Action #
action=rotate
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-020" \
-F "action=rotate" \
-F "files=@./samples/doc.pdf" \
-F "degrees=90" \
-F "pages=1,2"
Action #
action=metadata
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-021" \
-F "action=metadata" \
-F "files=@./samples/doc.pdf" \
-F "title=Updated"
Action #
action=reorder
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-022" \
-F "action=reorder" \
-F "files=@./samples/doc.pdf" \
-F "order=3,1,2"
Action #
action=delete-pages
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-023" \
-F "action=delete-pages" \
-F "files=@./samples/doc.pdf" \
-F "pages=2,4"
Action #
action=extract
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-024" \
-F "action=extract" \
-F "files=@./samples/doc.pdf" \
-F "pages=1-3"
Action #
action=flatten
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-025" \
-F "action=flatten" \
-F "files=@./samples/doc.pdf"
Action #
action=encrypt
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-026" \
-F "action=encrypt" \
-F "files=@./samples/doc.pdf" \
-F "userPassword=userpass" \
-F "ownerPassword=ownerpass"
userPassword is required for encrypt. ownerPassword is optional and defaults to userPassword if omitted. Encryption depends on qpdf being available in the runtime environment.
Action #
action=decrypt
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-027" \
-F "action=decrypt" \
-F "files=@./samples/locked.pdf" \
-F "password=userpass"
Action #
action=split
curl -sS -X POST "$BASE/v1/pdf" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-028" \
-F "action=split" \
-F "files=@./samples/doc.pdf" \
-F "ranges=1-2,3-5" \
-F "prefix=chapter_"
For PDF requests:
pagesaccepts selectors such asall,first, and CSV page rangesorderis used for page reorderrangesis required forsplitpasswordis required fordecryptuserPasswordis required forencrypt
Endpoint #
POST /v1/tools
Top-level actions:
singlemultitask
Actual tool selection is controlled through tools or tools[].
Documented tool names:
metadatacolorsdetect-formatorientationhashsimilaritydimensionsqualitytransparencyefficiency
Shared tools parameters #
actionimagestoolsortools[]includeRawExifpaletteSizehashTypequalitySampletransparencySamplesimilarityModesimilarityThresholdefficiencyFormatefficiencyQuality
Tool #
metadata
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-029" \
-F "action=single" \
-F "tools=metadata" \
-F "images=@./samples/a.jpg" \
-F "includeRawExif=true"
Tool #
colors
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-030" \
-F "action=single" \
-F "tools=colors" \
-F "images=@./samples/a.jpg" \
-F "paletteSize=8"
Tool #
detect-format
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-031" \
-F "action=single" \
-F "tools=detect-format" \
-F "images=@./samples/a.jpg"
Tool #
orientation
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-032" \
-F "action=single" \
-F "tools=orientation" \
-F "images=@./samples/a.jpg"
Tool #
hash
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-033" \
-F "action=single" \
-F "tools=hash" \
-F "images=@./samples/a.jpg" \
-F "hashType=phash"
Tool #
similarity
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-034" \
-F "action=single" \
-F "tools=similarity" \
-F "images=@./samples/a.jpg" \
-F "images=@./samples/b.jpg" \
-F "similarityMode=tofirst" \
-F "similarityThreshold=8"
Tool #
dimensions
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-035" \
-F "action=single" \
-F "tools=dimensions" \
-F "images=@./samples/a.jpg"
Tool #
transparency
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-036" \
-F "action=single" \
-F "tools=transparency" \
-F "images=@./samples/a.png" \
-F "transparencySample=64"
Tool #
quality
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-037" \
-F "action=single" \
-F "tools=quality" \
-F "images=@./samples/a.jpg" \
-F "qualitySample=256"
Tool #
efficiency
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-038" \
-F "action=single" \
-F "tools=efficiency" \
-F "images=@./samples/a.jpg" \
-F "efficiencyFormat=webp" \
-F "efficiencyQuality=80"
Action #
action=multitask
curl -sS -X POST "$BASE/v1/tools" \
-H "X-Api-Key: $API_KEY" \
-H "Idempotency-Key: idem-ext-039" \
-F "action=multitask" \
-F "tools=metadata,dimensions,hash,similarity,quality" \
-F "images=@./samples/a.jpg" \
-F "images=@./samples/b.jpg" \
-F "hashType=phash" \
-F "similarityMode=tofirst" \
-F "similarityThreshold=10" \
-F "qualitySample=256"
Notes
action=singlerequires exactly one tool.toolsandtools[]are both accepted.toolsinput is parsed as a lowercase comma-separated list.similarityModesupportspairsandtofirst.- Multitask is flat multipart form-data. There is no nested
tasks[]JSON structure in the documented implementation.
Common external errors #
Common external error codes relevant to cURL usage include:
api_key_location_not_allowedinvalid_api_keykey_expiredendpoint_not_allowedrate_limit_exceededrate_limit_store_unavailabletimeoutserver_busyfile_too_largetoo_many_filestotal_upload_exceededdimension_exceededinvalid_uploadunsupported_media_typemonthly_quota_exceededinvalid_parametermissing_fieldhtml_too_largerender_size_exceededhtml_render_failedimage_processing_failedpdf_tool_failedtool_processing_failed
Final notes #
/v1/h2iuses JSON request bodies./v1/image,/v1/pdf, and/v1/toolsusemultipart/form-data./v1/toolsreturns structured JSON analysis results rather than generated file URLs.encryptanddecryptdepend onqpdfbeing available in the runtime environment.- Generated output URLs are signed and protected for output-fetch paths according to the configured signed URL behavior.
