Secure credentials help you store, protect, and centrally manage sensitive information like passwords, API keys, or encoded certificates. Your synthetic monitors can securely access this information during script execution. This tutorial provides examples of how to use the NerdGraph API to programmatically manage secure credentials.
Create a secure credential
You can create a secure credential using the syntheticsCreateSecureCredential mutation. This mutation allows you to securely store sensitive information that your synthetic monitors can access during script execution.
Input parameters
Parameter | Data Type | Is it Required? | Description |
|---|---|---|---|
| Integer | Yes | The account ID of the New Relic account where the secure credential will be created. |
| String | No | A description to help identify the purpose of this credential. |
| String | Yes | The unique key identifier for the synthetics secure credential in New Relic. |
| String | Yes | The sensitive value to store securely (password, API key, etc.). |
Sample request
mutation { syntheticsCreateSecureCredential( accountId: ACCOUNT_ID description: "Your optional description" key: "SECURE_CREDENTIAL_NAME" value: "SECURE_CREDENTIAL_VALUE" ) { errors { description type } }}Sample response
A successful response returns null for errors:
{ "data": { "syntheticsCreateSecureCredential": { "errors": null } }}If there are any issues creating the secure credential, the errors array will contain objects with description and type fields explaining what went wrong.
Update a secure credential
You can update an existing secure credential using the syntheticsUpdateSecureCredential mutation. This allows you to modify the value and description while keeping the same key name.
Input parameters
Parameter | Data Type | Is it Required? | Description |
|---|---|---|---|
| Integer | Yes | The account ID that contains the secure credential. |
| String | No | Updated description for the secure credential. |
| String | Yes | The unique key identifier for the synthetics secure credential in New Relic. |
| String | Yes | The new sensitive value to store. |
Sample request
mutation { syntheticsUpdateSecureCredential( accountId: ACCOUNT_ID description: "Updated description for the secure credential." key: "SECURE_CREDENTIAL_NAME" value: "SECURE_CREDENTIAL_VALUE" ) { createdAt lastUpdate errors { description type } }}Sample response
A successful response returns the updated metadata and null for errors:
{ "data": { "syntheticsUpdateSecureCredential": { "createdAt": "2024-01-15T10:30:00Z", "lastUpdate": "2024-01-20T14:45:00Z", "errors": null } }}If there are any issues updating the secure credential, the errors array will contain objects with description and type fields explaining what went wrong.
Delete a secure credential
You can delete a secure credential using the syntheticsDeleteSecureCredential mutation. Once deleted, any monitors referencing this credential will fail until updated.
Prudence
Before deleting a secure credential, make sure no active monitors are using it. Deleting a credential that's in use will cause those monitors to fail.
Input parameters
Parameter | Data Type | Is it Required? | Description |
|---|---|---|---|
| Integer | Yes | The account ID that contains the secure credential. |
| String | Yes | The unique key identifier for the synthetics secure credential in New Relic. |
Sample request
mutation { syntheticsDeleteSecureCredential( accountId: ACCOUNT_ID key: "SECURE_CREDENTIAL_NAME" ) { errors { description type } }}Sample response
A successful response returns null for errors:
{ "data": { "syntheticsDeleteSecureCredential": { "errors": null } }}If there are any issues deleting the secure credential, the errors array will contain objects with description and type fields explaining what went wrong.