Mautic Community Forums

REST API: How to get multiple campaigns in one request?

Is there a way to get multiple campaigns by id using the API?

I know there is /api/campaigns, and I was able to search them via /api/campaigns?search=someText

Yet I would like to do something like /api/campaigns?search=id:1,5,4711

The reason is: We have a lot of campaigns, and the request will be performed by a mobile device. The result set of all campaigns is huge, which causes a significant overhead. Also, because Mautic returns all properties of the campaign, including the whole setup.

Important: I also need the contacts of all the requested campaigns. Currently, I can only get them by calling /api/campaigns/{id}/contacts, which is super ineffective if you want to test if a user is in one of these campaigns. It takes ages.

(Is there a description of the search parameter in general? Couldn’t find it.)

(I also know that there is /api/campaign/id, but this is super slow if you want to retrieve multiple ids.)

1 Like