Platform API reference

Platform API · Workspaces

post/v1/workspaces/{workspace_slug}/avatar/from-url/previewAuth

Preview the workspace image a website or image address would set

Fetches the address and returns the image it would set, without saving anything. An image address is used as is; for a web page, its best icon is used (apple-touch-icon, the largest `<link rel="icon">` or SVG icon, web app manifest icons, then `/favicon.ico`; square and at least 64 px preferred). Fetching is https only, to public addresses only (re-checked on every redirect, at most 4), 5 s per request, at most 2 MB; the format is read from the bytes (PNG, JPEG, WebP, GIF first frame, ICO, SVG rasterised; an SVG with script or external references is refused). Gated by `workspace.settings.update`.

Path parameters

workspace_slug*string

Slug of the workspace. Platform routes name the workspace by slug, positionally in the SDK (`platform.workspaces.retrieve("acme")`); the product APIs bind `workspace_id` instead.

Request body

url*string · uri

A website or an image address. An image is used as is; for a page, its icon is used (apple-touch-icon, then `<link rel="icon">`, then the web app manifest, then `/favicon.ico`). `https://` is assumed when no scheme is given, and `http://` is upgraded to `https://`.

Example: "https://acme.com"

Response · 200 What the address resolves to.

source_url*string · uri

The address that was given, normalised (https, no fragment). Saved as `avatar_source_url` when the image is set.

Example: "https://acme.com/"

image_url*string · uri

The image that was found: the address itself, or the icon found on that page.

Example: "https://acme.com/apple-touch-icon.png"

source_kind*object

Where the image came from. Open enum: new values may be added.

Example: "apple_touch_icon"

site_host*string

Host of the site the image came from (after redirects), for copy like "Found the icon of acme.com".

Example: "acme.com"

width*number

Width in px of the image as it will be stored (at most 512).

Example: 180

height*number

Height in px of the image as it will be stored (at most 512).

Example: 180

preview_data_url*string

The image exactly as it will be stored (webp), as a `data:` URL, so a preview needs no second request.

Example: "data:image/webp;base64,UklGR…"

Example

Request

POST https://api.platform-auth.productcraft.co/v1/workspaces/{workspace_slug}/avatar/from-url/preview
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "url": "https://acme.com"
}

Response

{
  "source_url": "https://acme.com/",
  "image_url": "https://acme.com/apple-touch-icon.png",
  "source_kind": "apple_touch_icon",
  "site_host": "acme.com",
  "width": 180,
  "height": 180,
  "preview_data_url": "data:image/webp;base64,UklGR…"
}