Create workflow using API in PHP

Hello, I’m using the hubspot-api-php package to interact with HubSpot in the Laravel framework. However, I can’t seem to find the Workflow API. Can anyone suggest how to perform operations with workflows similar to how I interact with HubSpot objects? I am able to interact with HubSpot objects, but I need guidance on working with workflows.

Hi @KPadhiyar

Here is the link to the workflow API. They are in the BETA version right now but you can use them

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

@GRajput Thanks for your answer. But I’ve already done some code with it. It shows me internal error.

$requestBody = [
 "type" => "CONTACT_FLOW",
 "name" => "Test WorkFlow",
 "description" => "Test WorkFlow",
 "canEnrollFromSalesforce" => false,
 "isEnabled" => true,
 "flowType" => "WORKFLOW",
 "actionId" => "1",
 "revisionId" => "1",
 "actionTypeVersion" => 0,
 "actionTypeId" => "0-3",
 "crmObjectCreationStatus" => "COMPLETE",
 "objectTypeId" => "0-1",
 "enrollmentCriteria" => [
 "shouldReEnroll" => true,
 "type" => "MANUAL"
 ],
 "actions" => [
 [
 "type" => "SINGLE_CONNECTION",
 "actionId" => "1",
 "actionTypeVersion" => 0,
 "actionTypeId" => "0-3",
 "fields" => [
 "task_type" => "TODO",
 "subject" => "Check in with lead",
 "body" => "<p>Remember to sync up with new lead!</p>",
 "use_explicit_associations" => "true",
 "priority" => "NONE"
 ]
 ]
 ]
];

$response = Http::withToken("access_token")
 ->accept("application/json")
 ->timeout(30)
 ->post("https://api.hubapi.com/automation/v4/flows", $requestBody);

$responseBody = $response->json();

I’ve tried the above code. Could you please suggest what I might be missing?
FYI: I’ve write code based on documetation.