External application calling ERPNext Workflow API

Our use case requires an external application making ERPNext Workflow API calls.

Specifically, we would like to achieve the following from our external application:

  1. Create a new Workflow in EPRNext
  2. Add Workflow states
  3. Add Workflow transitions

We have looked at [1], that describe something similar but they are working on the premise that you are within the ERPNext backend.

[1] Get next workflow state using API - #2 by Sangram

As an alternative, the REST API docs, say that you can call methods that are marked as whitelisted, but none of our required actions mentioned above seems to be whitelisted in the workflow.py source file on github (I would post the link but there’s a link limit for new users)

Or are we looking in the wrong place and what we really should be doing is using the Document API [2] to achieve our objectives?


Hi there, welcome to the forums.

The API requires whitelisting for RPC calls, but not for normal REST calls (create, read, update, delete, etc.) from your descriptions, it sounds like you should be able to do what you want to do with a simple POST call. Is there any reason not to go that way?

The link you’ve got for CRUD operations is for the JavaScript API, which probably won’t do what you want, but there’s simple http access too.


welcome to the forums

thanks @peterg :slight_smile:

it sounds like you should be able to do what you want to do with a simple POST call

i presume you mean a simple POST call to the /api/resource/:workflow/ endpoint?

if so, then yeah, that is the way that we were thinking of.

we just wasn’t sure if there was additional logic, which is usually abstracted away from the end user by the API, that had to called in order for the workflow to work as expected. e.g. other tables / references / entities / etc. that also needs to be updated.

Whitelisted methods can be more abstracted, but REST calls are just pure object lifecycle claims. The workflow doctype has two child tables, but those just become part of the json representation of the object you’re creating.