Assets API
Overview
The Assets API allows you to add Assets to the system such as images and PDF files. This page covers the common endpoints and methods associated with the Assets API.
Authentication
Use the following header parameters for all requests:
Headers | |
---|---|
Authentication string required | Authentication bearer token See Authentication Guide |
X-IAA-OW-ID integer required | Organization Workspace ID Header |
Assets Details
Get a List of All Assets
GET /api/v3/asset/listProperties | |
---|---|
id integer | Asset ID |
storagePath string | File path of Asset |
cdnUrl string | URL of Asset |
created integer | Unix epoch timestamp of Asset creation, in milliseconds |
modifiedDate string | Date Asset modified |
disposable boolean | Indicates whether Asset is temporary and can be purged (true), default: true |
- JSON
- TypeScript
Response 200
{
"success": true,
"data": [
{
"id": 1,
"storagePath": "assets/201427/tfteBYO_1704204958735.jpg",
"cdnUrl": "https://d3jme5si7t6llb.cloudfront.net/assets/201427/tfteBYO_1704204958735.jpg",
"created": 1704204961147,
"modifiedDate": "2024-01-02T14:16:08.726+0000",
"disposable": false
},
{
"id": 2,
"storagePath": "assets/201427/b7c0tTw_1704204968864.jpg",
"cdnUrl": "https://d3jme5si7t6llb.cloudfront.net/assets/201427/b7c0tTw_1704204968864.jpg",
"created": 1704204971010,
"modifiedDate": "2024-01-02T14:16:11.375+0000",
"disposable": false
},
{
"id": 3,
"storagePath": "assets/201427/2mBGamD_1704205759807.jpg",
"cdnUrl": "https://d3jme5si7t6llb.cloudfront.net/assets/201427/2mBGamD_1704205759807.jpg",
"created": 1704205761106,
"modifiedDate": "2024-01-02T08:59:21.508+0000",
"disposable": false
}
]
}
See TypeScript Prerequisites page for usage.
import {
getInstance
} from "prerequisites"
const axios = getInstance();
interface Responses {
200: {
content: {
"application/json": {
success: boolean;
data: {
id: number;
storagePath: string;
cdnUrl: string;
created: number;
modifiedDate: string;
disposable: boolean
}[]
}
}
}
}
function getAllAssets(): Promise<Responses> {
const options = {
method: 'GET',
url: 'https://app.iqm.com/api/v3/asset/list',
};
return axios.request(options).then(({ data }: { data: Responses }) => data);
}
Get Asset Details
GET /api/v3/asset/{assetId}Get properties of a single Asset by ID.
Path Parameters | |
---|---|
assetId integer | Asset ID |
- JSON
- TypeScript
Response 200
{
"success": true,
"data": {
"id": 1,
"storagePath": "new/path/to/asset.jpg",
"cdnUrl": "https://cdn.example.com/new_asset.jpg",
"created": 1704204961147,
"modifiedDate": "2024-01-18T06:03:23.823+0000",
"disposable": true
}
}
See TypeScript Prerequisites page for usage.
import {
getInstance
} from "prerequisites"
const axios = getInstance();
interface Responses {
200: {
content: {
"application/json": {
success: boolean;
data: {
id: number;
storagePath: string;
cdnUrl: string;
created: number;
modifiedDate: string;
disposable: boolean
}
}
}
}
}
function getAssetDetails(): Promise<Responses> {
const options = {
method: 'GET',
url: 'https://app.iqm.com/api/v3/asset/{assetId}',
params: {
path: {
assetId: `number`
}
}
};
return axios.request(options).then(({ data }: { data: Responses }) => data);
}
Assets Management
Add Multiple Assets
POST /api/v3/assetAdd multiple Assets to the system. Request accepts an array of multipart file objects and their corresponding metadata.
Parameters | ||||||
---|---|---|---|---|---|---|
filesMetadata array of objects required | Object array in JSON string | |||||
|
attachedFileName string | Name of asset |
originalFileName string | Name of uploaded multipart file |
files
multipart/formdata file required
- JSON
- TypeScript
Formdata Sample
------WebKitFormBoundaryAofpaWXja6BTaYQ9
Content-Disposition: form-data; name="files"; filename="example.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryAofpaWXja6BTaYQ9
Content-Disposition: form-data; name="filesMetadata"
[{"attachedFileName":"example.jpg","originalFileName":"example.jpg"}]
------WebKitFormBoundaryAofpaWXja6BTaYQ9--
Response 200
{
"success": true,
"data": {
"example.jpg": {
"assetID": 697,
"assetCDNURL": "https://d3jme5si7t6llb.cloudfront.net/assets/201427/IHp2jMI_1704987233847.jpg"
}
}
}
import axios from "axios";
import * as fs from "fs";
import * as path from "path";
import FormData from "form-data";
async function addAssets(filesMetadata: String, filePaths: string[]): Promise<any> {
const form = new FormData();
form.append("filesMetadata", filesMetadata);
for (const filePath of filePaths) {
const stream = fs.createReadStream(filePath);
form.append("files", stream, path.basename(filePath));
}
const headers = {
...form.getHeaders(),
Authorization: `Bearer [TOKEN]`, // replace this with actual bearer token
"x-iaa-ow-id": '[OWID]', // replace with your actual ow id
};
const response = await axios.post(
"https://app.iqm.com/api/v3/asset",
form,
{
headers,
timeout: 10000,
timeoutErrorMessage: 'Request timed out after 10 seconds'
}
);
console.log(JSON.stringify(response.data));
return response.data;
}
(async () => {
const metadata: { attachedFileName: string; originalFileName: string; }[] = [
{
attachedFileName: "example.png",
originalFileName: "example.png"
}
]
try {
const result = await addAssets(JSON.stringify(metadata), ["example.png"]); // you should have this file in the folder
console.log("Upload successful:", result);
} catch (error) {
console.error("Upload failed:", error);
}
})();
Update Asset Details
PATCH /api/v3/asset/{assetId}Update the details of an existing Asset by ID
Path Parameters | |
---|---|
assetId integer | Asset ID |
Request Schema | |
---|---|
storagePath string | File path of Asset |
cdnUrl string | Asset CDN URL |
disposable boolean | Indicates whether Asset is temporary and can be purged (true), default: true |
- JSON
- TypeScript
Request Sample
{
"storagePath": "string",
"cdnUrl": "string",
"disposable": true
}
Response 200
{
"success": true,
"data": {
"statusCode": 200,
"responseObject": {
"message": "Asset updated successfully"
}
}
}
See TypeScript Prerequisites page for usage.
import {
getInstance
} from "prerequisites"
const axios = getInstance();
interface Responses {
200: {
content: {
"application/json": {
success: boolean;
data: {
statusCode: number;
responseObject: {
message: string
}
}
}
}
};
401: {
content: {
"application/json": {
success?: boolean;
errorObjects?: {
error?: string;
reason?: string;
field?: string;
}[];
data?: Record<string, never>;
}
}
}
}
function updateAssetDetails(): Promise<Responses> {
const options = {
method: 'PATCH',
url: 'https://app.iqm.com/api/v3/asset/{assetId}',
params: {
path: {
assetId: `number`,
}
},
requestBody: {
content: {
"application/json": {
storagePath?: `string`,
cdnUrl?: `string`,
disposable?: `boolean`,
}
}
},
};
return axios.request(options).then(({ data }: { data: Responses }) => data);
}
Delete Asset
DELETE /api/v3/asset/{assetId}Delete single Asset by ID
Path Parameters | |
---|---|
assetId integer | Asset ID |
- JSON
- TypeScript
Response 200
{
"success": true,
"data": "Asset deleted successfully."
}
See TypeScript Prerequisites page for usage.
import {
getInstance
} from "prerequisites"
const axios = getInstance();
interface Responses {
200: {
content: {
"application/json": {
success: boolean;
data: string
}
}
};
401: {
content: {
Authorization?: string;
"X-IAA-OW-ID"?: string;
};
path: {
assetId: number;
}
}
}
function deleteAsset(): Promise<Responses> {
const options = {
method: 'DELETE',
url: 'https://app.iqm.com/api/v3/asset/{assetId}',
params: {
path: {
assetId: `number`
}
}
};
return axios.request(options).then(({ data }: { data: Responses }) => data);
}