Algolia icon

Algolia

Use Algolia in your n8n workflows

Overview

This node operation allows you to update an existing API key in your Algolia application. It replaces the permissions and restrictions of the specified API key with new values provided by the user. This is useful for managing access control, adjusting API key capabilities, or modifying usage limits without creating a new key.

Common scenarios include:

  • Updating the access control list (ACL) to grant or restrict specific API operations.
  • Changing the description to better identify the API key.
  • Modifying index access patterns or query limits.
  • Setting expiration times or restricting usage by IP addresses or HTTP referrers.

Practical example:
You have an API key that currently allows read-only access to certain indices, but you want to extend its permissions to allow write operations on additional indices. Using this node, you can update the ACL and indexes properties of the key accordingly.

Properties

Name Meaning
Key The unique identifier string of the API key to update.
Multiple properties Select one or more properties of the API key object to update. Options include: Acl, Description, Indexes, Max Hits Per Query, Max Queries Per IPPer Hour, Query Parameters, Referers, Validity.
Acl Permissions defining what types of API requests the key can make. See Algolia's access control list documentation for details.
Description A human-readable description to help identify the API key.
Indexes List or patterns of index names that the API key can access. Supports wildcards like dev_* or *_products_*.
Max Hits Per Query Maximum number of results the API key can retrieve per query. Default is no limit.
Max Queries Per IPPer Hour Maximum number of API requests allowed per IP address or user token per hour. Exceeding this returns a 429 error. Default is no limit.
Query Parameters Additional query parameters appended to API requests made with this key. Can be used to restrict sources, e.g., IP ranges.
Referers Allowed HTTP referrers for this API key. Supports wildcards. Note that referrers can be spoofed and should not be solely relied upon for security.
Validity Duration in seconds after which the API key expires. Default is no expiration.

Output

The node outputs the JSON response from the Algolia API after updating the API key. This typically includes the updated API key details such as its ACL, description, indexes, and other properties reflecting the changes made.

No binary data output is involved.

Dependencies

  • Requires an Algolia API authentication credential configured in n8n with appropriate permissions to update API keys.
  • The node sends HTTP PUT requests to the Algolia API endpoint /1/keys/{key} where {key} is the API key string to update.
  • The base URL uses the Algolia application ID from credentials.

Troubleshooting

  • Invalid API Key: If the specified API key does not exist or is malformed, the API will return an error. Verify the key string is correct.
  • Insufficient Permissions: The credential used must have admin rights to update API keys. Otherwise, the request will fail.
  • Malformed JSON Inputs: Properties like Acl, Indexes, Referers expect valid JSON arrays. Invalid JSON will cause errors.
  • Rate Limits: Excessive updates or API calls may hit Algolia rate limits; handle errors accordingly.
  • IP Restrictions: When setting Query Parameters with restrictSources, ensure the request originates from allowed IPs, or the update will fail.

Links and References

Discussion