Command methods for button, and/or token availability in context

This is useful for complex buttons that require use of the HTTP API instead of the button API.

It would be nice to have a simple fibery.command method (or .batch, .query, etc. methods) that takes the same payload as the API—or at least make a token available in the context for the current user.

This alleviate a current problems:

  • The “modified by” or “created by” isn’t you who created the button, but had to put your token
  • You don’t expose your own token in buttons for other App admins
  • It is a bit more cumbersome to set up the HTTP payload with URL, content-type, authorization, etc.

For native commands it could potentially also be faster? Since it can be executed internally, so the HTTP request doesn’t have to even go out to the internet, through DNS, SSL, other internal routing, only to go back in to Fibery and the current workspace.

As far as I can tell you would only really need two parameters in a single new method: fibery.exec(String: command, Object?: args).


There is already fibery.executeSingleCommand method in button api. It does what you describe, and exists to allow to execute fibery command without usage of http.

Token of user is not available. Actually buttons are executed under internal admin user, that is why only admins can create buttons. Otherwise it will be a security hole.

In general it is possible to execute button scripts under user who created them, but it will require some rework of current solution. We have no plans to change it at the moment.

Nice! I can’t find executeSingleCommand anywhere in the API docs, but I assume the IntelliSense in the button editor will help and/or that it takes the entire payload that would normally go in to body?

The other stuff isn’t a huge deal for me, so no worries about that. :slight_smile:

EDIT: Indeed it shows up in the IntelliSense, and it takes the body payload—except you omit the wrapping array and leave it with 1 command (as the method name suggests).

For other people’s reference, here’s an example:

const fibery = context.getService('fibery');
const e = await fibery.executeSingleCommand({
    "command": "fibery.entity/query",
    "args": {
        "query": {
            "q/from": "Contacts/Customer",
            "q/select": [
                    "user/Orders": {
                        "q/select": [
                            "Customer orders/name",
                            { "workflow/state": ["enum/name"] }
                        "q/limit": "q/no-limit"
            "q/where": ["=", "fibery/id", "$id"],
            "q/limit": 3
        "params": {
            "$id": "aaaaaa-bbbbb-bbbb-aaaaaaaa"