Files
The Digital Product Passport Files API allows you to manage the lifecycle of DPP Files, including creating, viewing, updating, and deleting DPP Files.
A DPP files allows you to upload file, with name and description, to the DPP object.

1. Create DPP File
POST /models/:modelId/dpps/:dppId/upload-file
Request Body
{
  "dpp_type": "uuid",
  "model_id": "uuid",
  "file": "file",
  "name": "string",
  "description": "string",
  "dpp_id":"string",
  "user_id": "string",
  "hash":"string"
}
Response
| Status | Description | 
|---|---|
| 200 OK | File uploaded successfully and the corresponding record created. | 
| 400 Bad Request | No file provided or error parsing request body. | 
| 500 Internal Server Error | Failed to upload the file or unexpected error occurred during creation. | 
Response Object
{
    "message": "string",
    "ok": true,
    "file": {
        "id": "string",
        "dpp_id": "string",
        "created_at": "string",
        "updated_at": "string",
        "created_by": "string",
        "description": "string",
        "name": "string",
        "notarized": false,
        "path": "string",
        "type": "string",
        "hash": "string",
        "signedUrl": "string"
    }
}
2. view DPP Files
GET /view-dpp-files/:dppId
Response
| Status | Description | 
|---|---|
| 200 OK | Successfully retrieved the list of DPP files with their signed URLs. | 
| 500 Internal Server Error | Failed to fetch the DPP files or generate their signed URLs. | 
Response Object
{
    "files": [
        {
            "id": "string",
            "dpp_id": "string",
            "created_at": "string",
            "updated_at": "string",
            "created_by": "string",
            "description": "string",
            "name": "string",
            "notarized": false,
            "path": "string",
            "type": "string",
            "hash": "string",
            "url": "string"
        }
    ]
}
3. view DPP File
GET /models/:modelId/view-dpp-file/:dppId/file/:fileId
Response
| Status | Description | 
|---|---|
| 200 OK | Successfully retrieved the DPP file with its signed URL | 
| 406 Not Acceptable | The specified DPP file was not found. | 
| 500 Internal Server Error | Failed to fetch the DPP file or generate its signed URL. | 
Response Object
{
    "file": [
        {
            "id": "string",
            "dpp_id": "string",
            "created_at": "string",
            "updated_at": "string",
            "created_by": "string",
            "description": "string",
            "name": "string",
            "notarized": false,
            "path": "string",
            "type": "string",
            "hash": "string",
            "url": "string"
        }
    ]
}
4. Update DPP Files
PUT /models/:modelId/update-dpp-file/:dppId/file/:fileId
Request Body
{
  "company_id": "string",
  "file":"file",
  "name": "string",
  "description": "string",
  "hash":"string",
}
Response
| Status | Description | 
|---|---|
| 200 OK | File updated successfully with new information and signed URL. | 
| 400 Bad Request | Error parsing request body or missing required fields. | 
| 406 Not Acceptable | The specified file or DPP was not found. | 
| 500 Internal Server Error | Failed to update the file or unexpected error occurred during the update. | 
Response Object
{
    {
    "message": "File updated successfully",
    "ok": true,
    "file": [
        {
            "id": "string",
            "dpp_id": "string",
            "created_at": "string",
            "updated_at": "string",
            "created_by": "string",
            "description": "string",
            "name": "string",
            "notarized": false,
            "path": "string",
            "type": "string",
            "hash": "string",
            "signedUrl": "string"
        }
    ]
}
}
5. Delete DPP Files
DELETE /models/:modelId/delete-dpp-file/:dppId/file/:fileId
Response
| Status | Description | 
|---|---|
| 200 OK | File deleted successfully from the database and storage. | 
| 406 Not Acceptable | The specified file or DPP was not found. | 
| 500 Internal Server Error | Failed to delete the file or unexpected error occurred during the deletion. | 
Response Object
{
    {
    "message": "File ${string} in DPP ${string} deleted successfully",
    "ok": true,
    
    }
}