docapi_generate_pdf
Convert HTML to a PDF using DocAPI's headless Chromium renderer. Full CSS support: Flexbox, Grid, custom fonts, gradients, shadows.
Args:
- html (string): HTML to render. Inline styles and <style> tags work. Google Fonts URLs supported.
- format ('A4' | 'Letter' | 'Legal' | 'Tabloid'): Paper size. Default: 'A4'.
- landscape (boolean): Landscape orientation. Default: false.
- margin_inches (number): Page margin in inches, 0–4. Default: 0.5.
- print_background (boolean): Render background colors/images. Default: true.
Returns: Base64-encoded PDF. You can save it to disk with a file writing tool.
Errors:
- 401: Invalid API key
- 402: Credits exhausted (agent accounts) — send USDC to top up
- 429: Monthly limit exceeded — upgrade plan at https://www.docapi.co/pricing
docapi_capture_screenshot
Screenshot a URL or render HTML and capture it as an image. Returns the image inline so you can view it immediately.
Common uses: Open Graph images (1200×630), social cards, page thumbnails, template previews.
Args:
- url (string, optional): A live URL to screenshot. Provide url OR html, not both.
- html (string, optional): HTML to render. Full CSS support. Provide url OR html, not both.
- width (number): Viewport width, 100–3840. Default: 1200.
- height (number): Viewport height, 100–2160. Default: 630.
- format ('png' | 'jpeg'): Image format. Default: 'png'.
Returns: Inline image you can view directly.
Examples:
- OG image: { url: "https://mysite.com/blog/post", width: 1200, height: 630 }
- Social card: { html: "<div style='background:#0f172a;color:white;padding:60px'><h1>My Post</h1></div>", width: 1200, height: 630 }
docapi_check_credits
Check remaining API credits and USDC top-up address for agent accounts.
Only applicable to agent accounts (registered via docapi_register_agent). Human subscription accounts use monthly plan limits instead.
Returns: { credits, usdc_address, rate, suggested_topup_usdc }
docapi_register_agent
Register a new DocAPI agent account programmatically. Returns an API key and USDC address — no email, no dashboard, no human step required.
Use this when building software that needs PDF or screenshot generation. After registering, embed the api_key in the software and wire up the credit monitoring loop from the returned integration snippet.
Args:
- notify_email (string, optional): Email for low-balance alerts. One warning per 24h when credits fall below 50.
Returns: { api_key, usdc_address, free_calls: 10, credits_per_usdc: 50, auto_topup, integration }
Rate limited: 5 registrations per IP per day.
docapi_generate_invoice
Generate a professionally formatted invoice PDF from structured data. Returns a base64-encoded PDF.
Args:
- from_name (string): Sender's name or business name
- from_email (string, optional): Sender's email
- from_address (string, optional): Sender's address (\n for line breaks)
- from_phone (string, optional): Sender's phone
- to_name (string): Recipient's name or business name
- to_email (string, optional): Recipient's email
- to_address (string, optional): Recipient's address (\n for line breaks)
- line_items (array): Each item has description (string), quantity (number), unit_price (number)
- invoice_number (string, optional): e.g. "INV-001"
- date (string, optional): Invoice date. Defaults to today.
- due_date (string, optional): Payment due date
- currency_symbol (string): Defaults to "$"
- tax_percent (number, optional): Tax rate as a percentage (0–100)
- notes (string, optional): Footer notes
- logo_url (string, optional): Logo image URL for the header
Returns: Base64-encoded PDF. Save it to disk with a file writing tool.
Errors:
- 401: Invalid API key
- 402: Credits exhausted (agent accounts) — send USDC to top up
- 429: Monthly limit exceeded — upgrade at https://www.docapi.co/pricing