# can i set custo header per each request?

**URL:** <https://community.hubspot.com/t/can-i-set-custo-header-per-each-request/107532>\
**Category:** CRM\
**Tags:** developer\
**Created:** [May 20, 2024, 7:26am UTC](https://community.hubspot.com/t/can-i-set-custo-header-per-each-request/107532 "2024-05-20T07:26:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![arthurHwang](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@arthurHwang](https://community.hubspot.com/u/arthurHwang)\
**Post date:** [May 20, 2024, 7:26am UTC](https://community.hubspot.com/t/can-i-set-custo-header-per-each-request/107532/1 "2024-05-20T07:26:49Z")

</div>

I want to set custom headers per each request.

for example, i want to traceId for request

```lia-code-sample
const hubspotClient = new Client({ accessToken: 'accessToken' });

hubspotClient.crm.deals.basicApi.getById(dealId, { headers: { 'x-request-id': uuId() } })​

```

can i do this for now? or there is no function for this..?

---

<div class="post-metadata">

**Author:** ![james-portant](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/james-portant/32/104419_2.png) [@james-portant](https://community.hubspot.com/u/james-portant)\
**Post date:** [May 20, 2024, 11:45am UTC](https://community.hubspot.com/t/can-i-set-custo-header-per-each-request/107532/2 "2024-05-20T11:45:25Z")

</div>

Hi @arthurHwang,

Yes, you can set custom headers for each request when using the HubSpot API. However, I don’t think the official HubSpot API client does not directly support custom headers in the way you specified in your example. To achieve this, you will need to use an HTTP client such as axios, fetch, or a similar library.

Here’s an example using axios to add a custom header to your request:

const axios = require(‘axios’); const hubspotClient = axios.create({ baseURL: ‘[https://api.hubapi.com](https://api.hubapi.com)’, headers: { ‘Authorization’: `Bearer ${accessToken}` } }); const traceId = uuId(); // Generate your UUID here const dealId = ‘your\_deal\_id’; hubspotClient.get(`/crm/v3/objects/deals/${dealId}`, { headers: { ‘x-request-id’: traceId } }) .then(response =\> { console.log(response.data); }) .catch(error =\> { console.error(error); });

In this example:

- axios.create is used to create a pre-configured instance of axios with the base URL and authorization header.
- When making the request, you add the custom header x-request-id using the headers option in the request configuration.

If you prefer to stick with the HubSpot API client, you might consider making a feature request to HubSpot support or checking their documentation for any updates regarding this functionality.  
Please give me a shout if you have any questions.  
Cheers,  
James - CEO @ [Portant  
 ](http://www.portant.co/)  
**Automate Hubspot to Google Docs with the Portant App:**  
[https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-in…](https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-integration)

---

<div class="post-metadata">

**Author:** ![arthurHwang](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@arthurHwang](https://community.hubspot.com/u/arthurHwang)\
**Post date:** [May 21, 2024, 2:00am UTC](https://community.hubspot.com/t/can-i-set-custo-header-per-each-request/107532/3 "2024-05-21T02:00:39Z")

</div>

thank you for answer! I was just wondering about custom header set with SDK 🙂

---

<div class="post-metadata">

**Author:** ![james-portant](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/james-portant/32/104419_2.png) [@james-portant](https://community.hubspot.com/u/james-portant)\
**Post date:** [May 21, 2024, 6:10am UTC](https://community.hubspot.com/t/can-i-set-custo-header-per-each-request/107532/4 "2024-05-21T06:10:26Z")

</div>

No problem @arthurHwang. Glad to help.
