How to perform a cURL request with custom authentication headers (e.g., API key)?

To perform a cURL request with custom authentication headers, you can use the -H flag to specify the headers in the command. Here is an example of how to do it:

curl -H "Authorization: API-KEY-HERE" https://api.example.com/endpoint

Replace API-KEY-HERE with your actual API key, and https://api.example.com/endpoint with the URL of the API endpoint you want to request.

If you need to include multiple custom headers, you can use multiple -H flags:

curl -H "Authorization: API-KEY-HERE" -H "Content-Type: application/json" https://api.example.com/endpoint

This example includes both an Authorization header and a Content-Type header.

Note that the headers must be specified within double quotes ("), and the headers and their values should be separated by a colon (:).