# API rules runnow: How to access payload?

**URL:** <https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416>\
**Category:** Scripts & Rules\
**Created:** [December 3, 2025, 11:30am UTC](https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416 "2025-12-03T11:30:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![moe](https://community.openhab.org/user_avatar/community.openhab.org/moe/32/80110_2.png) [@moe](https://community.openhab.org/u/moe)\
**Post date:** [December 3, 2025, 11:30am UTC](https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416/1 "2025-12-03T11:30:17Z")

</div>

Continuing the discussion from [API rules runnow: What is the payload for?](https://community.openhab.org/t/api-rules-runnow-what-is-the-payload-for/143118):

Hi,  
a pretty old thread but this is the same question for my problem.

I want to execute a file based JS Rule and want to handover some parameters.  
For me and ChatGPT it wasn’t possible to figure out how I can access the request body.

So direct access of the parameter additionalProp1 like in the linked thread is not possible.  
Can somebody help here?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [December 3, 2025, 3:04pm UTC](https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416/2 "2025-12-03T15:04:42Z")

</div>

For file based rules the passed in variables are in `event.raw`.

---

<div class="post-metadata">

**Author:** ![moe](https://community.openhab.org/user_avatar/community.openhab.org/moe/32/80110_2.png) [@moe](https://community.openhab.org/u/moe)\
**Post date:** [December 3, 2025, 6:25pm UTC](https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416/3 "2025-12-03T18:25:31Z")

</div>

Bus this is also always empty

Curl Request:

```php
curl -X 'POST' \
'http://192.168.178.32:8080/rest/rules/1-c22e3e55-27c4-4a14-a520-d7bc35ace206/runnow' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJraWQiOm51bGwsImFsZyI6IlJTMjU2In0.eyJpc3MiOiJvcGVuaGFiIiwiYXVkIjoib3BlbmhhYiIsImV4cCI6MTc2NDc4OTc2NCwianRpIjoiLWJieEVSOUlwUnRhRjVKaW9Mc19ydyIsImlhdCI6MTc2NDc4NjE2NCwibmJmIjoxNzY0Nzg2MDQ0LCJzdWIiOiJhZG1pbiIsImNsaWVudF9pZCI6Imh0dHA6Ly8xOTIuMTY4LjE3OC4zMjo4MDgwIiwic2NvcGUiOiJhZG1pbiIsInJvbGUiOlsiYWRtaW5pc3RyYXRvciJdfQ.b1dtD8J1E4K3pODMmmsXV9cS3hNvb8u6bSEnmowKRJi1N1HCG6xNNCt3i1F5PBUNbYZj7nfvppS0Hl6l94bzchenYAjki7anu2w5hvIl5em9naNt24FP0sjlDJ8pAUduoruUnTyK8GGYiEG6DHUvHhCjxcnOZCWQvMWtes6UfsaYGlExZ_nGtIyZTIMS5YzLoWqaojE9VGEiYebRAp5g0PKZo919XofMt2fQETRhWhpGSrZF9qx5Se4Drxl-iZzcue2PtyXZL5PZ61C6H_rJ5YRwvRDZMYv2SITajuj0jyeG-oqfhx811yk9baRHtBQjUiVVa8U3QDFNVofD0VsfTw' \
-d '{
"additionalProp1": "hallo",
"additionalProp2": {},
"additionalProp3": {}
}'

```

openhab log output:

```javascript
2025-12-03 19:23:20.795 \[INFO \] \[omation.script.file.deltaBetween2.js\] - Input JSON: {
“raw”: {}
}

```

Snappshot of the Rule to test:

```php
rules.JSRule({
  name: "1",
  description: "Executes deltaBetween using JSON from an Item due to OH4 REST bug",
  execute: (event) => {
    console.log("DeltaBetween: Rule started");
	console.log("Input JSON:", event);

```

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [December 3, 2025, 7:01pm UTC](https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416/4 "2025-12-03T19:01:37Z")

</div>

I do not know how to pass arguments through the REST API so I cannot comment whether the curl command is correct. It looks like it might be correct but 🤷 .

From [the docs](https://www.openhab.org/addons/automation/jsscripting/#event-object):

> `raw` all Original contents of the event including data passed from a calling rule N/A

I don’t use file based rules, but `raw` is the original Java Object passed to the rule without any manipulation by the library. So it will be the same for UI and file based.

Using the REST API I passed

```json
{
  "additionalProp1": "foo",
  "additionalProp2": "bar",
  "additionalProp3": "baz"
}

```

To call a script called `toCall` containing the following:

```js
console.info('Type is ' + event.type);
console.info('raw ' + event.raw);
console.info('raw.additionalProp1 ' + event.raw.additionalProp1);

```

which generated

```auto
2025-12-03 11:53:42.490 [INFO] [b.automation.jsscripting.rule.toCall] - Type is undefined
2025-12-03 11:53:42.493 [INFO] [b.automation.jsscripting.rule.toCall] - raw {additionalProp1=foo, additionalProp3=baz, ruleUID=toCall, additionalProp2=bar}
2025-12-03 11:53:42.494 [INFO] [b.automation.jsscripting.rule.toCall] - raw.additionalProp1 foo

```

Note that the exact same `event` Object is now passed into UI based rules from OH 5.1 M1 forward, so this is the exact same thing one would see from a file based rule.

Note: you should always set the id of the rule so it’s both meaningful and doesn’t change every time you edit the file.

You do not mention which version of OH you are on. If it’s before OH 5 the answer may be you can’t do this. Sometime during OH 4’s development adding these passed in arguments were added to the `event` Object for file based rules. Before that though it was not supported.

---

<div class="post-metadata">

**Author:** ![moe](https://community.openhab.org/user_avatar/community.openhab.org/moe/32/80110_2.png) [@moe](https://community.openhab.org/u/moe)\
**Post date:** [December 3, 2025, 9:50pm UTC](https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416/5 "2025-12-03T21:50:28Z")

</div>

ok Openhab version was the trick. I updated my test instance to version 5 M2 and this is working.  
I’m still a bit wondering why this functions is not already working in 4 but ok.

Thanks also for the hint with the rule id … was not aware of it. Make it’s a lot more easier to call the rule over rest api 😃 …

Thank you @rlkoshak

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [December 3, 2025, 10:11pm UTC](https://community.openhab.org/t/api-rules-runnow-how-to-access-payload/167416/6 "2025-12-03T22:11:37Z")

</div>

> [@moe](#):
>
> I’m still a bit wondering why this functions is not already working in 4 but ok.

Because it wasn’t implemented yet.

Not many files based rules users do this as it’s much easier and more flexible to build a personal library instead.
