# Access to request headers in Context

**URL:** <https://community.forestadmin.com/t/access-to-request-headers-in-context/7539>\
**Category:** Help me!\
**Tags:** smart-action\
**Created:** [October 14, 2024, 3:42pm UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539 "2024-10-14T15:42:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aman\_Ahlwat](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/aman_ahlwat/32/7450_2.png) [@Aman\_Ahlwat](https://community.forestadmin.com/u/Aman_Ahlwat)\
**Post date:** [October 14, 2024, 3:42pm UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539/1 "2024-10-14T15:42:01Z")

</div>

## Feature(s) impacted

Smart Actions

## Observed behavior

Trying to access the request headers from the context or other means. Currently cannot find it.

## Expected behavior

Access information like the ip address of the request being made.

## Context

Hey, I’m currently in the process of migrating form the old forest-express-sequelize agent to the @forestadmin/agent agent. I see that the new agent abstracted the request object that was previously passed to smart actions with context.caller. Is there any way to access the request object? I’m mostly interested in the ip address.

- Agent technology: NodeJS
- Agent (forest package) name & version: @forestadmin/agent: 1.47.0
- Recent changes made on your end if any: Migration from old express-sequelize agent to new node agent.

---

<div class="post-metadata">

**Author:** ![Enki](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/enki/32/6004_2.png) [@Enki](https://community.forestadmin.com/u/Enki)\
**Post date:** [October 15, 2024, 8:13am UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539/2 "2024-10-15T08:13:23Z")

</div>

Hello @Aman_Ahlwat ,

Indeed, currently it is not possible to access request headers through the agent context.  
Could you tell me more precisely what is your usecase for using the ip address ?

Kind regards

---

<div class="post-metadata">

**Author:** ![Aman\_Ahlwat](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/aman_ahlwat/32/7450_2.png) [@Aman\_Ahlwat](https://community.forestadmin.com/u/Aman_Ahlwat)\
**Post date:** [October 15, 2024, 8:42am UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539/3 "2024-10-15T08:42:42Z")

</div>

We pass it along to one of our endpoint where it eventually gets logged.

The endpoint is used for syncing connections which happens automatically but this smart action is used to trigger a manual sync if there were any problems syncing automatically. The current implementation does require an ip address so we were hoping that we could also pass the ip address from forest admin as well.

---

<div class="post-metadata">

**Author:** ![Enki](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/enki/32/6004_2.png) [@Enki](https://community.forestadmin.com/u/Enki)\
**Post date:** [October 15, 2024, 8:52am UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539/4 "2024-10-15T08:52:22Z")

</div>

I understand that it would not be exactly the same implementation than before, but is it possible to always provide the agent ip (or any identifiable constant value) when syncing from the action, and then you can rely on activity logs to know who has executed the action if needed ?

---

<div class="post-metadata">

**Author:** ![Antonio\_Marino](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/antonio_marino/32/460_2.png) [@Antonio\_Marino](https://community.forestadmin.com/u/Antonio_Marino)\
**Post date:** [October 17, 2024, 3:57pm UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539/5 "2024-10-17T15:57:58Z")

</div>

We need to store the IP of the admin user who performs a certain action for compliance reasons.  
Surely that can be added to the agent fairly easily?

---

<div class="post-metadata">

**Author:** ![Enki](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/enki/32/6004_2.png) [@Enki](https://community.forestadmin.com/u/Enki)\
**Post date:** [October 18, 2024, 1:11pm UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539/6 "2024-10-18T13:11:09Z")

</div>

Yes indeed ! We’ve just released this 🙂 If you update your agent to the v1.51.0, you’ll be able to get the requester IP from the action context: `context.caller.request.ip` !

Kind regards

---

<div class="post-metadata">

**Author:** ![Aman\_Ahlwat](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/aman_ahlwat/32/7450_2.png) [@Aman\_Ahlwat](https://community.forestadmin.com/u/Aman_Ahlwat)\
**Post date:** [October 18, 2024, 1:39pm UTC](https://community.forestadmin.com/t/access-to-request-headers-in-context/7539/7 "2024-10-18T13:39:22Z")

</div>

Thats a quick turnaround, thank you!
