When OpenSearch API keys fit service accounts
Pipelines, scheduled jobs and automation often need to write to or query OpenSearch without borrowing a person's password. OpenSearch API keys fit that gap. The docs describe them as long-lived, scoped tokens introduced in OpenSearch 3.7, sent in an Authorization: ApiKey header. A service that holds a key can do only what that key's permissions allow, and no human sign-in is involved. Before you adopt them, confirm that your cluster runs 3.7 or later, since keys do not exist on earlier versions.
Keys make the most sense for ingestion from log shippers or collectors, index maintenance jobs, and scheduled reporting, where the caller is a machine and the work is narrow. They are a poor fit when a caller needs a person's identity for audit, needs interactive sign-in, or needs access that changes with the user's role. The rest of this page covers how to scope, store, revoke and audit keys, and where their limits are. Start by listing each automated caller, the indexes it touches and the actions it performs, because that list determines how narrow each key must be.
Treat each key as a credential owned by one service, with a named owner who can rotate or retire it. The docs state that only security administrators can manage API keys, so your platform or security team should own the process, and application teams should request keys through it. Plan the key inventory, rotation cadence and the revocation steps for a compromised pipeline before the first key is issued. Confirm with your own security team how they want key creation and revocation recorded, because the audit settings and retention on your cluster will shape the evidence you can produce.
How API keys differ from users and roles
An API key is a separate credential that a security administrator issues for a pipeline or automation job, not a login for a person. Four parts decide whether it is safe to run in production: the token, its permissions, its lifetime and how the cluster stores it.
The token itself
An API key is a long-lived token sent in an Authorization: ApiKey header rather than a username and password. Automation sends it on every request, so the token is the secret that must stay out of source repositories, container images and shared CI logs. Ask who holds the value at creation time, where your pipeline tool keeps it, and how you will find every system that uses a given key before you rotate it.
- First version with API keys
- 3.7
Scoped permissions
Each key carries its own permission scope, so a log shipper can write to one index pattern while a reporting job only reads. This is the main difference from a user, whose access comes from the roles mapped to that account. Review each scope against the job it serves, and confirm that the scope cannot reach system indexes or Security API endpoints, which API key requests are blocked from calling.
Lifetime and expiry
Keys are long-lived by design, which suits automation that cannot answer a login prompt but raises the cost of a leaked value. Set an expiry date for every key your organization issues, and record an owner and a purpose alongside it. Confirm with your own runbook how often keys are rotated, because the duration you choose sets how long a stolen key stays useful.
Hashed storage
The cluster stores only the SHA-256 hash of each key, not the value you were given. A person with read access to the security index cannot recover a working key from it, but the value is shown only once, so a lost key must be replaced rather than retrieved. Plan a secure handover step in the pipeline setup, and do not rely on the cluster to re-display a key later.
Key storage detailsImmediate revocation
When a security administrator revokes a key, the change applies immediately on all nodes, so a compromised automation job loses access without waiting for a restart or a cache to expire. Write a revocation runbook that names who can revoke, how a pipeline owner is told, and how the replacement key reaches the job. Test it once in a non-production cluster before you need it.
Administrator-only management
Only security administrators can create, list and revoke API keys, so the team that runs pipelines depends on a separate admin group for every change. This separation of duties protects against a service owner granting itself wider access, but it adds a request step. Decide who holds the security administrator role, how requests are logged, and how quickly the admin group responds to a rotation.
Key configuration choices and when each fits
This table compares the main choices when you issue API keys to pipelines and automation: ownership, permissions, lifetime, naming, management rights and revocation. Read each row against your own pipeline inventory, and confirm exact settings in the documentation for your cluster version, since API keys were introduced in OpenSearch 3.7. The main takeaway is that one key per pipeline adds administration work but lets you revoke or audit one pipeline without disrupting the others.
| Decision | Option | Trade-off | When it fits |
|---|---|---|---|
| Key ownership | One key per pipeline | More keys to inventory, but revoking one leaves other pipelines running | Pipelines with different owners, data sets or change cycles |
| Key ownership | Shared key for a group | Fewer keys to manage, but one leak or revocation affects every caller | Small teams with one owner and identical access needs |
| Permissions scope | Index-specific, least-privilege access | Smallest blast radius, but roles must be designed and tested against each pipeline's calls | Ingest, search or read jobs against known indexes |
| Permissions scope | Broad access across many indexes | Simpler to set up, but a leaked key can reach far more data | Rarely justified for automation; confirm scopes in your version's docs first |
| Duration | Long-lived key with scheduled rotation | Keys are long-lived, so your team owns the rotation calendar and the cutover work | Most pipelines, once rotation is documented and tested |
| Naming | Name by pipeline, environment and owner | Faster audit triage, but only if a naming standard is enforced at request time | Any environment with more than a few automated callers |
| Management rights | Security administrators create and revoke keys | Keeps issuance under controlled hands, but adds a queue for pipeline owners | Regulated environments that need separation of duties |
| Revocation | Create replacement, switch pipeline, then revoke old key | Revocation applies immediately on all nodes, so the cutover must be ready first | Planned rotation or any suspected credential exposure |
Creating and rotating a service account key
This sequence takes a pipeline from no credential to a scoped, tested OpenSearch API key with a stored value, a named owner and a rotation procedure. Each step ends with a check so the team can confirm the key works before it is handed to automation.
Confirm the cluster runs OpenSearch 3.7 or later
The platform team checks the running version of every cluster the pipeline will call, since API keys were introduced in OpenSearch 3.7 and older clusters cannot create them. Confirm the version on each cluster, including any staging clusters that will receive the same pipeline. The step is done when every target cluster reports 3.7 or later and the version is recorded in the service account record. If a cluster is older, the pipeline needs a different credential plan, and the upgrade path should be scheduled before the key is created.
Define the required actions and indices
Before creating anything, the pipeline owner and the security team write down the exact operations the pipeline performs and the indices it touches, such as reading one index pattern or writing to one ingest index. Keep the list narrow and name each action, because the key's permissions are derived from this scope. Confirm with the pipeline developers that no step needs access to system indexes or Security API endpoints, since requests made with API keys cannot reach either. The step is done when the scope is written as a short, reviewed list.
Create the key as a security administrator
A security administrator creates the API key through the Security plugin, since only security administrators can manage API keys. Set the permissions to match the reviewed scope and set a duration or expiry policy that your organization has agreed on, confirming the available duration options in the API keys documentation for your version. The key value is returned once at creation, so the administrator should move directly to the next step. The step is done when the key appears in the key list with the intended name and scope, and the creation is visible in the audit log.
Store the returned value in the secret manager
The administrator places the returned key value into the pipeline's secret manager, such as the vault or secret store your platform team already operates, and never into source control, chat or a ticket. Only the SHA-256 hash of the key is kept by OpenSearch, so a lost value cannot be recovered and must be replaced by creating a new key. Restrict read access to the secret to the pipeline's runtime identity. The step is done when the pipeline can retrieve the secret at runtime and the plaintext copy has been removed from the administrator's workstation and any clipboard history.
Test the Authorization ApiKey header with a narrow read
Run a single read request against a non-sensitive index in scope, sending the key in an Authorization header with the ApiKey scheme. Confirm the request succeeds and then confirm that a write or a read on an index outside the scope is refused, which shows the permissions behave as designed. Keep the test request in the pipeline's test suite so future rotations can repeat it. The step is done when the in-scope read returns data, the out-of-scope call is denied, and both results are recorded with the key name and date.
Document the owner and the rotation procedure
Record the key's name, the pipeline it serves, the named owner, the scope and the expiry in your credential register, and write the rotation runbook. The runbook should cover creating the replacement key, updating the secret, running the narrow read test, switching the pipeline, and revoking the old key. Revocation takes effect immediately on all nodes, so schedule the switch to avoid a gap in pipeline runs. The step is done when the owner has confirmed the runbook in writing and a rotation has been rehearsed in a non-production cluster.
What API keys cannot call
An API key is scoped to data and index operations, and it cannot reach the security plane. Requests made with a key cannot access system indexes and cannot call Security API endpoints, so a key cannot create or change roles, users, role mappings or other keys. Only security administrators can manage API keys in the first place, so the boundary runs in both directions: people with administrator rights create and revoke keys, and the keys themselves cannot widen their own reach. Confirm this behavior on your exact OpenSearch version before you rely on it in a design, and test it with a key that holds broad index permissions to see which calls are refused.
The consequence shows up in automation that tries to manage security configuration. A pipeline that rotates users, adds a role for a new team or registers a new key will fail with a key, and that failure is the intended outcome. Do not work around it by storing an administrator certificate or admin password in the pipeline's secret store. Keep the work that changes security configuration in a separate job that runs under administrator credentials, is triggered by a reviewed change, and is held by people who are not the owners of the service pipelines it configures. Document which operations belong to each group before the first key is issued.
When you plan this split, list every automated task against the Security API and assign it to one of the two credential paths. Tasks that only read or write application data stay on scoped keys. Tasks that change roles, users, mappings or key lifecycle stay on administrator control, ideally with the configuration kept in version control and applied by a controlled process. Ask your OpenSearch support provider or the vendor documentation whether any administrative operation you need is available through another route on your version, and record the answer, because an unexpected gap found during an incident is harder to resolve than one found during design.
How a pipeline request is authorized with an API key
The flow starts in the pipeline's secret store, which holds the API key that the pipeline sends in an Authorization ApiKey header. The security plugin on the cluster receives the request, computes a SHA-256 hash of the presented key and compares it with the stored hash, then checks the permissions attached to that key. Revocation is applied on every node, so a revoked key stops working cluster-wide at once. Check two refusal paths: requests aimed at system indexes and requests to Security API endpoints are denied even when the key is valid.
Authorization path for a pipeline request using an OpenSearch API key.
Security and operational considerations
An API key is a bearer credential, so its safety depends on where the raw value lives, who owns its lifecycle and how quickly it can be cut off. The cards below cover the controls that connect storage, rotation, revocation, audit and administrative separation for keys used by pipelines and automation.
Secret storage in the pipeline platform
The raw API key is shown to you once, so the pipeline platform's secret store becomes the only place it should live afterward. Keep it out of source repositories, job logs, container images and shared configuration files. Confirm which of your CI/CD or scheduler products mask secrets in logs, who can read stored secrets, and whether job runners can be inspected by people who should not see the key. Scope each key to one pipeline so that a leaked value exposes only that job's permissions.
SHA-256 hash storage
The cluster stores only the SHA-256 hash of each key, so the raw value cannot be recovered from the cluster after creation. This protects against someone reading the security index, but it also means a lost key cannot be retrieved and must be replaced. Plan the handoff at creation time: record the key in the approved secret store immediately and confirm your team's process for issuing a replacement when a secret is lost. Do not assume an administrator can look up an existing value later.
API keys docsRotation owner for long-lived keys
Keys are long-lived by design, so they will outlive the project that created them unless someone owns their rotation. Name an owner for each key or key group, record the pipeline it serves, and set a review date in your change system. Ask the owner to confirm the consuming service, the permissions still needed and the replacement procedure. Without a named owner, stale keys accumulate with broad permissions that nobody remembers granting.
Immediate revocation during incidents
Revocation applies immediately on all nodes, so disabling a key stops its access without waiting for a cluster restart or a propagation window. Write a runbook that names who can revoke a key, how the pipeline is paused, and how a replacement is issued and deployed. Rehearse the steps with the pipeline owner so that revocation and redeployment happen in the same change window. Confirm that your incident process covers keys held by external tools, not only human accounts.
Audit logging of key activity
Requests made with an API key should appear in audit logs under the key's identity, so reviewers can tell automation apart from people. Confirm that audit logging is enabled on the cluster, that the audit categories you need are turned on and that logs are shipped to storage outside the cluster with retention set by your policy. Review key activity for unexpected indexes, volumes or times, and treat a sudden change in a key's pattern as an incident signal.
Separating key management from administrators
Only security administrators can manage API keys, which keeps the power to create and revoke them within a small group. Decide who holds that role, document how requests are approved and avoid giving the same people both key creation and pipeline deployment rights. Keys also cannot reach system indexes or Security API endpoints, so a compromised key cannot change the security configuration. Confirm this boundary in a test before relying on it, and review the role membership regularly.
Limits to confirm in your environment
Which permissions can an OpenSearch API key be granted, and how fine-grained are they?
The permission granularity is the first thing to confirm. API keys were introduced in OpenSearch 3.7, and their scope is set when the key is created, so you need to test the exact permission model on your target version. Create a key for a pipeline role, then attempt every call the pipeline makes and a set of calls it should not make, such as index creation, index deletion, and reads from a restricted index. Record which calls succeed. Check the OpenSearch API keys docs for the permission options, and do not assume a permission exists until a test confirms it.
How long can an OpenSearch API key stay valid, and can expiry be set?
Confirm the expiry options before you write a rotation policy. The documented model describes API keys as long-lived scoped tokens, so you should verify whether a key can be created with an expiration, what the default is, and whether a key can be extended or only replaced. Test creating a key with and without an expiry setting on your version, then confirm the behavior after the expiry point passes. If expiry is not available or not set by default, your rotation process must be run by your team or a partner on a schedule you define.
How do audit logs record API key use in OpenSearch?
Verify how audit categories record calls made with an API key before relying on them for investigations. Enable audit logging on a test cluster, make requests with a key and with a regular user, and compare the entries. Check whether the key identity appears in the audit record, which categories are logged, and whether failed requests from a revoked or out-of-scope key are captured. Your security team should review a sample of these entries, because the answer determines whether a leaked key can be traced to a pipeline.
Do OpenSearch API keys behave the same during a rolling upgrade?
Plan for mixed-version clusters and test the behavior before you upgrade production. API keys require OpenSearch 3.7 or later, so any node or client still running an older version cannot use the feature in the same way. Confirm how keys created on a newer version are handled while some nodes run an older release, and whether a key remains usable after the cluster finishes the rolling upgrade. The OpenSearch releases page lists the current versions and maintenance status, which helps you pick a target version for the upgrade.
Will my existing OpenSearch client libraries send API keys correctly?
Confirm client compatibility for every language and tool your pipelines use. API keys are sent in an Authorization header with the ApiKey scheme, so a client must allow custom headers and must not override the header with basic authentication. Test each client, including Logstash, Data Prepper, Fluent Bit, custom scripts and SDKs, against a test cluster with a key that has limited permissions. Note the client version that works, and pin it in your deployment so an update does not break authentication.
What exactly can an OpenSearch API key not call?
The documented limits are the starting point, but test the boundaries yourself. Requests made with an API key cannot access system indexes or call Security API endpoints, and only security administrators can manage keys. Confirm these limits on your version by attempting a read of a system index and a call to a security endpoint with a key, and by trying to create or revoke a key with a non-admin account. Also test any internal endpoints your automation relies on, since a pipeline that depends on a blocked call will fail after deployment.
How quickly does revoking an OpenSearch API key take effect?
The documented behavior is that revocation applies immediately on all nodes, but verify it in your topology. Run a test loop that sends requests with a key, revoke the key from an admin account, and confirm the next request from each node is rejected, including from a load-balanced address and a node in a second zone if you use one. Record the result in your runbook, because incident response depends on it.
Auditing key use and keeping an inventory
Every API key should be traceable from the request it makes back to a named owner, a defined scope and a rotation date. Start by confirming which audit log categories your deployed OpenSearch version records for API key activity, since the exact categories and their names must be checked in the OpenSearch Security documentation for that version before you build alerts on them. Audit logging is part of OpenSearch Security, so it has to be enabled and pointed at a destination you control, and the settings that decide which requests are logged belong in your change-controlled security configuration. Test the mapping in a non-production cluster by creating a key, using it, revoking it and checking that each step produces the expected log entry with the key's identifier and the calling principal.
Alerting is most useful for events that suggest a key is being misused or has outlived its purpose. Reasonable starting points include key creation and revocation outside an approved change window, authentication failures that use a key, requests from a key against an index pattern it was never meant to touch, and a key that is used after its owner has left. Some of these checks need the log fields to carry the key's name, so confirm that field exists in your version before writing the rule. Keep the inventory in a system your security team controls, not in a spreadsheet that drifts: each record should list the key name, owner, team, permitted roles, target indexes or pipelines, creation date, planned rotation date and the consuming system. Reconcile the inventory against the cluster's current key list monthly, because a key created outside the process is the most common gap in practice.
Questions teams ask before creating API keys
Can our own team set up OpenSearch API keys without a partner?
Yes, if you already run a self-hosted OpenSearch cluster with the Security plugin and have people who can administer it. API keys were introduced in OpenSearch 3.7, and only security administrators can manage them, so the work sits with the people who already control roles and backends. The harder part is usually not the clicks but the design: which pipelines get keys, what each key may call, who owns it, and how revocation is handled when a pipeline changes. Teams with a clear inventory of automation and an agreed naming and ownership model can usually do the first rollout internally. Confirm your cluster version first, since keys are not available before 3.7.
What drives the effort of an API key rollout?
The main drivers are the number of pipelines and services that need credentials, how narrowly you want to scope each key, and how many systems the keys must integrate with. Each pipeline needs its required index and action permissions mapped, and each key needs a duration decision. Secret manager integration adds work because keys must be stored and rotated in your existing vault rather than in job configuration files. Audit routing also adds work, since you need to confirm that the audit categories you enable reach your log platform and that someone reviews them. Teams with few pipelines and one secret store move quickly. Large estates with many owners take longer because most of the time goes to agreeing scope.
What do we need to provide before the work starts?
You need administrator access to the cluster with security administrator rights, because only those accounts can manage API keys. A test cluster on the same OpenSearch version as production is strongly recommended so you can verify permissions without touching live pipelines. You also need a named owner for each pipeline or service account, someone who can confirm which indexes and operations it uses and who will approve changes. Your secret management process should be defined, including where keys are stored and who can read them. Finally, identify the team that receives audit logs. Gathering these inputs before the first key is created is the step that most often determines how smoothly the rollout goes.
How long does a scoped API key setup take?
Duration depends on the same drivers as effort: how many pipelines exist, how well their access needs are already documented, and how many integration points the keys touch. A small set of pipelines with documented access needs can be scoped and tested in a short cycle. Estates where nobody knows what each job reads or writes need an inventory step first, which usually takes longer than the key creation itself. Ask any provider for a schedule built from your inventory and a list of pipelines, not from a generic template. Plan extra time for testing revocation and for confirming that audit events arrive where your team expects them.
Which permissions should a pipeline key receive?
Grant each key only the index patterns and actions the pipeline needs, and no more. Keys cannot access system indexes or call Security API endpoints, so they will not manage roles or users, but they can still read or write any data their role allows. For a log shipper, that might mean write access to one index pattern. For a reporting job, it might mean read access to a single pattern. Review roles whenever a pipeline changes, because overly broad permissions are the most common source of risk. Confirm the exact action names and key options against the current API key documentation for your version before you standardize them.
How do we revoke a key when a pipeline is retired or compromised?
Revocation takes effect immediately on all nodes, so a compromised key stops working as soon as it is revoked. Only the SHA-256 hash of each key is stored in the cluster, which means the plaintext value cannot be recovered from OpenSearch after creation. Your runbook should therefore record where each key lives in your secret manager, who owns it, and how to issue a replacement. Test the revocation path on the test cluster before you rely on it. Also decide whether keys have a set duration, and who approves renewals, because long-lived keys still need an owner who reviews them.
Do we need an outside partner for this work?
Not necessarily. Many teams manage API keys in-house once their cluster is running and their identity configuration is stable. A partner is worth considering when the estate is large, when pipelines are poorly documented, or when your staff cannot spare time to build the inventory, test the rollout and prepare audit evidence. DeployOpen plans, implements and hardens self-hosted open-source platforms inside your own infrastructure under a written, fixed scope, and can also prepare controls and evidence for compliance assessments. It does not issue audit reports or certifications. Ask any provider to confirm its scope, deliverables and handover in writing before work starts.
How DeployOpen scopes API key rollouts
DeployOpen plans and implements OpenSearch API keys inside your own infrastructure, starting from an inventory of every pipeline and automation job that touches the cluster. Each job is mapped to one key with the narrowest role set it needs, so a log shipper that only writes to one index pattern does not share credentials with a dashboard export or a reindex job. The mapping, the permissions each key receives and the duration chosen for it are written down before any key is created, and that written record becomes the reference for later reviews. The rollout is a fixed-scope engagement: deliverables, the systems in scope and the timeline are agreed in writing before work starts.
Key material is handled in your own secret manager, not in pipeline configuration files or chat threads. DeployOpen sets up the storage path, the rotation runbook and the way each consuming job reads its key, then confirms that the Authorization ApiKey header is injected at runtime and never logged by the pipeline. Because only the SHA-256 hash is stored in the cluster, the secret manager is the only place where the plain key exists after creation, so its access policy and backup behavior need the same review as any other credential store. Confirm with your security team which secret manager you will use and who may read it before the first key is issued.
Before handover, DeployOpen validates two things that are easy to assume and easy to get wrong: revocation and audit. A test key is revoked, and the team checks that requests fail on every node and that the audit log records the events in the categories your audit policy enables. The engagement also covers a rotation procedure that a platform engineer can follow without the consultant present, and a documented list of what keys cannot do, including system index access and Security API calls. Ongoing support, upgrades and periodic retesting of the key setup can be taken on as a retainer after handover, which suits teams that add new pipelines regularly.

