published on Saturday, Jul 18, 2026 by Pulumi
published on Saturday, Jul 18, 2026 by Pulumi
Use this data source to retrieve details of an existing New Relic API access key, which can be either an Ingest (license) key or a User API key. A common use case is to fetch the default license key that New Relic creates for every account (for instance, via the newrelic.AccountManagement resource) and inject its value into other resources, without having to manage the key itself with the newrelic.ApiAccessKey resource.
A key may be looked up in one of two ways: directly by its keyId, or by searching with a combination of accountId, keyType, ingestType, userId and name.
Refer to the New Relic article ‘Use NerdGraph to manage license keys and User API keys’ for detailed information.
WARNING: If the key being fetched was created for a user other than the one whose API key is being used to run Terraform, the New Relic API returns a truncated key value for security reasons. In such a case, the
keyattribute is not populated in state and a warning is emitted. See the Attributes Reference section below, and the New Relic article ‘Use NerdGraph to manage license keys and User API keys’ for further details.
Example Usage
Example: Look up the default license key of an account
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
const _default = newrelic.getApiAccessKey({
accountId: "1234567",
keyType: "INGEST",
ingestType: "LICENSE",
name: "License Key for <Account name>",
});
import pulumi
import pulumi_newrelic as newrelic
default = newrelic.get_api_access_key(account_id="1234567",
key_type="INGEST",
ingest_type="LICENSE",
name="License Key for <Account name>")
package main
import (
"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := newrelic.GetApiAccessKey(ctx, &newrelic.LookupApiAccessKeyArgs{
AccountId: pulumi.StringRef("1234567"),
KeyType: "INGEST",
IngestType: pulumi.StringRef("LICENSE"),
Name: pulumi.StringRef("License Key for <Account name>"),
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using NewRelic = Pulumi.NewRelic;
return await Deployment.RunAsync(() =>
{
var @default = NewRelic.GetApiAccessKey.Invoke(new()
{
AccountId = "1234567",
KeyType = "INGEST",
IngestType = "LICENSE",
Name = "License Key for <Account name>",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.newrelic.NewrelicFunctions;
import com.pulumi.newrelic.inputs.GetApiAccessKeyArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var default = NewrelicFunctions.getApiAccessKey(GetApiAccessKeyArgs.builder()
.accountId("1234567")
.keyType("INGEST")
.ingestType("LICENSE")
.name("License Key for <Account name>")
.build());
}
}
variables:
default:
fn::invoke:
function: newrelic:getApiAccessKey
arguments:
accountId: 1.234567e+06
keyType: INGEST
ingestType: LICENSE
name: License Key for <Account name>
pulumi {
required_providers {
newrelic = {
source = "pulumi/newrelic"
}
}
}
data "newrelic_getapiaccesskey" "default" {
account_id = 1234567
key_type = "INGEST"
ingest_type = "LICENSE"
name = "License Key for <Account name>"
}
Example: Look up a key directly by its ID
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
const byId = newrelic.getApiAccessKey({
keyId: "131313133A331313130B5F13DF01313FDB13B13133EE5E133D13EAAB3A3C13D3",
keyType: "INGEST",
});
import pulumi
import pulumi_newrelic as newrelic
by_id = newrelic.get_api_access_key(key_id="131313133A331313130B5F13DF01313FDB13B13133EE5E133D13EAAB3A3C13D3",
key_type="INGEST")
package main
import (
"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := newrelic.GetApiAccessKey(ctx, &newrelic.LookupApiAccessKeyArgs{
KeyId: pulumi.StringRef("131313133A331313130B5F13DF01313FDB13B13133EE5E133D13EAAB3A3C13D3"),
KeyType: "INGEST",
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using NewRelic = Pulumi.NewRelic;
return await Deployment.RunAsync(() =>
{
var byId = NewRelic.GetApiAccessKey.Invoke(new()
{
KeyId = "131313133A331313130B5F13DF01313FDB13B13133EE5E133D13EAAB3A3C13D3",
KeyType = "INGEST",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.newrelic.NewrelicFunctions;
import com.pulumi.newrelic.inputs.GetApiAccessKeyArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var byId = NewrelicFunctions.getApiAccessKey(GetApiAccessKeyArgs.builder()
.keyId("131313133A331313130B5F13DF01313FDB13B13133EE5E133D13EAAB3A3C13D3")
.keyType("INGEST")
.build());
}
}
variables:
byId:
fn::invoke:
function: newrelic:getApiAccessKey
arguments:
keyId: 131313133A331313130B5F13DF01313FDB13B13133EE5E133D13EAAB3A3C13D3
keyType: INGEST
pulumi {
required_providers {
newrelic = {
source = "pulumi/newrelic"
}
}
}
data "newrelic_getapiaccesskey" "byId" {
key_id = "131313133A331313130B5F13DF01313FDB13B13133EE5E133D13EAAB3A3C13D3"
key_type = "INGEST"
}
Example: Inject a license key into another resource
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
const ingest = newrelic.getApiAccessKey({
accountId: "1234567",
keyType: "INGEST",
ingestType: "LICENSE",
});
export const licenseKey = ingest.then(ingest => ingest.key);
import pulumi
import pulumi_newrelic as newrelic
ingest = newrelic.get_api_access_key(account_id="1234567",
key_type="INGEST",
ingest_type="LICENSE")
pulumi.export("licenseKey", ingest.key)
package main
import (
"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ingest, err := newrelic.GetApiAccessKey(ctx, &newrelic.LookupApiAccessKeyArgs{
AccountId: pulumi.StringRef("1234567"),
KeyType: "INGEST",
IngestType: pulumi.StringRef("LICENSE"),
}, nil)
if err != nil {
return err
}
ctx.Export("licenseKey", ingest.Key)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using NewRelic = Pulumi.NewRelic;
return await Deployment.RunAsync(() =>
{
var ingest = NewRelic.GetApiAccessKey.Invoke(new()
{
AccountId = "1234567",
KeyType = "INGEST",
IngestType = "LICENSE",
});
return new Dictionary<string, object?>
{
["licenseKey"] = ingest.Apply(getApiAccessKeyResult => getApiAccessKeyResult.Key),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.newrelic.NewrelicFunctions;
import com.pulumi.newrelic.inputs.GetApiAccessKeyArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var ingest = NewrelicFunctions.getApiAccessKey(GetApiAccessKeyArgs.builder()
.accountId("1234567")
.keyType("INGEST")
.ingestType("LICENSE")
.build());
ctx.export("licenseKey", ingest.key());
}
}
variables:
ingest:
fn::invoke:
function: newrelic:getApiAccessKey
arguments:
accountId: 1.234567e+06
keyType: INGEST
ingestType: LICENSE
outputs:
licenseKey: ${ingest.key}
pulumi {
required_providers {
newrelic = {
source = "pulumi/newrelic"
}
}
}
data "newrelic_getapiaccesskey" "ingest" {
account_id = 1234567
key_type = "INGEST"
ingest_type = "LICENSE"
}
output "licenseKey" {
value = data.newrelic_getapiaccesskey.ingest.key
}
Using getApiAccessKey
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getApiAccessKey(args: GetApiAccessKeyArgs, opts?: InvokeOptions): Promise<GetApiAccessKeyResult>
function getApiAccessKeyOutput(args: GetApiAccessKeyOutputArgs, opts?: InvokeOptions): Output<GetApiAccessKeyResult>def get_api_access_key(account_id: Optional[str] = None,
ingest_type: Optional[str] = None,
key_id: Optional[str] = None,
key_type: Optional[str] = None,
name: Optional[str] = None,
user_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetApiAccessKeyResult
def get_api_access_key_output(account_id: pulumi.Input[Optional[str]] = None,
ingest_type: pulumi.Input[Optional[str]] = None,
key_id: pulumi.Input[Optional[str]] = None,
key_type: pulumi.Input[Optional[str]] = None,
name: pulumi.Input[Optional[str]] = None,
user_id: pulumi.Input[Optional[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetApiAccessKeyResult]func LookupApiAccessKey(ctx *Context, args *LookupApiAccessKeyArgs, opts ...InvokeOption) (*LookupApiAccessKeyResult, error)
func LookupApiAccessKeyOutput(ctx *Context, args *LookupApiAccessKeyOutputArgs, opts ...InvokeOption) LookupApiAccessKeyResultOutput> Note: This function is named LookupApiAccessKey in the Go SDK.
public static class GetApiAccessKey
{
public static Task<GetApiAccessKeyResult> InvokeAsync(GetApiAccessKeyArgs args, InvokeOptions? opts = null)
public static Output<GetApiAccessKeyResult> Invoke(GetApiAccessKeyInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetApiAccessKeyResult> getApiAccessKey(GetApiAccessKeyArgs args, InvokeOptions options)
public static Output<GetApiAccessKeyResult> getApiAccessKey(GetApiAccessKeyArgs args, InvokeOptions options)
fn::invoke:
function: newrelic:index/getApiAccessKey:getApiAccessKey
arguments:
# arguments dictionarydata "newrelic_get_api_access_key" "name" {
# arguments
}The following arguments are supported:
- Key
Type string - The type of the key to look up. Valid options are
INGESTorUSER(case-sensitive). - Account
Id string - The New Relic account ID to search for keys in. Defaults to the
accountIdset in theprovider{}block (or theNEW_RELIC_ACCOUNT_IDenvironment variable) if not specified. - Ingest
Type string - Filters the search to ingest keys of the given type. Valid options are
LICENSEorBROWSER(case-sensitive). Only applies whenkeyTypeisINGEST. - Key
Id string - The ID of the key to look up. When specified, the key is fetched directly by its ID and all other search arguments are ignored.
- Name string
Filters the search to keys with the given name.
NOTE: When
keyIdis not specified, the search must resolve to exactly one key. If zero or more than one key matches the given criteria, the data source returns an error. In such a case, provide additional arguments (such asname,ingestTypeoruserId) to identify a unique key, or specifykeyIddirectly to bypass the search.- User
Id string - Filters the search to user keys owned by the given New Relic user ID. Only applies when
keyTypeisUSER.
- Key
Type string - The type of the key to look up. Valid options are
INGESTorUSER(case-sensitive). - Account
Id string - The New Relic account ID to search for keys in. Defaults to the
accountIdset in theprovider{}block (or theNEW_RELIC_ACCOUNT_IDenvironment variable) if not specified. - Ingest
Type string - Filters the search to ingest keys of the given type. Valid options are
LICENSEorBROWSER(case-sensitive). Only applies whenkeyTypeisINGEST. - Key
Id string - The ID of the key to look up. When specified, the key is fetched directly by its ID and all other search arguments are ignored.
- Name string
Filters the search to keys with the given name.
NOTE: When
keyIdis not specified, the search must resolve to exactly one key. If zero or more than one key matches the given criteria, the data source returns an error. In such a case, provide additional arguments (such asname,ingestTypeoruserId) to identify a unique key, or specifykeyIddirectly to bypass the search.- User
Id string - Filters the search to user keys owned by the given New Relic user ID. Only applies when
keyTypeisUSER.
- key_
type string - The type of the key to look up. Valid options are
INGESTorUSER(case-sensitive). - account_
id string - The New Relic account ID to search for keys in. Defaults to the
accountIdset in theprovider{}block (or theNEW_RELIC_ACCOUNT_IDenvironment variable) if not specified. - ingest_
type string - Filters the search to ingest keys of the given type. Valid options are
LICENSEorBROWSER(case-sensitive). Only applies whenkeyTypeisINGEST. - key_
id string - The ID of the key to look up. When specified, the key is fetched directly by its ID and all other search arguments are ignored.
- name string
Filters the search to keys with the given name.
NOTE: When
keyIdis not specified, the search must resolve to exactly one key. If zero or more than one key matches the given criteria, the data source returns an error. In such a case, provide additional arguments (such asname,ingestTypeoruserId) to identify a unique key, or specifykeyIddirectly to bypass the search.- user_
id string - Filters the search to user keys owned by the given New Relic user ID. Only applies when
keyTypeisUSER.
- key
Type String - The type of the key to look up. Valid options are
INGESTorUSER(case-sensitive). - account
Id String - The New Relic account ID to search for keys in. Defaults to the
accountIdset in theprovider{}block (or theNEW_RELIC_ACCOUNT_IDenvironment variable) if not specified. - ingest
Type String - Filters the search to ingest keys of the given type. Valid options are
LICENSEorBROWSER(case-sensitive). Only applies whenkeyTypeisINGEST. - key
Id String - The ID of the key to look up. When specified, the key is fetched directly by its ID and all other search arguments are ignored.
- name String
Filters the search to keys with the given name.
NOTE: When
keyIdis not specified, the search must resolve to exactly one key. If zero or more than one key matches the given criteria, the data source returns an error. In such a case, provide additional arguments (such asname,ingestTypeoruserId) to identify a unique key, or specifykeyIddirectly to bypass the search.- user
Id String - Filters the search to user keys owned by the given New Relic user ID. Only applies when
keyTypeisUSER.
- key
Type string - The type of the key to look up. Valid options are
INGESTorUSER(case-sensitive). - account
Id string - The New Relic account ID to search for keys in. Defaults to the
accountIdset in theprovider{}block (or theNEW_RELIC_ACCOUNT_IDenvironment variable) if not specified. - ingest
Type string - Filters the search to ingest keys of the given type. Valid options are
LICENSEorBROWSER(case-sensitive). Only applies whenkeyTypeisINGEST. - key
Id string - The ID of the key to look up. When specified, the key is fetched directly by its ID and all other search arguments are ignored.
- name string
Filters the search to keys with the given name.
NOTE: When
keyIdis not specified, the search must resolve to exactly one key. If zero or more than one key matches the given criteria, the data source returns an error. In such a case, provide additional arguments (such asname,ingestTypeoruserId) to identify a unique key, or specifykeyIddirectly to bypass the search.- user
Id string - Filters the search to user keys owned by the given New Relic user ID. Only applies when
keyTypeisUSER.
- key_
type str - The type of the key to look up. Valid options are
INGESTorUSER(case-sensitive). - account_
id str - The New Relic account ID to search for keys in. Defaults to the
accountIdset in theprovider{}block (or theNEW_RELIC_ACCOUNT_IDenvironment variable) if not specified. - ingest_
type str - Filters the search to ingest keys of the given type. Valid options are
LICENSEorBROWSER(case-sensitive). Only applies whenkeyTypeisINGEST. - key_
id str - The ID of the key to look up. When specified, the key is fetched directly by its ID and all other search arguments are ignored.
- name str
Filters the search to keys with the given name.
NOTE: When
keyIdis not specified, the search must resolve to exactly one key. If zero or more than one key matches the given criteria, the data source returns an error. In such a case, provide additional arguments (such asname,ingestTypeoruserId) to identify a unique key, or specifykeyIddirectly to bypass the search.- user_
id str - Filters the search to user keys owned by the given New Relic user ID. Only applies when
keyTypeisUSER.
- key
Type String - The type of the key to look up. Valid options are
INGESTorUSER(case-sensitive). - account
Id String - The New Relic account ID to search for keys in. Defaults to the
accountIdset in theprovider{}block (or theNEW_RELIC_ACCOUNT_IDenvironment variable) if not specified. - ingest
Type String - Filters the search to ingest keys of the given type. Valid options are
LICENSEorBROWSER(case-sensitive). Only applies whenkeyTypeisINGEST. - key
Id String - The ID of the key to look up. When specified, the key is fetched directly by its ID and all other search arguments are ignored.
- name String
Filters the search to keys with the given name.
NOTE: When
keyIdis not specified, the search must resolve to exactly one key. If zero or more than one key matches the given criteria, the data source returns an error. In such a case, provide additional arguments (such asname,ingestTypeoruserId) to identify a unique key, or specifykeyIddirectly to bypass the search.- user
Id String - Filters the search to user keys owned by the given New Relic user ID. Only applies when
keyTypeisUSER.
getApiAccessKey Result
The following output properties are available:
- Account
Id string - The New Relic account ID the key belongs to.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ingest
Type string - The type of the ingest key (
LICENSEorBROWSER). Populated only whenkeyTypeisINGEST. - Key string
- The value of the API key. This attribute is marked as sensitive.
- It is important to exercise caution when exporting the value of
key, as it is sensitive information. Avoid logging or exposing it inappropriately. - Not populated when the New Relic API returns a truncated key value; see the warning at the top of this page.
- It is important to exercise caution when exporting the value of
- Key
Id string - The ID of the API key.
- Key
Type string - The type of the key (
INGESTorUSER). - Name string
- The name of the API key.
- Notes string
- Any notes attached to the API key.
- User
Id string - The New Relic user ID that owns the key. Populated only when
keyTypeisUSER.
- Account
Id string - The New Relic account ID the key belongs to.
- Id string
- The provider-assigned unique ID for this managed resource.
- Ingest
Type string - The type of the ingest key (
LICENSEorBROWSER). Populated only whenkeyTypeisINGEST. - Key string
- The value of the API key. This attribute is marked as sensitive.
- It is important to exercise caution when exporting the value of
key, as it is sensitive information. Avoid logging or exposing it inappropriately. - Not populated when the New Relic API returns a truncated key value; see the warning at the top of this page.
- It is important to exercise caution when exporting the value of
- Key
Id string - The ID of the API key.
- Key
Type string - The type of the key (
INGESTorUSER). - Name string
- The name of the API key.
- Notes string
- Any notes attached to the API key.
- User
Id string - The New Relic user ID that owns the key. Populated only when
keyTypeisUSER.
- account_
id string - The New Relic account ID the key belongs to.
- id string
- The provider-assigned unique ID for this managed resource.
- ingest_
type string - The type of the ingest key (
LICENSEorBROWSER). Populated only whenkeyTypeisINGEST. - key string
- The value of the API key. This attribute is marked as sensitive.
- It is important to exercise caution when exporting the value of
key, as it is sensitive information. Avoid logging or exposing it inappropriately. - Not populated when the New Relic API returns a truncated key value; see the warning at the top of this page.
- It is important to exercise caution when exporting the value of
- key_
id string - The ID of the API key.
- key_
type string - The type of the key (
INGESTorUSER). - name string
- The name of the API key.
- notes string
- Any notes attached to the API key.
- user_
id string - The New Relic user ID that owns the key. Populated only when
keyTypeisUSER.
- account
Id String - The New Relic account ID the key belongs to.
- id String
- The provider-assigned unique ID for this managed resource.
- ingest
Type String - The type of the ingest key (
LICENSEorBROWSER). Populated only whenkeyTypeisINGEST. - key String
- The value of the API key. This attribute is marked as sensitive.
- It is important to exercise caution when exporting the value of
key, as it is sensitive information. Avoid logging or exposing it inappropriately. - Not populated when the New Relic API returns a truncated key value; see the warning at the top of this page.
- It is important to exercise caution when exporting the value of
- key
Id String - The ID of the API key.
- key
Type String - The type of the key (
INGESTorUSER). - name String
- The name of the API key.
- notes String
- Any notes attached to the API key.
- user
Id String - The New Relic user ID that owns the key. Populated only when
keyTypeisUSER.
- account
Id string - The New Relic account ID the key belongs to.
- id string
- The provider-assigned unique ID for this managed resource.
- ingest
Type string - The type of the ingest key (
LICENSEorBROWSER). Populated only whenkeyTypeisINGEST. - key string
- The value of the API key. This attribute is marked as sensitive.
- It is important to exercise caution when exporting the value of
key, as it is sensitive information. Avoid logging or exposing it inappropriately. - Not populated when the New Relic API returns a truncated key value; see the warning at the top of this page.
- It is important to exercise caution when exporting the value of
- key
Id string - The ID of the API key.
- key
Type string - The type of the key (
INGESTorUSER). - name string
- The name of the API key.
- notes string
- Any notes attached to the API key.
- user
Id string - The New Relic user ID that owns the key. Populated only when
keyTypeisUSER.
- account_
id str - The New Relic account ID the key belongs to.
- id str
- The provider-assigned unique ID for this managed resource.
- ingest_
type str - The type of the ingest key (
LICENSEorBROWSER). Populated only whenkeyTypeisINGEST. - key str
- The value of the API key. This attribute is marked as sensitive.
- It is important to exercise caution when exporting the value of
key, as it is sensitive information. Avoid logging or exposing it inappropriately. - Not populated when the New Relic API returns a truncated key value; see the warning at the top of this page.
- It is important to exercise caution when exporting the value of
- key_
id str - The ID of the API key.
- key_
type str - The type of the key (
INGESTorUSER). - name str
- The name of the API key.
- notes str
- Any notes attached to the API key.
- user_
id str - The New Relic user ID that owns the key. Populated only when
keyTypeisUSER.
- account
Id String - The New Relic account ID the key belongs to.
- id String
- The provider-assigned unique ID for this managed resource.
- ingest
Type String - The type of the ingest key (
LICENSEorBROWSER). Populated only whenkeyTypeisINGEST. - key String
- The value of the API key. This attribute is marked as sensitive.
- It is important to exercise caution when exporting the value of
key, as it is sensitive information. Avoid logging or exposing it inappropriately. - Not populated when the New Relic API returns a truncated key value; see the warning at the top of this page.
- It is important to exercise caution when exporting the value of
- key
Id String - The ID of the API key.
- key
Type String - The type of the key (
INGESTorUSER). - name String
- The name of the API key.
- notes String
- Any notes attached to the API key.
- user
Id String - The New Relic user ID that owns the key. Populated only when
keyTypeisUSER.
Package Details
- Repository
- New Relic pulumi/pulumi-newrelic
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
newrelicTerraform Provider.
published on Saturday, Jul 18, 2026 by Pulumi