Kustomer api customer/search for messages with attachments


This is a kustomer api specific question.

Having Kustomer api endpoint, docs are here. I want to receive messages with attachments (attachment namecontentTypecontentLength).

The body for this request (simplified version):

"and": [
"message_channel": {
"equals": ["email"]
"queryContext": "message"

The problem here - the standard response does not include all the info about attachments that I need. The question is - Is there any documentation on request body params aggs and fields(I think they may help)? Is it possible somehow to change the request body, so that message attachments are included in response as well?

I am trying to minimise the number of calls to kustomer api - get all the info in one go.

Thank you for your time.


Best answer by derek.parson 17 May 2023, 17:25

View original

3 replies

Badge +2



Thanks for reaching out here about this. A great question with a couple different ways to the solution. Using the query parameters you’ve shared will return messages and their data. If a message has an attachment included this will be found in the relationships attribute seen here:

From here you can then either get the attachment by it listed ID with this endpoint ({message_id}/attachments/{id}) or you could just get all listed attachments by removing the id parameter at the end so it would be{message_id}/attachments.


The other option you have is to search for messages where you know attachments are present using different search query parameters. Example here:


Which is equivalent to this in the UI:


Both options require the same amount of API requests but the amount of data returned in the second search is a bit more targeted and provides relevant information for what you’re looking to find.

I hope this helps!


Thank you,

Derek Parson

Sr. Technical Support Engineer




Thanks for reaching out here about this. A great question with a couple different ways to


Thank you for your answer, Derek. That is exactly what I do at the moment - getting attachment ids from relationships and then query separate attachments for the info.

But it is not exactly what I would like to have. What I really need instead - is get the attachment info (file name, content length etc.) in the search itself. I was thinking about the request body parameters aggs and fields (these params do not have much info on them in docs). May they be of any help - like specifying additional fields for messages or something. I will add picture from the customers search documentation

aggs and fields


Badge +2

I see, thank you for sharing that!

The fields parameter is used for setting the columns displayed on a saved search so that wouldn’t be helpful to us here and the aggs parameter is used in conjunction with an internal tool called intelligence to populate Sentiment in the insights panel of a search.

So unfortunately both would not be helpful to us here and it seems this is likely an API limitation on the Kustomer side at the moment.

I’d recommend submitting a feature request outlining what you’re trying to accomplish and how the current API endpoints are coming up just short for you resulting in many requests from your end. Our product teams are always looking to improve the platform for our users and I think what we’ve discussed here would benefit many Kustomer clients trying to accomplish the same goal as you here.