Copy deals into a new pipeline

I need to copy deals from a given pipeline who match some criteria into a new pipeline.

Criteria will be something like this:
- Deals who are on a specific stage, OR
- Deals who has certain custom_properties

Is there any easy way to do this using the API?
I was thinking about:
1- Get all the deals from the given pipeline
2- Filter the deals - keep only those who match the criteria
3- For each deal obtained from #2:
3.1 Create a new deal into the new pipeline with the same properties
Question
- What is the best way to solve points 1 and 2?
- Is there any way to filter the deals using this endpoint? Accounts Dashboard | HubSpot
Thanks!

Hey @alfonsoromanz , the deals API doesn’t currently support filtering/sorting. You would need to construct a way on your end to filter the JSON results, or another way I can think of is you can create a smart list of contacts that have associated deals which matches your criteria (using deal properties filter). You can then pull in those contacts and get the deals associated with those contacts.

https://developers.hubspot.com/docs/methods/lists/get_list_contacts

Thank you @JasminLin!
16x16_smiley-happy.png.png