Camera API
The Camera API provides access to the device's camera, enabling photo capture directly within POS UI extensions. The API requests camera permissions if not already enabled, opens the native camera interface, and returns the image data including dimensions, file size, and base64 string for immediate display or server upload.
Anchor to Use casesUse cases
- Photo capture: Capture photos for product documentation, damage verification, or visual records.
- Proof workflows: Create photo-based proof workflows for deliveries, returns, or customer verification.
- Visual documentation: Document inventory conditions or store displays.
- Customer engagement: Implement features requiring visual capture for custom orders or personalization.
Supported targets
- pos.
cart. line-item-details. action. menu-item. render - pos.
cart. line-item-details. action. render - pos.
customer-details. action. menu-item. render - pos.
customer-details. action. render - pos.
customer-details. block. render - pos.
draft-order-details. action. menu-item. render - pos.
draft-order-details. action. render - pos.
draft-order-details. block. render - pos.
exchange. post. action. menu-item. render - pos.
exchange. post. action. render - pos.
exchange. post. block. render - pos.
home. modal. render - pos.
home. tile. render - pos.
order-details. action. menu-item. render - pos.
order-details. action. render - pos.
order-details. block. render - pos.
product-details. action. menu-item. render - pos.
product-details. action. render - pos.
product-details. block. render - pos.
purchase. post. action. menu-item. render - pos.
purchase. post. action. render - pos.
purchase. post. block. render - pos.
register-details. action. menu-item. render - pos.
register-details. action. render - pos.
register-details. block. render - pos.
return. post. action. menu-item. render - pos.
return. post. action. render - pos.
return. post. block. render
Supported targets
- pos.
cart. line-item-details. action. menu-item. render - pos.
cart. line-item-details. action. render - pos.
customer-details. action. menu-item. render - pos.
customer-details. action. render - pos.
customer-details. block. render - pos.
draft-order-details. action. menu-item. render - pos.
draft-order-details. action. render - pos.
draft-order-details. block. render - pos.
exchange. post. action. menu-item. render - pos.
exchange. post. action. render - pos.
exchange. post. block. render - pos.
home. modal. render - pos.
home. tile. render - pos.
order-details. action. menu-item. render - pos.
order-details. action. render - pos.
order-details. block. render - pos.
product-details. action. menu-item. render - pos.
product-details. action. render - pos.
product-details. block. render - pos.
purchase. post. action. menu-item. render - pos.
purchase. post. action. render - pos.
purchase. post. block. render - pos.
register-details. action. menu-item. render - pos.
register-details. action. render - pos.
register-details. block. render - pos.
return. post. action. menu-item. render - pos.
return. post. action. render - pos.
return. post. block. render
Anchor to PropertiesProperties
The shopify global object provides camera capabilities for the POS device. Access the following properties on shopify to capture photos for documentation, verification, or customer engagement.
- Anchor to takePhototakePhototakePhoto(options?: CameraMediaOptions) => Promise<CameraMediaResponse>(options?: CameraMediaOptions) => Promise<CameraMediaResponse>requiredrequired
Launch the device's camera to take a photo.
CameraMediaOptions
Specifies configuration options for capturing photos using the device camera.
- facingMode
The camera that will be active when the camera interface first opens. - `'user'`: The front-facing camera - `'environment'`: The rear-facing camera
'user' | 'environment' - maxHeight
The maximum height (1 to 1920) of the image in pixels. Resizes the image to this height if it is larger.
number - maxWidth
The maximum width (1 to 1920) of the image in pixels. Resizes the image to this width if it is larger.
number - quality
The quality of the image returned. Percentile value between 0 (lowest quality/highest compression) and 1 (highest quality/lowest compression).
number
CameraMediaResponse
Represents the captured image and associated metadata returned by `shopify.camera.takePhoto()`.
- base64
The image data as base64 string.
string - fileSize
The file size of the image in bytes.
number - height
The height of the image in pixels.
number - type
The MIME type of the image.
string - width
The width of the image in pixels.
number
Anchor to Best practicesBest practices
- Optimize image quality: Use appropriate quality and size settings to balance image quality with file size and upload performance.
- Provide feedback: Show loading states while processing images and clear success/error messages after capture.
- Handle errors gracefully: Account for scenarios where users cancel, camera is unavailable, or permissions are denied.
Anchor to LimitationsLimitations
- Camera functionality requires the device to have a camera and appropriate permissions granted by the user.
- Only one camera operation can be in progress at a time. Attempting to call
takePhoto()while a capture is already in progress will result in a rejected promise. - Base64 strings can be memory-intensive for large images. Use appropriate
maxWidth,maxHeight, andqualitysettings to optimize performance. - The
facingModeparameter may not behave consistently on all Android devices, because camera-facing behavior varies across manufacturers. If a requested mode isn't supported, the rear-facing camera is used by default, and users can still manually switch cameras from the camera interface.