Skip to content
Skip to main contentWhere does your team stand on AI adoption?
CONTACT SALESSTART BUILDING

Assets

Retrieve and filter assets stored in your Builder Space. Use these operations to query media by type, folder, and other attributes to support content delivery and management workflows.

Assets refer to media content uploaded to Builder. For more details on assets, see Asset Library.

Get all assets

To get all assets from your Builder Space, use the following query.

Framework

Query

const response = await adminSDK .query({ assets: { id: true, name: true, url: true, bytes: true, lastUsed: true, type: true, folders: true, createdDate: true } });

Response

{ "data": { "assets": [ { "id": "...", "name": "My Image", "url": "...", "bytes": 380892, "lastUsed": 1745956615894, "type": "image/jpeg", "folders": ["folder-id-1", "folder-id-2"], "createdDate": "2024-01-15T10:30:00Z" } ] } }

Sort assets

Use the following query to sort your assets by a particular key, such as the asset's name.

Framework

Query

const response = await adminSDK .query({ assets: [ { input: { sort: { name: "-1" // or 1 } } }, { id: true, name: true, url: true, bytes: true, lastUsed: true, type: true, folders: true } ] });

Response

{ "data": { "assets": [ { "id": "...", "name": "My Image", "url": "...", "bytes": 380892, "lastUsed": 1745956615894, "type": "image/jpeg", "folders": ["folder-id-1", "folder-id-2"], "createdDate": "2024-01-15T10:30:00Z" } ] } }

Filter assets by type

To filter assets by media type (such as images, videos, or specific formats), use the type field. Note that this corresponds to the MIME type of the asset.

Framework

Query

const response = await adminSDK .query({ assets: [ { input: { query: { type: { $eq: "image/svg+xml" } }, sort: { createdDate: "descending" } } }, { id: true, name: true, url: true, type: true, folders: true, createdDate: true } ] });

Response

{ "data": { "assets": [ { "id": "...", "name": "My Icon", "url": "...", "type": "image/svg+xml", "folders": ["folder-id-1"], "createdDate": "2024-01-15T10:30:00Z" } ] } }

Common asset types:

image/jpeg: jpeg images

image/png: png images

image/svg+xml: svg images

image/gif: gif images

image/webp: webp images

video/mp4: mp4 videos

application/pdf: pdf documents

Filter assets by folder

To filter assets by folder, use the folders field with the folder ID. Assets can belong to multiple folders, so folders is an array field.

Framework

Query

const response = await adminSDK .query({ assets: [ { input: { query: { folders: { $in: ["your-folder-id"] } }, sort: { createdDate: "descending" } } }, { id: true, name: true, url: true, type: true, folders: true, createdDate: true } ] });

Response

{ "data": { "assets": [ { "id": "...", "name": "Folder Asset", "url": "...", "type": "image/png", "folders": ["your-folder-id"], "createdDate": "2024-01-15T10:30:00Z" } ] } }

Filter assets by type and folder

You can combine multiple filters to get more specific results. For example, to get all SVG images from a specific folder:

Framework

Query

const response = await adminSDK .query({ assets: [ { input: { query: { type: { $eq: "image/svg+xml" }, folders: { $in: ["your-folder-id"] } }, sort: { createdDate: "descending" }, limit: 50 } }, { id: true, name: true, url: true, type: true, folders: true, createdDate: true } ] });

Response

{ "data": { "assets": [ { "id": "...", "name": "My SVG Icon", "url": "...", "type": "image/svg+xml", "folders": ["your-folder-id"], "createdDate": "2024-01-15T10:30:00Z" } ] } }

Using variables for dynamic queries

Framework

Query

const input = { query: { type: { $eq: "image/svg+xml" }, folders: { $in: ["your-folder-id"] } }, sort: { createdDate: "descending" }, limit: 20 }; const response = await adminSDK .query({ assets: [ { input }, { id: true, name: true, url: true, type: true, folders: true, createdDate: true, bytes: true, lastUsed: true } ] });

Available query operators

$eq: equal

$ne: not equal

$in: in array

$nin: not in array

$exists: field exists

$regex: regular expression match

Example with multiple operators:

Framework
const response = await adminSDK .query({ assets: [ { input: { query: { type: { $in: ["image/jpeg", "image/png"] }, name: { $regex: "logo" }, folders: { $exists: true } } } }, { id: true, name: true, url: true, type: true, folders: true } ] });

This query returns jpeg or png images that have "logo" in their name and belong to at least one folder.

What's next

Continue to explore the Admin API documentation or use the GraphQL Explorer to try out these queries with your own Space and Organization. Then, visit the Admin API GraphQL Schema for more details on how to modify your queries.

Was this article helpful?