Models
The ModelsResource class manages Product Models, which serve as the "blueprints" or templates for your product lines. A Model defines shared characteristics, branding, descriptions, and images that are inherited by all individual Digital Product Passports (DPPs) created under it.
Methods
list
Retrieves all product models associated with the company configured in the SDK.
Signature
async list(options?: RequestOptions): Promise<Models[]>
Parameters
| Parameter | Type | Description |
|---|---|---|
| options | RequestOptions | (Optional) Custom request configuration. |
Returns
Promise<Models[]>: An array of product models associated with the currentcompanyId.
get
Retrieves the full details and metadata of a specific product model.
Signature
async get(id: string, options?: RequestOptions): Promise<Models>
Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | The unique identifier (UUID) of the model. |
| options | RequestOptions | (Optional) Custom request configuration. |
create
Creates a new product model. This method automatically handles FormData construction, allowing you to upload multiple images along with the model metadata.
Signature
async create(data: CreateModel, options?: RequestOptions): Promise<Models>
Example
const model = await sdk.models.create({
name: "Eco-Runner 2024",
description: "Sustainable athletic footwear",
type: "unique",
images: [
{
uuid: "img-001",
file: myFileBlob // File or Blob object
}
],
created_at: new Date().toISOString()
});
Parameters
| Parameter | Type | Description |
|---|---|---|
| data | CreateModel | Object containing name, description, type, and an optional array of images. |
| options | RequestOptions | (Optional) Custom request configuration. |
update
Updates an existing product model's information. Like create, this method supports updating the model's images via FormData.
Signature
async update(id: string, data: UpdateModel, options?: RequestOptions): Promise<Models>
Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | The unique identifier of the model to update. |
| data | UpdateModel | The updated fields (name, description, images, type). |
| options | RequestOptions | (Optional) Custom request configuration. |
delete
Permanently deletes a product model and the underlying dpps from the system.
Signature
async delete(id: string, options?: RequestOptions): Promise<void>
Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | The unique identifier of the model to delete. |
Technical Notes
Error Handling
If a request fails—for instance, if a model ID is not found or the user lacks permissions—the resource will throw an SDKError.
try {
const model = await sdk.models.get("non-existent-id");
} catch (error) {
if (error instanceof SDKError) {
console.error(`Status: ${error.status}, Message: ${error.message}`);
}
}
[!TIP] Use models to standardize your product data. Changes made to a Model's metadata (like a description or type) provide a centralized way to categorize the DPPs that belong to that production line.