Documentation should be updated to explain the process to create the apikey. It is a base64 encoded string of ":<api_key>" values returned by the elasticsearch /_security/api_key endpoint. Docs for calling that endpoint are online for elasticsearch.
You have to make sure not to include the new line character when creating the API key base64 string, i.e.:
echo -n xpajefwM4r3N:NwfeoSLsjlavanw19fSD | base64
If you forget the -n it will not work and you'll get a 401.