# Maintain Cloudflare records using Ansible

**URL:** <https://forum.ansible.com/t/maintain-cloudflare-records-using-ansible/8763>\
**Category:** Get Help\
**Tags:** playbook, community-general\
**Created:** [September 25, 2024, 2:26pm UTC](https://forum.ansible.com/t/maintain-cloudflare-records-using-ansible/8763 "2024-09-25T14:26:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sabrthor](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sabrthor/32/4870_2.png) [@Sabrthor](https://forum.ansible.com/u/Sabrthor)\
**Post date:** [September 25, 2024, 2:26pm UTC](https://forum.ansible.com/t/maintain-cloudflare-records-using-ansible/8763/1 "2024-09-25T14:26:14Z")

</div>

**Ansible throws HTTP 400 for a valid Cloudflare API Token**.

I wanted to manage our Cloudflare DNS records through Ansible and as such created a Cloudflare API Token which has DNS edit permissions for a specific DNS Zone. When I try to execute my playbook, it throws API bad request error. Whereas, when I use Postman to POST the same record with the same API token, it works.

This does not look like an issue with the token itself, as I tried to replace API token with Account Email and Account API Key, the response is same API bad request 400.

_Can anyone please guide me what am I doing wrong?_

My Playbook:

```auto
- name: Create a customer facing A record in Cloudflare
  community.general.cloudflare_dns:
    zone: "example.com"
    record: "login"
    type: A
    value: "200.200.200.200"
    api_token: "MYPRIVATEAPITOKEN"
    proxied: yes 
    state: present

```

Postman cURL command which provided correct output:

```auto
curl --location 'https://api.cloudflare.com/client/v4/zones/306ef97d12e62fc080ca38639d5ffa35/dns_records' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer MYPRIVATEAPITOKEN' \
--header 'Cookie: __cf_bm=GENERATEDCOOKIE' \
--data '{
    "type": "A",
    "name": "login.example.com",
    "content": "200.200.200.200",
    "ttl": 60,
    "proxied": true
}
'

```

Exact Error Message:

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/8/82b310be6752590d272f317fdfe3a7949b550002.png)
