---
title: "Execute python-pptx code in sandbox"
method: POST
path: "/v1/render/code"
tags: ["sandbox"]
---

# Execute python-pptx code in sandbox

`POST /v1/render/code`

## Request

- Base URL: `https://api.slideforge.dev`
- URL: `https://api.slideforge.dev/v1/render/code`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Run arbitrary python-pptx code in a secure sandbox and get a PPTX file + PNG preview. The code is a python-pptx script (the presentation it saves is the output), or a `build(prs)` function (`build(prs, slide)` when chrome is provided). All python-pptx helpers (add_text_box, add_box, add_icon, etc.) are available. Dangerous imports are blocked. 30-second timeout.

Use this for custom layouts, novel visualizations, or any slide that needs full layout control. $0.05 per render. ~2 seconds.

## Request body

- SandboxRenderRequest
  - `code` string, nullable: Python code defining build(prs) or build(prs, slide). Required if job_id not provided. Max 64 KB — well above any real slide; the Jev screen (A2) screens the whole thing, so an unbounded field would let a padded payload slip past a prefix screen.
  - `job_id` string, nullable: Previous render_code job ID — loads its code for patching with replacements.
  - `replacements` Replacement[], nullable: String replacements to apply to the loaded code. Requires job_id.
    - `old` string, required: Exact string to find in the code
    - `new` string, required: String to replace it with
  - `theme_id` string, nullable: Theme ID for chrome + colors
  - `logo_id` string, nullable: Uploaded logo (upload_asset purpose=logo): the account's logo inside the code — add_logo(slide) draws it in the theme's logo box.
  - `chrome` object, nullable: Chrome overlays: title, subtitle, footer, etc.
  - `headline` string, nullable: Slide title (chrome-rendered; use build(prs, slide))
  - `context` string, nullable: Subtitle line under the title (chrome-rendered)
  - `takeaway` string, nullable: Bottom takeaway band (chrome-rendered)
  - `source_note` string, nullable: Source citation in the footer zone (chrome-rendered)
  - `notes` string, nullable: Speaker notes for the presenter; never drawn on the slide. Wins over notes the code wrote.
  - `name` string, nullable: Human-readable job name
  - `include_preview` string, nullable: Embed preview inline: none, small (256px), default (768px), full. Default: none.
  - `verify` string: Verification tier: off | lint (default — static geometry linter + composer content validators, no LLM) | lint+vlm (adds the VLM second-look, ~+8s) | full.
  - `dry_run` boolean: If true: run the verify tier and return status (validated if clean, invalid if errors) + warnings/errors with cost:0 and NO PPTX — a free pre-commit check. Fix errors, then render for real.
  - `quality_profile` string, nullable: Readiness thresholds the layout block is judged against: executive | technical (default) | appendix.
  - `fail_on_vlm` string[], nullable: VLM finding categories that BLOCK (escalate to errors, render free per usable-or-free): substring match on the finding, e.g. ['contrast', 'clipping']. A high-confidence `overlap` and any `content_missing` already block by default. Requires verify=lint+vlm.
  - `content` object, nullable: Typed business facts (ADR 2026-07-14): available read-only as CONTENT inside the code; the renderer verifies every leaf rendered verbatim and emits fidelity + provenance. Keys named 'id' are references, not display content.
  - `code_profile` string, nullable: widgets_only = compose via add_widget + approved helpers + CONTENT/theme only; raw python-pptx (slide.shapes.*, add_text_box/add_box, add_slide) is rejected. Omit or 'native' for full access. Response echoes code_profile.applied + violations.

## Response `200`

Render complete with signed URLs

- unknown

## Other responses

- `400`: Code validation failed (syntax error, blocked import, script made no presentation)
- `402`: Insufficient balance
- `408`: Execution timed out (30s limit)
- `422`: Validation Error

---

[API](https://skmtc.dev/slideforge/apis/slideforge-api.md) · [All operations](https://skmtc.dev/slideforge/apis/slideforge-api/llms.txt) · [OpenAPI document](https://skmtc.dev/slideforge/apis/slideforge-api/revisions/ae698e3d3c00?raw)
