Some requests against the API return error 1000 unauthorized but others succeed

When I run some commands it works. With others I get
{“success”:false,“errors”:[{“code”:10000,“message”:“Authentication error”}]}
How could that be?

This works;

get the zone id for the requested zone

zoneid=$(curl -s -X GET “https://api.cloudflare.com/client/v4/zones?name=$zone&status=active
-H “Authorization: Bearer $cloudflare_auth_key”
-H “Content-Type: application/json” | jq -r ‘{“result”} | .[0] | .id’)

echo “Zoneid for $zone is $zoneid”

This does not work:

update the record

curl -X POST “https://api.cloudflare.com/client/v4/zones/abc1234567xyz/dns_records
-H “Authorization: Bearer $cloudflare_auth_key”
-H “Content-Type: application/json”
–data ‘{“type”:“A”,“name”:“testing”,“content”:"{redacted}",“proxied”:“true”,“ttl”:“1”}’

What could be going wrong?

I see you’re using API tokens. Are you sure they have the proper permissions? One is a Read, and the other is an Edit.