Are you missing the x-sandbox-name header in the API request?
x-sandbox-name is a required header in the batch ingestion API. It refers to the Experience Platform sandbox environment in which you are working. By default, there is a prod sandbox, but then you can create multiple development sandboxes for testing.
When you log into the UI you are always defaulted into a sandbox, and if you have access to multiple sandboxes, you can switch between them using the dropdown in the top left corner. This is probably why you don't get this error in the UI... because you always have to be in a sandbox.
When using the API, you need to use the sandbox name field, which you can see from the UI (if you have sandbox permissions):
You could also retrieve a list of your available sandboxes from one of the requests in this Postman collection: