Skip to main content
This page documents an earlier version of the API client. For the latest version, see Request options.
This method allows you to send the server a specific key-value pair (an extra HTTP header) with every query. By doing this, you are giving the API an additional header that it can be used in situations such as:
  • Setting X-Forwarded-For for analytics. If your server sends the user’s IP address with every search, analytics can distinguish between users. Otherwise, analytics uses the server’s IP address, which doesn’t provide user details. Alternatively, see the followingX-Algolia-UserToken example.
  • Setting X-Algolia-UserToken for analytics. The Analytics API uses the provided value to distinguish between users. It takes priority over any value in X-Forwarded-For. Use this header if you need to forward the user’s identity without relying on IP addresses.
  • Setting X-Algolia-UserToken for API key rate limiting.
  • Setting X-Forwarded-For to ensure that geo-search locations use the user’s IP address, not your backend server’s. For an example of this, see the aroundLatLngViaIP parameter.
The set extra header method will eventually be replaced by the request options parameter, allowing you to set the header as part of your query parameters.

Examples

var configuration = new SearchConfig("YourApplicationID", "YourWriteAPIKey");
configuration.DefaultHeaders.Add("NAME-OF-HEADER", "value-of-header");

SearchClient client = new SearchClient(configuration);

Parameters

headerName
string
required
Name of the header to add.
headerValue
string
required
Value of the header to add.
I