# Enroll to workflow via API

**URL:** <https://community.hubspot.com/t/enroll-to-workflow-via-api/60400>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [July 6, 2022, 5:19am UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400 "2022-07-06T05:19:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![imarquez](https://avatars.discourse-cdn.com/v4/letter/i/bc8723/32.png) [@imarquez](https://community.hubspot.com/u/imarquez)\
**Post date:** [July 6, 2022, 5:19am UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400/1 "2022-07-06T05:19:02Z")

</div>

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](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”

}

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [July 11, 2022, 3:59pm UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400/2 "2022-07-11T15:59:41Z")

</div>

@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](https://legacydocs.hubspot.com/docs/methods/workflows/v3/get_workflows). When I used the ID given from the API, it worked. Otherwise, I received the same error that you did.

---

<div class="post-metadata">

**Author:** ![nychd](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@nychd](https://community.hubspot.com/u/nychd)\
**Post date:** [November 13, 2023, 9:34pm UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400/3 "2023-11-13T21:34:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robbieboy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robbieboy/32/75635_2.png) [@robbieboy](https://community.hubspot.com/u/robbieboy)\
**Post date:** [July 27, 2022, 4:40pm UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400/4 "2022-07-27T16:40:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![imarquez](https://avatars.discourse-cdn.com/v4/letter/i/bc8723/32.png) [@imarquez](https://community.hubspot.com/u/imarquez)\
**Post date:** [July 27, 2022, 4:44pm UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400/5 "2022-07-27T16:44:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robbieboy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robbieboy/32/75635_2.png) [@robbieboy](https://community.hubspot.com/u/robbieboy)\
**Post date:** [July 27, 2022, 4:54pm UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400/6 "2022-07-27T16:54:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Albanmana](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@Albanmana](https://community.hubspot.com/u/Albanmana)\
**Post date:** [January 12, 2023, 2:07pm UTC](https://community.hubspot.com/t/enroll-to-workflow-via-api/60400/7 "2023-01-12T14:07:08Z")

</div>

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\](https://api.hubapi.com/automation/ **v2** /workflows/37919934/enrollments/contacts/%5C*your%5C_email%5C)\*

Hope it helps 🙂
