---
title: Manage secure credentials
source: https://docs.newrelic.com/docs/apis/nerdgraph/examples/synthetics-api/secure-credentials
---

[Secure credentials](https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/using-monitors/store-secure-credentials-scripted-browsers-api-tests) 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 [#create-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                                                                                                                                                                   |
| ------------- | --------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId`   | Integer   | Yes             | The [account ID](https://docs.newrelic.com/docs/accounts/accounts-billing/account-structure/account-id) of the New Relic account where the secure credential will be created. |
| `description` | String    | No              | A description to help identify the purpose of this credential.                                                                                                                |
| `key`         | String    | Yes             | The unique key identifier for the synthetics secure credential in New Relic.                                                                                                  |
| `value`       | String    | Yes             | The sensitive value to store securely (password, API key, etc.).                                                                                                              |

### Sample request

```graphql
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:

```json
{
  "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 [#update-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                                                                                                                                  |
| ------------- | --------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId`   | Integer   | Yes             | The [account ID](https://docs.newrelic.com/docs/accounts/accounts-billing/account-structure/account-id) that contains the secure credential. |
| `description` | String    | No              | Updated description for the secure credential.                                                                                               |
| `key`         | String    | Yes             | The unique key identifier for the synthetics secure credential in New Relic.                                                                 |
| `value`       | String    | Yes             | The new sensitive value to store.                                                                                                            |

### Sample request

```graphql
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:

```json
{
  "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 [#delete-secure-credential]

You can delete a secure credential using the `syntheticsDeleteSecureCredential` mutation. Once deleted, any monitors referencing this credential will fail until updated.

> #### ⚠️ CAUTION
>
> 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                                                                                                                                  |
| ----------- | --------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId` | Integer   | Yes             | The [account ID](https://docs.newrelic.com/docs/accounts/accounts-billing/account-structure/account-id) that contains the secure credential. |
| `key`       | String    | Yes             | The unique key identifier for the synthetics secure credential in New Relic.                                                                 |

### Sample request

```graphql
mutation {
  syntheticsDeleteSecureCredential(
    accountId: ACCOUNT_ID,
    key: "SECURE_CREDENTIAL_NAME"
  ) {
    errors {
      description
      type
    }
  }
}
```

### Sample response

A successful response returns `null` for errors:

```json
{
  "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.

## Query secure credentials [#query-secure-credentials]

Use NerdGraph to retrieve credential metadata.

For more information, refer to:

-   [Query secure credentials](https://docs.newrelic.com/docs/apis/nerdgraph/examples/synthetics-api/query-synthetics-data#query-secure-credentials) - Get secure credential metadata (names, GUIDs, last updated).

To view complete list of query examples, refer to the [Query synthetics data](https://docs.newrelic.com/docs/apis/nerdgraph/examples/synthetics-api/query-synthetics-data) document.
