<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Add an Authorization Header to Custom Workflow Actions? in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-Add-an-Authorization-Header-to-Custom-Workflow-Actions/m-p/1125156#M81043</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/917856"&gt;@pablo-synthflow&lt;/a&gt;&amp;nbsp;- I thinkk what you are asking is how to add a header to API calls executed in the custom workflow logic? Apologies if I have this incorrect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The classical approach of hiding an access token for any kind of API call (HubSpot or 3rd party) is to use a SECRET passed as an environment variable to the code at startup. Taking this approach, you can manage/update that SECRET value periodically without making individual changes to all the code sequences that use it. The SECRET is stored independently of any record properties of course.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you format&amp;nbsp; the header for a request (in Python that is) you construct the appropriate header using the retrieved value of the SECRET.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that helpful?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
    <pubDate>Thu, 20 Mar 2025 18:12:35 GMT</pubDate>
    <dc:creator>SteveHTM</dc:creator>
    <dc:date>2025-03-20T18:12:35Z</dc:date>
    <item>
      <title>How to Add an Authorization Header to Custom Workflow Actions?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-Add-an-Authorization-Header-to-Custom-Workflow-Actions/m-p/1124926#M81027</link>
      <description>&lt;P&gt;Hey all — I have a question about custom workflow actions. How can I add a header to them?&lt;BR /&gt;I’m sure it’s possible, but I haven’t been able to figure it out. I think I might need to use a PRE_ACTION_EXECUTION function but I’m not sure.&lt;BR /&gt;My action is currently working, but I want to secure the endpoint and ask the user to provide a token via UI, using one of the action inputs (open to other methods if you have better suggestions!). The idea is to then add an Authorization: Bearer token header to the action.&lt;BR /&gt;&lt;BR /&gt;This is a simplified version of the payload:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"actionUrl": "&amp;lt;BACKEND_URL&amp;gt;",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"published": false,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"inputFields": [&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"typeDefinition": {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"name": "workspace",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"type": "enumeration",&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"fieldType": "select",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"options": [],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"optionsUrl": "&amp;lt;REDACTED&amp;gt;",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;...&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"objectRequestOptions": {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"properties": [&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"firstname",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"email",&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"lastname"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"labels": {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"en": {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"inputFieldLabels": {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"workspace": "Workspace",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"phone": "Lead Phone Number",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"prompt": "Prompt"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"outputFieldLabels": {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"call_analysis": "Call Analysis",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"call_id": "Call ID",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"call_initiated": "Call Initiated"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"actionName": "Make Phone Call",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"actionDescription": "",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"actionCardContent": ""&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"objectTypes": [&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"0-1"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"outputFields": [&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"typeDefinition": {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"name": "call_analysis",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"type": "string",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"fieldType": "text",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;...&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"id": "&amp;lt;REDACTED&amp;gt;",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"revisionId": "1",&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"functions": []&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;BR /&gt;&lt;BR /&gt;Thanks!!&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Mar 2025 11:37:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-Add-an-Authorization-Header-to-Custom-Workflow-Actions/m-p/1124926#M81027</guid>
      <dc:creator>pablo-synthflow</dc:creator>
      <dc:date>2025-03-20T11:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add an Authorization Header to Custom Workflow Actions?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-Add-an-Authorization-Header-to-Custom-Workflow-Actions/m-p/1125156#M81043</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/917856"&gt;@pablo-synthflow&lt;/a&gt;&amp;nbsp;- I thinkk what you are asking is how to add a header to API calls executed in the custom workflow logic? Apologies if I have this incorrect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The classical approach of hiding an access token for any kind of API call (HubSpot or 3rd party) is to use a SECRET passed as an environment variable to the code at startup. Taking this approach, you can manage/update that SECRET value periodically without making individual changes to all the code sequences that use it. The SECRET is stored independently of any record properties of course.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you format&amp;nbsp; the header for a request (in Python that is) you construct the appropriate header using the retrieved value of the SECRET.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that helpful?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2025 18:12:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-Add-an-Authorization-Header-to-Custom-Workflow-Actions/m-p/1125156#M81043</guid>
      <dc:creator>SteveHTM</dc:creator>
      <dc:date>2025-03-20T18:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to Add an Authorization Header to Custom Workflow Actions?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-Add-an-Authorization-Header-to-Custom-Workflow-Actions/m-p/1125695#M81073</link>
      <description>&lt;P&gt;Hey Steve! Thanks for responding &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I think I'm asking something a bit different. I'm following &lt;A href="https://developers.hubspot.com/docs/guides/api/automation/custom-workflow-actions#define-your-custom-action" target="_blank" rel="noopener"&gt;these docs&lt;/A&gt; to let my Hubspot app users execute a particular action.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The action works, but I want them to be able to input an API key (that they get from my website) in order to use it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I am using the PRE_ACTION_EXECUTION parameter for that, but it doesn't seem to work for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my current payload (simplified and sanitized)&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"actionUrl": "&lt;A href="https://example.com/hubspot-action" target="_blank"&gt;https://example.com/hubspot-action&lt;/A&gt;",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"published": true,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"inputFields": [&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{ "name": "workspace", "optionsUrl": "&lt;A href="https://example.com/api/hubspot-get-workspaces/" target="_blank"&gt;https://example.com/api/hubspot-get-workspaces/&lt;/A&gt;" },&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{ "name": "model_id", "optionsUrl": "&lt;A href="https://example.com/api/hubspot-get-agents/" target="_blank"&gt;https://example.com/api/hubspot-get-agents/&lt;/A&gt;" },&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{ "name": "phone" },&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{ "name": "api_key" },&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{ "name": "lead_timezone", "optionsUrl": "&lt;A href="https://example.com/api/hubspot-get-timezones" target="_blank"&gt;https://example.com/api/hubspot-get-timezones&lt;/A&gt;" },&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{ "name": "prompt" },&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{ "name": "greeting" }&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;],&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"labels": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"en": {&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"actionName": "Make Phone Call"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"functions": [&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"functionType": "PRE_ACTION_EXECUTION",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"functionSource": "exports.main = (event, callback) =&amp;gt; {\n const apiKey = event.inputFields.api_key;\n const contactProps = event.object.properties;\n const fullName = `${contactProps.firstname || ''} ${contactProps.lastname || ''}`.trim();\n const requestBody = {\n phone: event.inputFields.phone,\n name: fullName,\n model_id: event.inputFields.model_id,\n workspace: event.inputFields.workspace,\n prompt: event.inputFields.prompt,\n greeting: event.inputFields.greeting,\n lead_timezone: event.inputFields.lead_timezone,\n contact: contactProps\n };\n callback({\n webhookUrl: event.webhookUrl,\n body: JSON.stringify(requestBody),\n contentType: \"application/json\",\n httpHeaders: {\n Authorization: `Bearer ${apiKey}`\n }\n });\n};"&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I create the action using that payload, I get a 200 OK, but if I fetch the Hubspot action, the last part of the payload is like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;"functions": [&lt;BR /&gt;{&lt;BR /&gt;"functionType": "PRE_ACTION_EXECUTION"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;&lt;BR /&gt;There is no functionSource, which makes me think that the action is not really being formatted according to the function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know what might be happening here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 18:16:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-Add-an-Authorization-Header-to-Custom-Workflow-Actions/m-p/1125695#M81073</guid>
      <dc:creator>pablo-synthflow</dc:creator>
      <dc:date>2025-03-21T18:16:30Z</dc:date>
    </item>
  </channel>
</rss>

