How to create workflow with Custom workflow action?

If you already have the workflow created, easiest way is to just use a GET on https://api.hubspot.com/automation/v4/flows/YOUR_WORKFLOW_ID to get the workflow data and copy your actions data (or everything if you really wanted).

It sounds like you’re trying to recreate a Webhook action. The basic structure for a Webhook action is:

 {
 "actionId": "5",
 "method": "POST",
 "webhookUrl": "https://endpoint here",
 "queryParams": [],
 "authSettings": {
 "appId": 1234567890,
 "type": "SIGNATURE"
 },
 "type": "WEBHOOK"
 }

Unless you mean you want to create a Custom Code Action:

 {
 "actionId": "4",
 "secretNames": [],
 "sourceCode": "exports.main = async (event, callback) => {\n /*****\n Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.\n *****/\n const email = event.inputFields['email'];\n /*****\n Use the callback function to output data that can be used in later actions in your workflow.\n *****/\n callback({\n outputFields: {\n email: email\n }\n });\n}",
 "runtime": "NODE20X",
 "inputFields": [],
 "outputFields": [],
 "type": "CUSTOM_CODE"
 }

But it’s literally easier to just build the workflow or actions you want in Hubspot, then use a GET request on it and copy the action data.