Enrolling Contact to Workflow Through API Not Working


#1

I’m having trouble adding a contact to a workflow through the API. Here are the details of the request:

HUBSPOT WORKFLOW URL
https://api.hubapi.com/contacts/v1/lists/375/add?hapikey=[KEY]

HUBSPOT CONTACT DATA
{"properties":[{"property":"email","value":"[EMAIL]"},{"property":"firstname","value":"Sam"},{"property":"lastname","value":"Brodie"}]}

HUBSPOT REQUEST RESULT
Array
(
[headers] => Array
(
[access-control-allow-credentials] => false
[content-type] => application/json; charset=UTF-8
[x-hubspot-notfound] => true
[vary] => Accept-Encoding
[date] => Fri, 22 Jul 2016 19:05:06 GMT
[content-length] => 182
[connection] => close
)

[body] => {"status":"error","message":"Couldn't find a List with the given id '375'.","correlationId":"[KEY]","requestId":"[KEY]"}
[response] => Array
    (
        [code] => 404
        [message] => Not Found
    )

[cookies] => Array
    (
    )

[filename] => 

)

If I go to https://api.hubapi.com/contacts/v1/lists/static?count=300&hapikey=[KEY] there is an item with listId 375:

dynamic: false,
metaData: {
  processin: "DONE",
  size: 0,
  error: "",
  stProcessingStateChangeAt: 1468861144978,
  lastSizeChangeAt: 0
},
name: "Workflow: [WORKFLOW], Enrolled List (Automation)",
filters: [ ],
portalId: [ID],
createdAt: 1468861144978,
internal: true,
listId: 375,
updatedAt: 1468861144978,
authorId: [ID],
listType: "STATIC",
internalListId: 425

Note that I also tried using the internalListId number, 425 and got the same error.

What am I doing wrong?


#2

@sambrodie,

You should use the workflowId not the listId as that is an internal property. You can find the workflow ID either by using GET /automation/v3/workflows see docs.

Or you will find it in the URL if you navigate to the workflow in the HubSpot UI.

Sebastian