Skip to main content

Models

The Models API provides operations for managing models within the system. This includes viewing, creating, updating, and deleting models. Models represent key entities in the system and is associated with Digital Product Passports (DPPs) and templates.

The model creation is the first step to do nefore creating the DPP. It allows you to create the model of the product you are referring to.

View Models

1. View All Models

GET /view-models/:companyId

Description: Fetches all models for a specific company.

Parameters:

  • companyId (query parameter) - The ID of the company whose models are to be fetched.

Response

StatusDescription
200 OKSuccessfully retrieved the list of models with their images.
500 Internal Server ErrorError fetching models or generating signed URLs for images.

Response Object

{
"models": [
{
"id": "string",
"name": "string",
"company_id": "string",
"type": "string",
"images": [
{
"image": "string",
"type": "string",
"uuid": "string"
}
]
}
{
"id": "string",
"name": "string",
"company_id": "string",
"type": "string",
"images": [
{
"image": "string",
"type": "string",
"uuid": "string"
}
]
}
]
}

2. View Model

GET /view-model/:modelId

Description: Fetches details of a specific model by its ID.

Parameters:

  • modelId (path parameter) - The ID of the model to be fetched.

Response

StatusDescription
200 OKSuccessfully retrieved the model and its images.
406 Not AcceptableModel not found or failed to fetch images for the model.
500 Internal Server ErrorUnexpected error occurred while fetching model data or images.

Response Object

{
"model": {
"id": "string",
"name": "string",
"company_id": "string",
"type": "string",
"images": [
{
"image": "string",
"type": "string",
"uuid": "string"
}
]
}
}

3. Create Model

Create Model

POST /create-model

Description: Creates a new model for a company.

Request Body:

{
"company_id": "string",
"name": "string",
"type": "string",
"images": [
{
"uuid": "string",
"file": "file"
}
]
}

Response

StatusDescription
200 OKModel created successfully along with its images.
400 Bad RequestError parsing form data.
403 ForbiddenNo active subscription found or model limit reached.
406 Not AcceptableNo plan info found or no active models found for the company.
500 Internal Server ErrorError occurred during model creation or image upload.

Response Object

{
"message": "Model created successfully",
"model": {
"id": "uuid",
"name": "string",
"created_at": "string",
"updated_at": "string",
"company_id": "uuid",
"type": "string",
"images": [
{
"uuid": "uuid",
"image": "string",
"type": "string"
},
{
"uuid": "uuid",
"image": "string",
"type": "string"
}
]
},
"ok": true
}

4. Update Model

PUT /update-model/:modelId

Description: Updates an existing model by its ID.

Parameters:

  • modelId (path parameter) - The ID of the model to be updated.

Request Body:

{
"company_id": "string",
"name": "string",
"type": "string",
"images": [
{
"uuid": "string",
"file": "file"
}
]
}

Response

StatusDescription
200 OKModel updated successfully with its new data and images.
400 Bad RequestError parsing form data.
406 Not AcceptableFailed to fetch existing images for the model
500 Internal Server ErrorError occurred during model update or image processing.

Response Object

{
"ok": true,
"message": "Model updated successfully",
"model": {
"id": "uuid",
"name": "string",
"created_at": "string",
"updated_at": "string",
"company_id": "uuid",
"type": "string",
"images": [
{
"uuid": "uuid",
"image": "string",
"type": "string"
},
{
"uuid": "uuid",
"image": "string",
"type": "string"
}
]
}
}

5. Delete Model

DELETE /delete-model/:modelId

Description: Deletes a model by its ID.

Parameters:

  • modelId (path parameter) - The ID of the model to be deleted.

Response

StatusDescription
200 OKModel deleted successfully along with its associated data.
403 ForbiddenNo active subscription found for the company.
406 Not AcceptableModel not found.
500 Internal Server ErrorError occurred during model deletion or updating subscription data.

Response Object

{
"message": "Model deleted successfully",
"ok": true
}