Skip to content

Images

PUT /media retains an image for your website and verifies its bytes against the supplied descriptor. It requires edit permission. PNG, JPEG and WebP are supported, with a maximum retained file size of 30 MiB.

The request contains asset and base64 bytes. Obtain your website UUID from PulpSense with your activation details. Use the image’s actual pixel dimensions.

This Node.js example reads a WebP file and constructs the descriptor:

import { readFile } from "node:fs/promises";
import { createHash } from "node:crypto";
const baseUrl = "https://seo.pulpsense.com/api/website-publishing/v1";
const websiteId = process.env.PULPSENSE_WEBSITE_ID;
const bytes = await readFile("./consultation-room.webp");
const sha256 = createHash("sha256").update(bytes).digest("hex");
const key = `managed/${websiteId}/${sha256}.webp`;
const response = await fetch(`${baseUrl}/media`, {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.PULPSENSE_WEBSITE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
asset: {
contractVersion: 1,
websiteId,
bucket: "ai-seo-client-content",
key,
url: `https://seo.pulpsense.com/api/content-media/${key}`,
sha256,
mimeType: "image/webp",
sizeBytes: bytes.length,
width: 1600,
height: 900,
provenance: { source: "Practice-supplied consultation room photograph" },
},
bytes: bytes.toString("base64"),
}),
});
if (!response.ok) throw new Error(`Upload failed: ${response.status}`);
const { asset: uploadedAsset } = await response.json();

Replace width, height and provenance with the actual image’s details. For JPEG use .jpg and image/jpeg; for PNG use .png and image/png. Hash the exact bytes being uploaded, and keep the website ID, key, hash and MIME type consistent.

The response is {"saved":true,"asset":...}. Use that returned asset as the article’s cover. Include meaningful imageAlt with new articles and cover replacements. The API verifies that the image belongs to the same website and is retrievable before saving article ownership.

The upload retains an image; it does not publish an article or modify a page by itself. Read the article endpoints for the next step.