# Assets (Admin)

Assets are media resources that can be used inside commerce entities ecosystem, like images or videos.

We don't export an endpoint to upload assets directly by our api as we use some 3rd party service provider like Cloudinary to maintain that assets in the web. So, to upload some asset and use it into your products, you must create an asset upload request using this module which will give to you all needed informations to upload your media asset directly using the [Cloudinary API](https://cloudinary.com/documentation/image_upload_api_reference).

Assets are maintained by commerce service and have its lifecycle. So, when you request to upload some asset, you must keep in mind some things:

* The signature that you will receive to upload expires in 1 hour.
  * After that time, if you don't upload anything to Cloudinary using that signature, your asset will be expired and you will need to get a new asset signature.
* Uploaded assets must be associated to some product at maximum 3 days after the upload.
  * If the uploaded asset was not associated, it will be automatically removed and the asset will expire
* Assets that are unassociated from all products (after some time of use) are automatically removed
  * If you have more than one product associated to the same asset, don't worry. We just remove assets that are not associated to anything.

<details>

<summary>Asset Model (Example)</summary>

```json
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "createdAt": "2022-11-04T10:31:50.112Z",
  "updatedAt": "2022-11-04T10:31:50.112Z",
  "companyId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "type": "image",
  "status": "waiting_upload",
  "provider": "cloudinary",
  "directLink": "https://dummyimage.com/200x200/fff/000",
  "providerUploadParams": {
    "apiKey": "000000000000",
    "timestamp": 1666215568,
    "publicId": "commerce/3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "signature": "bfd09f95f331f558cbd1320e67aa8d488770583e",
    "signedParams": "filename_override=false&public_id=commerce/3fa85f64-5717-4562-b3fc-2c963f66afa6&timestamp=1666215568&unique_filename=true",
    "queryParams": {
      "filename_override": "false",
      "public_id": "commerce/3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "timestamp": "1666215568",
      "unique_filename": "true"
    }
  }
}
```

</details>

## Service Methods

### Create asset and get upload request signature

{% hint style="info" %}
Remember to inform all signed query params into your Cloudinary request, otherwise your signature will be not valid.
{% endhint %}

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/assets" method="post" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://w3block.gitbook.io/w3block-eng/dev-docs/api/commerce-api-services/company-administration/assets-admin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
