/{app_slug}/v1/me/avatarAuthUpload (or replace) the EndUser avatar
PNG/JPEG/WEBP only — SVG is rejected (stored-XSS vector). ≤2 MB. Magic bytes are sniffed; a mislabeled file is rejected. The image is re-encoded server-side (orientation baked in, all metadata incl. EXIF/GPS stripped, bounded to 512×512, webp). An uploaded avatar takes precedence over a provider-captured picture.
Path parameters
app_slug*stringSlug of the app.
Response · 201
avatar_url*stringStable avatar URL (`/:appSlug/v1/avatars/:accountId`). Safe to cache and hotlink — it 302s to a fresh short-lived presigned GET on every hit.
Example: "https://api.auth.productcraft.co/my-app/v1/avatars/8f14…"
Example
Request
POST https://api.auth.productcraft.co/{app_slug}/v1/me/avatar
Authorization: Bearer YOUR_TOKENimport { Auth } from "@productcraft/auth";
// Admin routes read PRODUCTCRAFT_API_KEY; consumer routes need no key
const auth = new Auth();
const avatarUrl = await auth.consumer("my-app").me.uploadAvatar({ file: new File(["…"], "image.png", { type: "image/png" }) });auth.consumer(…).me.uploadAvatar(params, options?): Auth.AvatarUrl
Response
{
"avatar_url": "https://api.auth.productcraft.co/my-app/v1/avatars/8f14…"
}