thincms_upload_media
Upload an image or file to the media library from a local file, URL, or base64 content. Automatically generates optimized WebP variants in multiple sizes.
Instructions
Upload an image or file to the media library. Provide exactly one source: filePath (local file), url (download from URL), or base64 (encoded content with filename). For images, optimized WebP variants (thumbnail 400px, medium 800px, large 1200px) are automatically generated and returned in the variants field.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | URL to download and upload | |
| base64 | No | Base64-encoded file content | |
| siteId | No | Override the active site for this single call. Pass to target a specific tenant without mutating shared active-site state — the right pattern when running concurrent agent sessions managing different tenants. Must match a siteId from your THINCMS_SITES config (use thincms_list_sites to inspect). When omitted, the call uses the active site set by thincms_switch_site. | |
| altText | No | Alt text for accessibility | |
| caption | No | Image caption | |
| filePath | No | Absolute path to a local file | |
| filename | No | Filename (required for base64, optional otherwise) | |
| visibility | No | Visibility (default: public) | |
| confirmProductionWrite | No | Acknowledge that this call may write to a configured production site (THINCMS_PRODUCTION_SITE_IDS env var). Required for any POST/PUT/PATCH/DELETE against a production-listed site; ignored otherwise. The error message lists which site triggered the requirement and recommends thincms_snapshot before any production write. |