Skip to main content

Examples

Query examples
Link copied!

Getting an Asset by the ID
Link copied!

In the query below, we are querying for the createdDate and label of three specific assets using each of their ids.

{
assets(
id: [
"QXNzZXQ6MWMzYTUzNDUtM2I1Yi00ZjdmLThjNWItOTY0ZDBlYWE4ZDI1"
"QXNzZXQ6OWU2YjM4ZjUtN2FjZC00MjJhLWIwZWEtMjE4MWRiNzU3MmI0"
"QXNzZXQ6MzcxMWYyNGEtNzE5MS00ZjM2LWJmZjUtNTM4YzFkMjY5MDli"
]
) {
edges {
node {
label
createdDate
}
}
}
}

This query gives us the following response:

{
"data": {
"assets": {
"edges": [
{
"node": {
"label": "woman-in-blue-dress-on-beach.jpg",
"createdDate": "2022-07-14T08:52:48.143Z"
}
},
{
"node": {
"label": "woman-in-chair.jpg",
"createdDate": "2021-10-06T11:17:25.208Z"
}
},
{
"node": {
"label": "woman-in-winter-coat.jpg",
"createdDate": "2022-07-14T08:52:48.143Z"
}
}
]
}
}
}

Getting the Asset Repositories
Link copied!

If you would like to access the asset repositories for the current user or API client, you would use the following query:

{
viewer {
mediaHubs {
edges {
node {
assetRepositories (first: 10) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
label
}
}
}
}
}
}
}
}

Getting the Asset Folders
Link copied!

To get the asset repositories and asset folders for the current user or api client, you would use the following query:

{
viewer {
mediaHubs {
edges {
node {
assetRepositories (first: 10) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
label
assetFolders (first:20) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
label
children {
id
label
}
}
}
}
}
}
}
}
}
}
}
}

Getting the Media Hub ID
Link copied!

If you would like to obtain the mediaHubId that is needed for the createTransformationTemplate mutation you would use the following query:

query {
viewer {
mediaHubs {
edges {
node {
id
__typename
}
}
}
}
}

Getting the Organization id
Link copied!

To get the organization id that is needed for the removeBackgroundFromImage mutation you can use the following query:

query {
viewer {
organizations {
edges {
node {
id
name
}
}
}
}
}

Mutation examples
Link copied!

deleteAssets
Link copied!

The following mutation query example details how you would delete assets by ID:

mutation {
deleteAssets(input:{
id: [
"QXNzZXQ6NzA4MmFlMTItNzY3Ny00MDhjLTk1YzMtMmEwYzFlZGZhMzk1",
"QXNzZXQ6ZmZmZjIwZTktOTljMC00NTM1LWEzZDItNjE1ZDBmZTU0YjVi",
"QXNzZXQ6ZmZmZjIwZTktOTljMC00NTM1LWEzZDItNjE1ZDBmZTU0YjVi",
"QXNzZXQ6ZmZmZjIwZTktOTljMC00NTM1LWEzZDItNjE1ZDBmZTU0YjVi"]
})
}

updateAssets
Link copied!

The following mutation query example details how you would update assets by specific id:

mutation {
updateAsset(input:{
id: "QXNzZXQ6NjIxN2FjNGQtMzcxMi00YzI4LThlMDctOTFlYmM3ZmY5NDIw"
assetFolderId: "QXNzZXRGb2xkZXI6OGI4N2Y2ODgtY2MwNy00NmM3LWE3OTItZGNjYThmNmRiMGE2"
})
{
id
}
}

updateAssetMetadata
Link copied!

The following mutation query example details how you would update the metadata of your assets by a specific id, with the inclusion of what you would like the existing meta data to be replaced by:

mutation {
updateAssetMetadata(input:{
id: "QXNzZXQ6Y2NmOTMxYjMtZmQ2NS00OWExLThlMTEtYjYzOTEyZDgzY2Nj"
metadataSchemaName: "exif"
metadata: {
description: "my description"
author: "Olly"
}
})
{
id
__typename
}
}

Personal access token examples
Link copied!

Personal access tokens(PATs) can be used to authorize access to the GraphQL Asset Management API and Dynamic Content Management API. Access tokens are associated with users within an organization.

Creating an access token
Link copied!

To create a PAT use the createPersonalAccessToken mutation and send the organizationId and a name as input.

mutation {
createPersonalAccessToken(
input: {
name: "My personal access token"
organizationId: "T4JnYW5penF0aW9uOm9yZ18QVUI0OU51NDF4eU4zanZQ"
}
) {
id
name
token
createdDate
lastUsedDate
}
}

Listing your access tokens
Link copied!

This query will list all tokens assigned to the user.

query {
viewer {
personalAccessTokens {
id
name
token
createdDate
lastUsedDate
}
}
}

Deleting an access token
Link copied!

Use thedeletePersonalAccessToken mutation to delete a token. The token will be revoked and can no longer be used for authentication.

mutation {
deletePersonalAccessToken(
input: {
id: "UGVyc29uYWxBY2Nlc3NUb2tlbjoyZjM4YTFhOS1jNzZkLTRmMzQtOTFmYS02NTJkMDliNmVlZGUvZWI4ZGJmMTgtMGY0Yi00OWFmLWI0YWUtZjZjOGUzZTNkNWNk"
}
)
}