import requests
account_id = ['']
bearer = ['']
worker_name = ['']
for z in worker_name:
for i, j in zip(bearer, account_id):
headers = {
'Content-Type': 'application/javascript',
'Authorization': 'Bearer '+i
}
headers1 = {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+i
}
data1 = {"title":"new_ns","body_part":"script","bindings":[{"type":"kv_namespace","name":"new_ns","namespace_id":":namespace_id"}]}
response1 = requests.post(
'https://api.cloudflare.com/client/v4/accounts/'+j+'/storage/kv/namespaces',
headers=headers1,
json=data1,
)
if response1.status_code == 200:
print('KV Created Enabled: ', response1.json())
else:
print('Error Creating KV:', response1.json())
#Response is
# {'result': {'id': '84e5129c275a428ca7bccab16c6e2050', 'title': 'new_ns', 'supports_url_encoding': True}, 'success': True, 'errors': [], 'messages': []}