I am looking to get the content (html/ampscript) value of content blocks programmatically from Salesforce Marketing Cloud.

I successfully make a call to /v2/token with my clientid and secret with the scope "documents_and_images_read" and it returns a bearer token.

I then use that token to call GET /asset/v1/content/categories and successfully returns a JSON array of the folders within my MID.

I then call GET /asset/v1/content/assets/1001663 but it returns a 404 and no response body despite that ID being inside one of the categories listed in the prior call.

I have also tried using the UUID value instead of the numeric value.

Any thoughts on gaps?

Note: When the bearer token expires, the 404 changes to unauthorized.

  • 1
    Is that ID a categoryID or asset ID? Commented Oct 16, 2020 at 20:54

1 Answer 1


Judging from your question, I have a couple options to help and thoughts on what the potential issue is you are facing.

Option 1:

Use the 'get all' endpoint to get each and iterate through it page by page.

GET /asset/v1/content/assets
Host: {{subdomain}}.rest.marketingcloudapis.com
Content-Type: application/json
Authorization: Bearer {{auth_token}}

This will return a JSON array with all the content blocks in your BU. You then iterate through each object and grab the content property (which one to grab varies depending on the asset type) from the object in the array to get the HTML. This will include ALL CB assets though, including emails, images, etc.

You can add a filter onto this via: $filter=assetType.name=htmlemail or similar to narrow down the results. Which brings us to...

Option 2

You can use a filter (or advanced query endpoint) to filter it based on category ID to mimic what I am assuming you are attempting to do in your question.

GET /asset/v1/content/assets?$filter=category.id={{categoryID}}
Host: {{subdomain}}.rest.marketingcloudapis.com
Content-Type: application/json
Authorization: Bearer {{auth_token}}

This will return a JSON Array of assets that exist in that category ID. I mention this because I think the 1001663 you are mentioning that you got from /asset/v1/content/categories is the categoryid (folder id) and not an assetId (id for an individual asset). Which is why it is tossing an error.

If you put an ID that is not a valid ID in to that endpoint, it will just send back an error code of 404 since it does not exist and therefore was not found.

  • You're correct, I did show a category number. However, upon going to the base /asset/v1/content/assets without any IDs, I get an insufficient privileges error. I have validated it has the scope as noted above and I am able to list categories, and the app has scope the the MID in the original auth request. The assets are not shared. Any thoughts on that error?
    – Carl K
    Commented Oct 18, 2020 at 19:06
  • Did you verify the package you created (clientId/secret) has the correct permissions assigned there? You cannot add permissions to the API Scope if the package does not have it already. Commented Oct 19, 2020 at 12:02
  • Yes, confirmed. However, though trial and error, I just removed all scopes from the API auth call and now it works successfully. It's odd
    – Carl K
    Commented Oct 20, 2020 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .