I used services as an example, but the same could apply to the incidents API.
Hi @pmansfield,
I’m afraid you’re correct. Currently the PagerDuty REST API does not support regex or wildcard matching in query parameters for endpoints like /services
or /incidents
. The name
parameter only supports exact matches, and partial string or pattern-based searches aren’t available via the API at this time. You can see this in the PagerDuty API docs, and search docs.
The usual workaround is to paginate through all results and then filter them locally using jq
an grep
. I understand this is not ideal, but it’s the only way to achieve pattern-based filtering right now.
Funny that I tried doing the exact same thing earlier this week when searching the /vendors
API to help a user, and ended up iterating through each page using jq
, which took longer than it needed. 
I believe Regex support is available in other parts of PagerDuty, like event orchestration and email integrations, but not for API object searches.
I’ll reach out to the API team and run this by them to see if there are any blockers or challenges, but if you’d like to see this feature added, I recommend submitting feedback to PagerDuty support or through your account team in the meanwhile to generate some traction. Please feel free to include a link to this topic.
Let me know if I can help with anything else, and have a nice weekend!
Hi @pmansfield
You can use the query
parameter with the /services
endpoint, although it’s not documented (I’m not sure why it’s not documented; but it was available in the pagerduty cli, so I went digging).
query
doesn’t support a full regex, it’s really a contains
match. It is at least case-insensitive, which is helpful. It also only applies to the name of the object, in this case the service name. For users it will match first or last name. I think it’s available for all objects, but I haven’t dug that deeply into it; I’m going off what Martin had in the cli code, which had query
as a base argument for all objects.
So if I’m digging in one of my sandboxes and send a GET /services?query=shop
, I get back one example list:
Fabulous Shop Database
Fabulous Shop Frontend
Fabulous Shop Search Caching
Fabulous Shop Search Service Backend
Fabulous Shop Shopping Cart Backend
Shopping Cart - Microservices Demo
Shopping Cart - Pulumi Demo-f7d625c
If using query
doesn’t cull your records enough, you might want to take a look at the pagination docs. Pagination is definitely awkward if you are using shell scripts or command line tools, but usable from Python or Go.
@lupimiguel query works on the /vendors
endpoint as well. Python example here.
HTH. Sorry for the confusion. We’ll see if we can get that param documented better.
--mandi