# Accessing workflow via API

**URL:** <https://community.fibery.io/t/accessing-workflow-via-api/1390>\
**Category:** API & Programming\
**Created:** [February 21, 2021, 7:43pm UTC](https://community.fibery.io/t/accessing-workflow-via-api/1390 "2021-02-21T19:43:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seaotternerd](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@seaotternerd](https://community.fibery.io/u/seaotternerd)\
**Post date:** [February 21, 2021, 7:43pm UTC](https://community.fibery.io/t/accessing-workflow-via-api/1390/1 "2021-02-21T19:43:16Z")

</div>

I’m writing a Python script to sync tasks between fibery and todoist. It was working great until I tried to access a Workflow element on my fibery task entities. I’m using the following query (the Strategy and Planning is a version of the GIST app that I have tweaked to fit my needs, and the workflow field is called “State”):

```
   [{"command": "fibery.entity/query", 
     "args": {"query": {"q/from": "Strategy and Planning/Task",
                                "q/select": ["Strategy and Planning/name", 
                                                  "Strategy and Planning/State"], 
                                "q/limit": "q/no-limit"}
                 }
   }]'

```

I get the error “Invalid query.\nCause: Field ‘Strategy and Planning/State’ was not found in ‘Strategy and Planning/Task’ type.” If I take out the “Strategy and Planning/State” part it works fine.

Is it not possible to access workflows through the API or am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![Andray\_Shotkin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/andray_shotkin/32/1531_2.png) [@Andray\_Shotkin](https://community.fibery.io/u/Andray_Shotkin)\
**Post date:** [February 21, 2021, 8:42pm UTC](https://community.fibery.io/t/accessing-workflow-via-api/1390/2 "2021-02-21T20:42:55Z")

</div>

Hi!  
This query shape should work:

```auto
[{"command": "fibery.entity/query",
  "args": {"query": {"q/from": "Strategy and Planning/Task",
                     "q/select": ["Strategy and Planning/name",
                                  {"workflow/state": ["fibery/id", "enum/name"]}],
                    "q/limit": "q/no-limit"}
          }
  }]

```

---

<div class="post-metadata">

**Author:** ![Viktar\_Zhuk](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/viktar_zhuk/32/1934_2.png) [@Viktar\_Zhuk](https://community.fibery.io/u/Viktar_Zhuk)\
**Post date:** [February 21, 2021, 8:43pm UTC](https://community.fibery.io/t/accessing-workflow-via-api/1390/3 "2021-02-21T20:43:31Z")

</div>

It certainly possible. You have couple errors in your query. First one is that the Workflow is an extension, so it adds own field to a type. This field name is **workflow/state**. The second is that this field is not a basic but a reference to a compound entity with own fields like **fibery/id** and **enum/name**. It’s a pity that in the Fibery you cannot list all of this visually, but you can take a closer look into output of `{command: "fibery.schema/query", args: {}}`.

So, in your case, query should look like in Andrew’s answer

---

<div class="post-metadata">

**Author:** ![seaotternerd](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@seaotternerd](https://community.fibery.io/u/seaotternerd)\
**Post date:** [February 21, 2021, 10:06pm UTC](https://community.fibery.io/t/accessing-workflow-via-api/1390/4 "2021-02-21T22:06:24Z")

</div>

Wonderful! Thank you both so much. I’m still learning my way around the API and this helps a lot.
