# Using API batch operation in Python

**URL:** <https://forum.asana.com/t/using-api-batch-operation-in-python/132205>\
**Category:** API & Developers\
**Created:** [13 August 2021 05:06 UTC](https://forum.asana.com/t/using-api-batch-operation-in-python/132205 "2021-08-13T05:06:46Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ShunS](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/shuns/32/115053_2.png) [@ShunS](https://forum.asana.com/u/ShunS)\
**Post date:** [28 February 2022 15:29 UTC](https://forum.asana.com/t/using-api-batch-operation-in-python/132205/3 "2022-02-28T15:29:31Z")

</div>

Hi @anon36344658 ,

I’m sorry for the very late response.  
Despite [this comment](https://forum.asana.com/t/introducing-the-batch-api/17748/1), it seems the example was deleted from the API doc 😲

Here’s part of my Python code I wrote in the past using batch API:

```auto
client = asana.Client.access_token(os.environ['ASANA_ACCESS_TOKEN'])
client.headers = {'Asana-Enable': 'string_ids,new_sections', 'Asana-Fast-Api': 'True'}
response_all_tags, response_all_users = client.post('/batch', {'actions': [
    {'method': 'get', 'relative_path': '/workspaces/' + some_data_source.data_str_workspace_gid + '/tags'},
    {'method': 'get', 'relative_path': '/workspaces/' + some_data_source.data_str_workspace_gid + '/users', 'options': {'fields': ['email']}}
]})

def add_subtasks_batch(list_assignees_and_names, task_gid):
    client.post('/batch', {'actions': [{'method': 'post', 'relative_path': '/tasks/' + task_gid + '/subtasks', 'data': assignee_and_name} for assignee_and_name in list_assignees_and_names]})

if list_user_tags_gid:
    list_actions_add_tags = [{'method': 'post', 'relative_path': '/tasks/' + task_gid + '/addTag', 'data': {'tag': user_tag_gid}} for user_tag_gid in list_user_tags_gid]
    client.post('/batch', {'actions': list_actions_add_tags})

```

---

_[View the full topic](https://forum.asana.com/t/using-api-batch-operation-in-python/132205)._
