Prerequisites
The Assets REST API is available on each out-of-the-box install of a recent AEM version.
Key Concepts
The Assets REST API offers REST-style access to assets stored within an AEM instance.
It uses the /api/assets
endpoint and requires the path of the asset to access it (without the leading /content/dam
).
- This means that to access the asset at:
/content/dam/path/to/asset
- You need to request:
/api/assets/path/to/asset
For example, to access /content/dam/wknd/en/adventures/cycling-tuscany
, request /api/assets/wknd/en/adventures/cycling-tuscany.json
/api/assets
does not need the use of the.model
selector./content/path/to/page
does require the use of the.model
selector.
The HTTP method determines the operation to be executed:
- GET - to retrieve a JSON representation of an asset or a folder
- POST - to create new assets or folders
- PUT - to update the properties of an asset or folder
- DELETE - to delete an asset or folder
The exact format of supported requests is defined in the API Reference documentation.
Transactional Behavior
All requests are atomic.
This means that subsequent (write
) requests cannot be combined into a single transaction that could succeed or fail as a single entity.
AEM (Assets) REST API versus AEM Components
Aspect | Assets REST API | AEM Component (components using Sling Models) |
---|---|---|
Supported use-case(s) | General purpose. |
Optimized for consumption in a Single Page Application (SPA), or any other (content consuming) context. Can also contain layout information. |
Supported operations |
Create, Read, Update, Delete. With additional operations depending on the entity type. | Read-only. |
Access |
Can be accessed directly. Uses the An example path would look like: |
Needs to be referenced through an AEM component on an AEM page. Uses the An example path would look like: |
Security |
Multiple options are possible. OAuth is proposed; can be configured separately from standard setup. | Uses AEM's standard setup. |
Architectural remarks |
Write access will typically address an author instance. Read may also be directed to a publish instance. | As this approach is read-only, it will typically be used for publish instances. |
Output | JSON-based SIREN output: verbose, but powerful. Allows for navigating within the content. | JSON-based proprietary output; configurable through Sling Models. Navigating the content structure is hard to implement (but not necessarily impossible). |
Security
If the Assets REST API is used within an environment without specific authentication requirements, AEM’s CORS filter needs to be configured correctly.
In environments with specific authentication requirements, OAuth is recommended.
Available Features
Content Fragments are a specific type of Asset, see Working with Content Fragments.
For further information about features available through the API see:
- The Assets REST API
- Entity Types, where the features specific to each supported type (as relevant to Content Fragments) are explained
Paging
The Assets REST API supports paging (for GET requests) via the URL parameters:
offset
- the number of the first (child) entity to retrievelimit
- the maximum number of entities returned
The response will contain paging information as part of the properties
section of the SIREN output. This srn:paging
property contains the total number of (child) entities ( total
), the offset and the limit ( offset
, limit
) as specified in the request.
Example: Paging
GET /api/assets.json?offset=2&limit=3
...
"properties": {
...
"srn:paging": {
"total": 7,
"offset": 2,
"limit": 3
}
...
}
...
Entity Types
Folders
Folders act as containers for assets and other folders. They reflect the structure of the AEM content repository.
The Assets REST API exposes access to the properties of a folder; for example, its name, title, and so on. Assets are exposed as child entities of folders, and sub-folders.
Assets
If an asset is requested, the response will return its metadata; such as title, name and other information as defined by the respective asset schema.
The binary data of an asset is exposed as a SIREN link of type content
.
Assets can have multiple renditions. These are typically exposed as child entities, one exception being a thumbnail rendition, which is exposed as a link of type thumbnail
( rel="thumbnail"
).
Content Fragments
A content fragment is a special type of asset. They can be used to access structured data, such as texts, numbers, dates, among others.
As there are several differences to standard assets (such as images or audio), some additional rules apply to handling them.
Representation
Content fragments:
-
Do not expose any binary data.
-
Are completely contained in the JSON output (within the
properties
property). -
Are also considered atomic, that is, the elements and variations are exposed as part of the fragment’s properties vs. as links or child entities. This allows for efficient access to the payload of a fragment.
Content Models and Content Fragments
Currently the models that define the structure of a content fragment are not exposed through an HTTP API. Therefore the consumer needs to know about the model of a fragment (at least a minimum) - although most information can be inferred from the payload; as data types, and so on. are part of the definition.
To create a content fragment, the (internal repository) path of the model has to be provided.
Associated Content
Associated content is currently not exposed.
Using
Usage can differ depending on whether you are using an AEM author or publish environment, together with your specific use case.
-
It is strongly recommended that creation is bound to an author instance (and currently there is no means to replicate a fragment to publish using this API).
-
Delivery is possible from both, as AEM serves requested content in JSON format only.
-
Storage and delivery from an AEM author instance should suffice for behind-the-firewall, media library applications.
-
For live web delivery, an AEM publish instance is recommended.
-
/api
.Read/Delivery
Usage is via:
GET /{cfParentPath}/{cfName}.json
For example:
http://<host>/api/assets/wknd/en/adventures/cycling-tuscany.json
The response is serialized JSON with the content structured as in the content fragment. References are delivered as reference URLs.
Two types of read operations are possible:
- Reading a specific content fragment by path, this returns the JSON representation of the content fragment.
- Reading a folder of content fragments by path: this returns the JSON representations of all content fragments within the folder.
Create
Usage is via:
POST /{cfParentPath}/{cfName}
The body has to contain a JSON representation of the content fragment to be created, including any initial content that should be set on the content fragment elements. It is mandatory to set the cq:model
property and it must point to a valid content fragment model. Failing to do so will result in an error. It is also necessary to add a header Content-Type
which is set to application/json
.
Update
Usage is via
PUT /{cfParentPath}/{cfName}
The body has to contain a JSON representation of what is to be updated for the given content fragment.
This can simply be the title or description of a content fragment, or a single element, or all element values and/or metadata.
Delete
Usage is via:
DELETE /{cfParentPath}/{cfName}
Limitations
There are a few limitations:
- Content fragment models are currently not supported: they cannot be read or created. To be able to create a content fragment, or update an existing one, developers have to know the correct path to the content fragment model. Currently the only method to get an overview of these is through the administration UI.
- References are ignored. Currently there are no checks on whether an existing content fragment is referenced. Therefore, for example, deleting a content fragment might result in issues on a page that contains a reference to the deleted Content Fragment.
- JSON data type The REST API output of the JSON data type is currently string based output.
Status Codes and Error Messages
The following status codes can be seen in the relevant circumstances:
-
200 (OK)
Returned when:- requesting a content fragment via
GET
- successfully updating a content fragment via
PUT
- requesting a content fragment via
-
201 (Created)
Returned when:- successfully creating a content fragment via
POST
- successfully creating a content fragment via
-
404 (Not found)
Returned when:- the requested content fragment does not exist
-
500 (Internal server error)
NOTE
This error is returned:- when an error that cannot be identified with a specific code has happened
- when the given payload was not valid
The following lists common scenarios when this error status is returned, together with the error message (monospace) generated:
-
Parent folder does not exist (when creating a content fragment via
POST
) -
No content fragment model is supplied (cq:model is missing), cannot be read (due to an invalid path or a permission problem) or there is no valid fragment model:
No content fragment model specified
Cannot create a resource of given model '/foo/bar/qux'
-
The content fragment could not be created (potentially a permission problem):
Could not create content fragment
-
Title and or description could not be updated:
Could not set value on content fragment
-
Metadata could not be set:
Could not set metadata on content fragment
-
Content element could not be found or could not be updated
Could not update content element
Could not update fragment data of element
The detailed error messages are usually returned in the following manner:
{ "class": "core/response", "properties": { "path": "/api/assets/foo/bar/qux", "location": "/api/assets/foo/bar/qux.json", "parentLocation": "/api/assets/foo/bar.json", "status.code": 500, "status.message": "...{error message}.." } }
API Reference
See here for detailed API references:
Additional Resources
For further information see:
Experience Manager
Adobe Experience Manager Assets at Summit
Register for these developer sessions:
- Rapid Feature Releases with AEM Cloud: Telegraph Media Group’s RDE Strategy (attend online)
- Put the Customer at the Center and Build Relationships That Last a Lifetime (attend online)
- A Damn Good DAM: Intel’s Blueprint for Enterprise-Wide Asset Management (attend online)
- The True Cost of a Failed Implementation (attend online)
- Elevate and Empower Teams with Agentic AI for Exceptional Experiences (attend online)
Connect with Experience League at Summit!
Get front-row access to top sessions, hands-on activities, and networking—wherever you are!
Learn more