Enroll to workflow via API

Hi -
We’re trying to create a custom job that enrolls a specific customer based on checks we do.
Im trying to call this specific api
https://api.hubapi.com/automation/v2/workflows/:workflowId/enrollments/contacts/:email
but im always getting the error. I have validated the email and workflow id to be existing and set the proper permissions for the bearer token being used.

{

“status”: “error”,

“message”: “resource not found”,

“correlationId”: “d733a5a8-7463-4bb3-bd3b-d3626c6da229”

}

@imarquez

Where did you grab the workflow ID? I did a test and used what I thought was the ID which I grabbed from the url in browser, but noticed it does not mirror the id given when I get all workflows through the API. When I used the ID given from the API, it worked. Otherwise, I received the same error that you did.

Thank you for sharing this! I was doing the same thing and you solved my problem for me.

Did grabbing the ID from the workflow get api work for you? I’m using a valid ID and contact email and cannot get it to work. I get a 404 no matter which way I send the request. Could there be something else I’m missing? Thanks.

hi robbie -

you have to fetch them through the api and get the id from the response, the id in the url is actually a different identifier which is not the identifier that the api uses.

I’ve talked with the support team and this was expected behaviour.

Thanks for getting back so quick iMarquez I started by grabbing the id from the URL, but am now using the “workflowId” variable from the get api with the same result. Must be a different problem. Maybe because I’m using the HAPI key in the url and it’s getting phased out?

Hi @robbieboy I messed around a bit and found why the request was failing.

You just have to change the “v3” into “v2” so that it looks like this :

https://api.hubapi.com/automation/**v2**/workflows/37919934/enrollments/contacts/\*your\_email\*

Hope it helps :slightly_smiling_face: