How can an API user create posts as another user?

If you create an API key for “All Users”:

You can then specify the username you want to create posts for via the Api-Username header when making the api request.