# How to create actions

**URL:** <https://community.hubspot.com/t/how-to-create-actions/98235>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [January 19, 2024, 4:46pm UTC](https://community.hubspot.com/t/how-to-create-actions/98235 "2024-01-19T16:46:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AqsaQayyum](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@AqsaQayyum](https://community.hubspot.com/u/AqsaQayyum)\
**Post date:** [January 19, 2024, 4:46pm UTC](https://community.hubspot.com/t/how-to-create-actions/98235/1 "2024-01-19T16:46:50Z")

</div>

Hi,  
I have created private application and done it’s authentication. It’s working fine.  
Now, I want to create multiple actions for my application. How can I do this. I want to create actions like following attached screenshot.  
What are the steps for it.

 ![Screenshot 2024-01-19 at 9.26.30 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/4/1435f6a840b96f168c825f45ad8cc282e010b95c.png)

 ![Screenshot 2024-01-19 at 9.27.09 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/3/83ce439d3fe99731b692150fecaf67a3b5290139.png)

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [January 20, 2024, 1:42am UTC](https://community.hubspot.com/t/how-to-create-actions/98235/2 "2024-01-20T01:42:05Z")

</div>

Hi @AqsaQayyum 👋

Just to confirm, are you referring to HubSpot Custom **Workflow** Actions? If so, as far as I’m aware, you won’t be able to achieve this with a HubSpot Private App. You’ll instead need to create a “Public” App and then create your Custom Workflow Actions via API. Here’s [HubSpot’s official documentation](https://developers.hubspot.com/docs/api/automation/custom-workflow-actions) for this feature.

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![AqsaQayyum](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@AqsaQayyum](https://community.hubspot.com/u/AqsaQayyum)\
**Post date:** [January 22, 2024, 7:06am UTC](https://community.hubspot.com/t/how-to-create-actions/98235/3 "2024-01-22T07:06:45Z")

</div>

Hi [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) ,  
Yeah I want to create Hubsppot custom workflow actions.  
I created publc application and tried following API by passing my APP\_ID and Developer\_Key. I got respoonse from this API but didn’t know where I could see it’s reflection or changes on my hubspot application UI.  
this is the API that I tried:

app.post(‘/action’, async (req, res) =\> {

try {

const requestData =

{

“actionUrl”: “[https://webhook.site/ad466dc7-b126-4ce1-bc7d-3f672e50d277](https://webhook.site/ad466dc7-b126-4ce1-bc7d-3f672e50d277)”,

“objectTypes”: [

“CONTACT”

],

“inputFields”: [

{

“typeDefinition”: {

“name”: “staticInput”,

“type”: “string”,

“fieldType”: “text”

},

“supportedValueTypes”: [

“STATIC\_VALUE”

],

“isRequired”: true

},

{

“typeDefinition”: {

“name”: “objectInput”,

“type”: “string”,

“fieldType”: “text”

},

“supportedValueTypes”: [

“OBJECT\_PROPERTY”

],

“isRequired”: true

},

{

“typeDefinition”: {

“name”: “optionsInput”,

“type”: “enumeration”,

“fieldType”: “select”,

“optionsUrl”: “[https://webhook.site/94d09471-6f4c-4a7f-bae2-c9a585dd41e0](https://webhook.site/94d09471-6f4c-4a7f-bae2-c9a585dd41e0)”

},

“supportedValueTypes”: [

“STATIC\_VALUE”

]

}

],

“inputFieldDependencies”: [

{

“dependencyType”: “SINGLE\_FIELD”,

“dependentFieldNames”: [

“objectInput”

],

“controllingFieldName”: “staticInput”

}

],

“outputFields”: [

{

“typeDefinition”: {

“name”: “myOutput”,

“type”: “string”,

“fieldType”: “text”

},

“supportedValueTypes”: [

“STATIC\_VALUE”

]

}

],

“objectRequestOptions”: {

“properties”: [

“email”

]

},

“labels”: {

“en”: {

“inputFieldLabels”: {

“staticInput”: “Static Input”,

“objectInput”: “Object Property Input”,

“optionsInput”: “External Options Input”

},

“actionName”: “My Extension”,

“actionDescription”: “My Extension Description”,

“appDisplayName”: “My App Display Name”,

“actionCardContent”: “My Action Card Content”

}

},

“functions”: [

{

“functionType”: “POST\_ACTION\_EXECUTION”,

“functionSource”: “exports.main = (event, callback) =\> {\r\n callback({\r\n outputFields: {\r\n myOutput: \“example output value\”\r\n }\r\n });\r\n}”

},

{

“functionType”: “POST\_FETCH\_OPTIONS”,

“functionSource”: “exports.main = (event, callback) =\> {\r\n callback({\r\n \“options\”: [{\r\n \“label\”: \“Big Widget\”,\r\n \“description\”: \“Big Widget\”,\r\n \“value\”: \“10\”\r\n },\r\n {\r\n \“label\”: \“Small Widget\”,\r\n \“description\”: \“Small Widget\”,\r\n \“value\”: \“1\”\r\n }\r\n]\r\n });\r\n}”

}

]

};

const response = await axios.post(‘[https://api.hubspot.com/automation/v4/actions/{appId}?hapikey={developer\_API\_key](https://api.hubspot.com/automation/v4/actions/%7BappId%7D?hapikey=%7Bdeveloper_API_key)}’, requestData, {

headers: {

// ‘Content-Type’: ‘application/x-www-form-urlencoded’

}

});

console.log(“action response checking ====”, response);

} catch (error) {

console.error(‘Error during token exchange:’, error.response ? error.response.data : error.message);

res.status(500).send(‘Error during token exchange’);

}

});  
Can yoou please let me knoe about it. Thank you so much.  
Best Regards,  
Aqsa Qayyum.

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [January 23, 2024, 11:22pm UTC](https://community.hubspot.com/t/how-to-create-actions/98235/4 "2024-01-23T23:22:41Z")

</div>

Hi @AqsaQayyum 👋

Based on my experience, testing custom workflow actions before making them available to your app users can be difficult.

First, I’d suggest creating a Test Public App (separate to your “Production” app, that only you will install within Test HubSpot Accounts). Make sure to set the status of your test custom action to “published”. This can be achieved within your custom action definition like this:

```lia-code-sample
{
 "actionUrl": "https://www.example.com",
 "published": true,

 ...
 ...
 ... 

 "objectTypes": [
 "CONTACT",
 "DEAL",
 "COMPANY",
 "TICKET"
 ]
}

```

You’ll then need to install your Test HubSpot Public App within a Test HubSpot Account/Portal. Then create a Workflow within that test portal in order to debug your custom action.

Note that sometimes the changes you make to your custom action via API can take a while to be reflected within HubSpot. It’s been a while since I last tested this, but previously changes were taking anywhere between 5 and 30 minutes to be reflected in HubSpot. Hopefully things have improved since then​🤞

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![AqsaQayyum](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@AqsaQayyum](https://community.hubspot.com/u/AqsaQayyum)\
**Post date:** [January 24, 2024, 5:58pm UTC](https://community.hubspot.com/t/how-to-create-actions/98235/5 "2024-01-24T17:58:04Z")

</div>

Hi [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) ,  
It worked with **Publish : true.**  
**Thank you so much for help.**  
Can you please let me know about following query too.  
**I have some user defined custom fields. Which I want to show them as dynamic inputs in the action.**  
I have coded like following :  
/////////

const **fetchCustomFields** = async () =\> {

let response = {};

try {

response = await axios.get(‘[https://url/api/v1/custom-fields](https://url/api/v1/custom-fields)’, {

headers: {

‘Content-Type’: ‘application/json’,

‘Authorization’: `Bearer ${olcAuthToken}`

},

});

} catch (error) {

throw error;

}

return response?.data?.data;

}

**My Actual Action Code**  
////////////////

app.post(‘/action’, async (req, res) =\> {

const inputFields = [];

try {

const customFields = await fetchCustomFields();

customFields?.forEach(field =\> {

inputFields.push(

{

typeDefinition: {

name: field.key,

label: field.value,

type: ‘string’,

fieldType: ‘text’

},

“supportedValueTypes”: [“STATIC\_VALUE”],

isRequired: true

});

});

const requestData =

{

“actionUrl”: “[https://webhook.site/ad466dc7-b126-4ce1-bc7d-3f672e50d277](https://webhook.site/ad466dc7-b126-4ce1-bc7d-3f672e50d277)”,

“published”:true,

“objectTypes”: [

“CONTACT”

],

“inputFields”: [

**…inputFields,**

],

“labels”: {

“en”: {

“inputFieldLabels”: {

“staticInput”: “Static Input”,

“objectInput”: “Object Property Input”,

“optionsInput”: “External Options Input”

},

“actionName”: “Send PostCard3” + ‘\_’ + Math.floor(Math.random() \* 0.3184),

“actionDescription”: “My Extension Description”,

“appDisplayName”: “My App Display Name”,

“actionCardContent”: “My Action Card Content”

}

},

“functions”: [

{

“functionType”: “POST\_ACTION\_EXECUTION”,

“functionSource”: “exports.main = (event, callback) =\> {\r\n callback({\r\n outputFields: {\r\n myOutput: \“example output value\”\r\n }\r\n });\r\n}”

},

{

“functionType”: “POST\_FETCH\_OPTIONS”,

“functionSource”: “exports.main = (event, callback) =\> {\r\n callback({\r\n \“options\”: [{\r\n \“label\”: \“Big Widget\”,\r\n \“description\”: \“Big Widget\”,\r\n \“value\”: \“10\”\r\n },\r\n {\r\n \“label\”: \“Small Widget\”,\r\n \“description\”: \“Small Widget\”,\r\n \“value\”: \“1\”\r\n }\r\n]\r\n });\r\n}”

}

]

**Now the issue I am facing above code is not fetching the latest custom fields added by user after the action is published. How can I show the latest custom fields as inputs in the action, even after my action is published.**  
Best Regards,  
Aqsa Qayyum.

---

<div class="post-metadata">

**Author:** ![AqsaQayyum](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@AqsaQayyum](https://community.hubspot.com/u/AqsaQayyum)\
**Post date:** [January 29, 2024, 12:38pm UTC](https://community.hubspot.com/t/how-to-create-actions/98235/6 "2024-01-29T12:38:48Z")

</div>

Hi [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) ,  
Can you please let me know about following query:

**How to delete the published action which is created using custom code actions.**

Best Regards,  
Aqsa Qayyum.

---

<div class="post-metadata">

**Author:** ![AqsaQayyum](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@AqsaQayyum](https://community.hubspot.com/u/AqsaQayyum)\
**Post date:** [January 23, 2024, 1:11pm UTC](https://community.hubspot.com/t/how-to-create-actions/98235/7 "2024-01-23T13:11:25Z")

</div>

Hi [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) ,  
Hope you are doing good.  
Can you please check my query ?  
Best Regards,  
Aqsa Qayyum
