# Unclear Forge Remote \`invokeRemote\` response semantics

**URL:** <https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899>\
**Category:** Forge UI Kit and Custom UI\
**Tags:** forge-remote, forge\
**Created:** [May 13, 2024, 9:30am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899 "2024-05-13T09:30:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbinna](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/tbinna/32/35870_2.png) [@tbinna](https://community.developer.atlassian.com/u/tbinna)\
**Post date:** [May 13, 2024, 9:30am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/1 "2024-05-13T09:30:32Z")

</div>

[The `invokeRemote` documentation](https://developer.atlassian.com/platform/forge/apis-reference/ui-api-bridge/invokeRemote/) does not explain how `invokeRemote` handles the HTTP response.

From what I understand, `invokeRemote` takes a description of the HTTP request that should be made against the remote, but what happens to the response of that HTTP request?  
The documented type signature suggests that the response body can be missing or must be an object.

```auto
function invokeRemote(
  input: InvokeRemoteInput
): Promise<{ [key: string]: any } | void>;

```

The documentation leaves me with a lot of questions:

- How exactly is the response handled?
- What if the server responds with an error response? If, in this case, the Promise rejects, what does it reject (and on which status codes)?
- Does that caller have access to HTTP headers or HTTP status code?
- Can the remote return an array or a plain value instead of an object? If not, why not?

It seems `invokeRemote` makes some choices about how it handles the HTTP response from the remote, which are not documented.

---

<div class="post-metadata">

**Author:** ![tbinna](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/tbinna/32/35870_2.png) [@tbinna](https://community.developer.atlassian.com/u/tbinna)\
**Post date:** [May 13, 2024, 9:54am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/2 "2024-05-13T09:54:10Z")

</div>

I just checked [the actual Typescript definition in the latest @forge/bridge](https://cdn.jsdelivr.net/npm/@forge/bridge@3.4.0/out/invoke-remote/invoke-remote.d.ts), which looks as follows:

```auto
export declare const invokeRemote: <T>(input: InvokeRemoteInput) => Promise<T>;

```

This suggests the response can be anything. In reality, it is probably anything accepted by `JSON.parse` but that’s a guess.

---

<div class="post-metadata">

**Author:** ![BoZhang](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bozhang/32/51055_2.png) [@BoZhang](https://community.developer.atlassian.com/u/BoZhang)\
**Post date:** [May 14, 2024, 10:31am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/3 "2024-05-14T10:31:46Z")

</div>

Hi @tbinna, thanks for the feedback, we will definitely look at improving the documentation. In terms of the questions that you have raised:

> How exactly is the response handled?

Under the hood, `invokeRemote` makes a call to Forge; Forge then performs some validation, hydrates the request with OAuth tokens (if configured) and the [FIT](https://developer.atlassian.com/platform/forge/remote/essentials/#the-forge-invocation-token--fit-)… etc. before proxying the request to your remote server. The response is then validated by Forge before responding back to the Front end, where `invokeRemote` will massage the response somewhat (Forge operates using GraphQL, so essentially `invokeRemote` is attempting to bridge between Forge’s GraphQL request/response).

> What if the server responds with an error response? If, in this case, the Promise rejects, what does it reject (and on which status codes)?

Yes, the Promise returned by `invokeRemote` will reject. It will reject on all non-2XXs as noted [here](https://developer.atlassian.com/platform/forge/remote/essentials/#errors), but also if the remote returns a response that is not JSON.

> Does that caller have access to HTTP headers or HTTP status code?

At this point, the caller does not have access to the HTTP status code. For successful requests, you will have access to the headers though (they will be under the `headers` prop of the resolved Promise)

> Can the remote return an array or a plain value instead of an object? If not, why not?

In terms of the response, the `content-type` header must be `application/json` and we must be able to call `JSON.parse()` on the response (as you have guessed).

---

<div class="post-metadata">

**Author:** ![tbinna](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/tbinna/32/35870_2.png) [@tbinna](https://community.developer.atlassian.com/u/tbinna)\
**Post date:** [May 16, 2024, 6:33am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/4 "2024-05-16T06:33:46Z")

</div>

Thank you for the detailed response, @BoZhang.

I am still not entirely clear on the actual response payload shape.

> At this point, the caller does not have access to the HTTP status code. For successful requests, you will have access to the headers though (they will be under the `headers` prop of the resolved Promise)

From your reply above, it sounds like the response shape is something like

```auto
{
  "headers": ...,
  ? // "body":
}

```

I am trying to get an `invokeRemote` example working so I can test this out myself but I am struggling with this: [invokeRemote throws Error: Resolver has no definition for 'undefined'](https://community.developer.atlassian.com/t/invokeremote-throws-error-resolver-has-no-definition-for-undefined/80011)

---

<div class="post-metadata">

**Author:** ![BoZhang](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bozhang/32/51055_2.png) [@BoZhang](https://community.developer.atlassian.com/u/BoZhang)\
**Post date:** [May 16, 2024, 6:56am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/5 "2024-05-16T06:56:11Z")

</div>

Yup, the shape of the response should be as you’ve mentioned. I will have a look at your other post soon.

---

<div class="post-metadata">

**Author:** ![tbinna](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/tbinna/32/35870_2.png) [@tbinna](https://community.developer.atlassian.com/u/tbinna)\
**Post date:** [May 21, 2024, 3:35am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/6 "2024-05-21T03:35:26Z")

</div>

@BoZhang I have been working with `invokeRemote` a bit more and wanted to add that it would be good if the documentation could also clearly define the error response semantics and the API could be improved.

If the remote returns an error response, the underlying GraphQL response payload looks something like this:

```auto
{
    "data": {
        "invokeExtension": {
            "success": false,
            "response": null,
            "contextToken": null,
            "errors": [
                {
                    "message": "Invalid response from remote",
                    "extensions": {
                        "errorType": "INVALID_REMOTE_INVOCATION_ERROR",
                        "statusCode": 400,
                        "__typename": "GenericMutationErrorExtension"
                    },
                    "__typename": "MutationError"
                }
            ],
            "__typename": "InvokeExtensionResponse"
        }
    },
    "extensions": {
        "gateway": {
            "request_id": "fb358c3eb9ad448bb024ca1bb6f9c0bb",
            "crossRegion": false,
            "edgeCrossRegion": false
        }
    }
}

```

As shown above, the `errors` array does expose the error code, but the caller is never passed on that information, which is quite annoying.

The `invokeRemote` interface is quite messy. It suggests to the caller that it has an HTTP interface, but the actual implementation is neither here nor there. It would be good if the API implementation and interface propagated all the details of the underlying HTTP call to the `invokeRemote` caller, including code, body, and headers for error responses.

The current workaround could be implementing the Forge Remote endpoint more like a GraphQL endpoint and always returning 200 responses, with all the details (incl. errors) in the response body.

---

<div class="post-metadata">

**Author:** ![BoZhang](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bozhang/32/51055_2.png) [@BoZhang](https://community.developer.atlassian.com/u/BoZhang)\
**Post date:** [May 21, 2024, 4:01am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/7 "2024-05-21T04:01:40Z")

</div>

Hi @tbinna ,

Thanks for sharing your feedback. We discussed error handling earlier and some of its shortcomings, particularly the fact that the status code, along with the headers and body are not available if there is an error.

The error you are seeing with the GQL response payload is actually the response from an internal Forge service. This service handles errors from the response it gets from the remote server and does some of its own internal error mapping, so we will need to do some work to propagate the error some other way. I have created this [FRGE ticket](https://ecosystem.atlassian.net/browse/FRGE-1402), to track it.

---

<div class="post-metadata">

**Author:** ![tbinna](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/tbinna/32/35870_2.png) [@tbinna](https://community.developer.atlassian.com/u/tbinna)\
**Post date:** [April 14, 2025, 9:15am UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/8 "2025-04-14T09:15:35Z")

</div>

I just came back here a year later in an attempt to understand the @forge/bridge `invokeRemote`. Dealing with `invokeRemote` from a Custom UI is still incredibly painful due to the unclear and undocumented API contract.

I am trying to write an HTTP API client for my Connect remote and thought I could just plugin in `invokeRemote` from @forge/bridge or from @forge/api, but that does not work. @forge/bridge invokeRemote has GraphQL-like semantics, while @forge/api invokeRemote has close to fetch-like semantics, which makes reusing the same client or even the same API endpoint difficult.

I will probably establish an API between the Custom UI and Forge backend (using `invoke`) and only call my Connect remote through the Forge backend.

---

<div class="post-metadata">

**Author:** ![iliyanvlahov](https://avatars.discourse-cdn.com/v4/letter/i/6f9a4e/32.png) [@iliyanvlahov](https://community.developer.atlassian.com/u/iliyanvlahov)\
**Post date:** [October 1, 2025, 1:02pm UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/9 "2025-10-01T13:02:08Z")

</div>

It looks like there is no progress done on this. The typescript support is extremely bad and vague, it’s even wrong.

The type annotation is still `export declare type `_`InvokeResponse`_`=`_`Record`_`<`_`string`_`, `_`any`_`> | `_`void`_`;`

Also, the whole method is not generic at all and at least this will be needed in order to safely type your body for the responses under the 200s

Is this even planned to be improved or it will stay as it is ?

---

<div class="post-metadata">

**Author:** ![BoZhang](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/bozhang/32/51055_2.png) [@BoZhang](https://community.developer.atlassian.com/u/BoZhang)\
**Post date:** [October 3, 2025, 12:54pm UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/10 "2025-10-03T12:54:29Z")

</div>

Hi @iliyanvlahov, unfortunately there hasn’t been any progress made in this area recently.

Just wanted to ask, will the following feature request - [Jira](https://ecosystem.atlassian.net/browse/FRGE-1402) help you out?

---

<div class="post-metadata">

**Author:** ![SebastianPawlak](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@SebastianPawlak](https://community.developer.atlassian.com/u/SebastianPawlak)\
**Post date:** [January 8, 2026, 12:19pm UTC](https://community.developer.atlassian.com/t/unclear-forge-remote-invokeremote-response-semantics/79899/11 "2026-01-08T12:19:17Z")

</div>

It looks like invokeRemote started to return status code. Is that intentional? Can we rely on this?
