---
title: "Upload an asset"
method: POST
path: "/papi/project/{projectId}/assets"
tags: ["Assets"]
---

# Upload an asset

`POST /papi/project/{projectId}/assets`

## Request

- Base URL: `https://api.websitepublisher.ai`
- URL: `https://api.websitepublisher.ai/papi/project/{projectId}/assets`
- Auth: OAuth 2 (authorization code, authorization URL `https://api.websitepublisher.ai/dapi/oauth/authorize`, token URL `https://api.websitepublisher.ai/dapi/oauth/token`, scopes: `read`, `write`)

Upload a file (image, font, PDF, etc). Provide base64 content OR a source_url (public HTTPS URL) — not both. source_url is recommended for DALL-E/Unsplash images. Always use the returned url field in your HTML.

## Path parameters

- `projectId` integer, required

## Request body

- AssetCreate
  - `slug` string, required: Desired file path for the asset. Used for upload only — use the returned url field in your HTML.
  - `content` string: Base64 encoded file content (no data: prefix). Use this OR content_text OR source_url — exactly one.
  - `content_text` string: Plain text content for text-based assets (JS, JSX, TS, TSX, CSS, JSON, SVG, TXT, HTML, XML, MD, CSV). Preferred over content (base64) for text files — saves ~33% tokens. Use this OR content OR source_url — exactly one.
  - `source_url` string, uri: Public HTTPS URL to fetch the file from (e.g. DALL-E image URL, Unsplash). Use this OR content, not both. Supports images, PDF, fonts, ico. For CSS/SVG/JSON use content instead.
  - `alt` string: Alt text for images

## Response `201`

Uploaded

---

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