add-profile-image
Method: POST
Path: /auth/user/{id}/profile-image
Tags: Users
Summary
Add profile image
Description
Uploads a profile image for the user. Returns the profile_image_url.
Storefront SDK Usage
SDK Method: sdk.auth.addProfileImage()
Example:
typescript
// Add profile image for a user
const input = document.querySelector<HTMLInputElement>("#file-input");
const imageFile = input?.files?.[0];
if (!imageFile) return;
const { data, error } = await sdk.auth.addProfileImage(
{ id: "01H9XYZ12345USERID" },
{ image: imageFile }
);
if (error) {
console.error("Failed to add profile image:", error.message);
} else {
console.log("Profile image added successfully");
console.log("Image URL:", data.profile_image_url);
}TypeScript Definition
typescript
"add-profile-image": {
parameters: {
query?: never;
header?: never;
path: {
/** @description user ID */
id: string;
};
cookie?: never;
};
requestBody: {
content: {
"multipart/form-data": {
/**
* Format: binary
* @description JPG, JPEG, PNG, WebP or GIF, at most 10 MB.
*/
image: string;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @description A descriptive message confirming the success or failure of the add operation. */
message: string;
/** @description Indicates whether the request was successful or failure (true for success, false for failure). */
success: boolean;
/** @description An object containing the response content. */
content: {
/** @description A string representing the URL to a profile image. */
profile_image_url: string;
};
};
};
};
400: components["responses"]["AuthBadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
/** @description The account does not exist or is inactive. */
404: components["responses"]["NotFound"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["responses"]["AuthBadRequest"] | AuthBadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
components["responses"]["NotFound"] | NotFound |
components["responses"]["InternalServerError"] | InternalServerError |
components["responses"]["GatewayTimeout"] | GatewayTimeout |
Parameters
- id (path): user ID
Request Body
Content Types: multipart/form-data
Responses
200
OK
400
Bad request
401
Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.
403
Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.
404
Requested resource not found
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
json
{
"tags": [
"Users"
],
"operationId": "add-profile-image",
"summary": "Add profile image",
"description": "Uploads a profile image for the user. Returns the `profile_image_url`.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/add-profile-image",
"description": "API reference for the add-profile-image operation"
},
"parameters": [
{
"name": "id",
"in": "path",
"description": "user ID",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"required": [
"image"
],
"properties": {
"image": {
"description": "JPG, JPEG, PNG, WebP or GIF, at most 10 MB.",
"type": "string",
"format": "binary"
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"description": "A descriptive message confirming the success or failure of the add operation.",
"type": "string"
},
"success": {
"description": "Indicates whether the request was successful or failure (true for success, false for failure).",
"type": "boolean"
},
"content": {
"description": "An object containing the response content.",
"properties": {
"profile_image_url": {
"description": "A string representing the URL to a profile image.",
"type": "string"
}
},
"required": [
"profile_image_url"
],
"type": "object"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/AuthBadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"description": "The account does not exist or is inactive.",
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "auth",
"x-speakeasy-ignore": true,
"x-speakeasy-name-override": "addProfileImage"
}Auto-generated from OpenAPI spec and TypeScript definitions