# Programmatically remove / update credentials in a template by API in AWX

**URL:** <https://forum.ansible.com/t/programmatically-remove-update-credentials-in-a-template-by-api-in-awx/44078>\
**Category:** Get Help\
**Tags:** awx\
**Created:** [July 24, 2025, 6:32pm UTC](https://forum.ansible.com/t/programmatically-remove-update-credentials-in-a-template-by-api-in-awx/44078 "2025-07-24T18:32:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trippinnik](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/trippinnik/32/4308_2.png) [@trippinnik](https://forum.ansible.com/u/trippinnik)\
**Post date:** [July 24, 2025, 6:32pm UTC](https://forum.ansible.com/t/programmatically-remove-update-credentials-in-a-template-by-api-in-awx/44078/1 "2025-07-24T18:32:36Z")

</div>

We use the API to codify our templates and things I noticed that when changing the credentials on a job the API errors:

```auto
{'error': 'Cannot assign multiple Machine credentials.'}

```

going by the documentation:  
[10. Tower API Reference Guide — Ansible Tower API Guide v3.8.6](https://docs.ansible.com/ansible-tower/latest/html/towerapi/api_ref.html#/Job_Templates/Job_Templates_job_templates_credentials_list)

and included a json payload in a post:

```auto
{ "id": credential['id'],'dissasociate': True}

```

but the error is the same. The documentation is a bit confusing and does not provide an example of what that looks like. How does one remove a credential from the template via the API?

---

<div class="post-metadata">

**Author:** ![ildjarn](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@ildjarn](https://forum.ansible.com/u/ildjarn)\
**Post date:** [July 25, 2025, 6:01am UTC](https://forum.ansible.com/t/programmatically-remove-update-credentials-in-a-template-by-api-in-awx/44078/2 "2025-07-25T06:01:12Z")

</div>

You need a 2 step approach:

POST /api/v2/job\_templates/ID/credentials/ with body { ‘id’: oldid, “disassociate”: true }  
POST /api/v2/job\_templates/ID/credentials/ with body { ‘id’: newid }
