How to Automatically Subscribe to a Jira Search Filter with REST API

I created a search filter in Jira using the following request:

POST /rest/api/2/filter

This was successful. Now, I would like to know if there’s a way to automatically subscribe to that filter using the REST API instead of having to do it manually.

I came across the documentation mentioning the “subscriptions” property, but I’m unclear on the correct syntax to use. Can someone guide me on how to achieve this? Thank you!

In my experience, the REST API capability for subscriptions is somewhat limited compared to manual operations through the Jira UI. However, you can accomplish this using a workaround. After creating the filter, you can create a subscription job for it using the endpoint: /rest/api/2/filter/{filterId}/favorite. You will need to send a POST request granting access to the users you want to subscribe. Note, authorization and selecting the correct headers are crucial here; you might need to ensure administrative privileges for adding users.

I would suggest using a scripting tool like one written in Python with the JIRA library, which can help automate the whole process including subscribing to a filter. By leveraging the library, you can handle authentication and API calls more conveniently. Specifically, you’d want to create a script to access the filterSubscription functionality in the API. Do ensure you have the correct permissions before you proceed to subscribe users automatically. Such scripting can save time and reduce manual errors.