StorageApiError: new row violates row-level security policy

Using the Supabase Storage API, I am calling:

const createBucketRes = await supabase.storage.createBucket('avatars')

But I am getting the error

StorageApiError: new row violates row-level security policy

I am able to use the dashboard to create a bucket and set policies there, but then what is the purpose of having the API?

Reference: https://supabase.com/docs/guides/storage/quickstart?queryGroups=language&language=javascript