Search code examples
palantir-foundrypalantir-foundry-api

Is there a way for foundry function-backed actions to return a value when called via the API?


Based on the API documentation here, I know I can make an HTTP call to Foundry to apply an action: https://www.palantir.com/docs/foundry/api/ontology-resources/actions/apply-action/. I also know that action can be function-backed: https://chapter.palantirfoundry.com/docs/foundry/action-types/function-actions-getting-started/.

My question is, can you have the function used to define an action return some value (say the ID to a created object), and have that value be returned in the API call response body?

I noticed that the return type of the ApplyActionResponse is just an empty JSON object. Does this mean that nothing can be returned from the endpoint?


Solution

  • Short Answer: Not today

    Possible workarounds:

    • Generate the unique id for the object on the client and make a get request for that object after the post request finishes. This is what I've done in the past. I usually use UUIDs for this since other sorts of primary keys may not be unique (e.g. an incrementing integer). In any case, best to include retry logic in the event your PK is not unique.
    • If you're calling the API from a server that Foundry can communicate with, you could potentially add a webhook to your Action that would send whatever data you need to send to your server. I haven't tested this, but it seems like it should be possible.