# Update a connector credential

> **PATCH** `https://api.us.nylas.com/v3/connectors/{provider}/creds/{id}`

Source: https://developer.nylas.com/docs/reference/api/connector-credentials/patch_credential_by_id/

Updates the specified connector credential.

When you make a `PATCH` request, Nylas replaces all data in the nested object with the information
included in your request. For more information, see
[Updating objects](/docs/reference/api/#updating-objects).

**Authentication:** NYLAS_API_KEY

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `provider` | string | Yes |  |
| `id` | string | Yes |  |

## Request body

Content-Type: application/json

- `name` (string) - The credential name.
- `credential_data` (object) - An object that specifies some special information required for the credential.
This information is securely encoded and stored, and is _not_ visible to users.

For the
[Google App Permission flow](/docs/v3/auth/bulk-auth-grants/#google-app-permission-via-nylas),
this field must contain the `private_key_id`, `private_key`, and `client_email`.

For the
[Microsoft App Permission flow](/docs/v3/auth/bulk-auth-grants/#use-a-microsoft-bulk-authentication-grant),
this field must contain the Azure `client_id` and `client_secret`.

To use the credential to override a connector, this field must contain the `client_id`
and `client_secret`.

## Responses

### 200 - Returns the updated credential.

- `request_id` (string) - The request ID.
- `data` (object)
  - `id` (string) **(required)** - Credential ID
  - `name` (string) **(required)** - Unique name of this credential
  - `created_at` (integer) **(required)** - Date of creation of the credential
  - `updated_at` (integer) **(required)** - Initially same as `created_at`. Can differ if the credential has been updated.

### 400 - Bad Request

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

### 401 - Not Authenticated

- `request_id` (string) **(required)** - ID of the request
- `error` (object) **(required)** - Error object
  - `type` (string) - Type of error
  - `message` (string) - Informative error message
  - `provider_error` (object) - (OPTIONAL) informative error message from provider's side

## Code samples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.us.nylas.com/v3/connectors/<CONNECTOR>/creds/<CREDENTIAL_ID>' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --data '{
    "name": "google",
    "credential_data": {
      "client_id": "<PROVIDER_CLIENT_ID>",
      "client_secret": "<PROVIDER_CLIENT_SECRET>"
    }
  }'
```

### Node.js SDK

```javascript
import Nylas from "nylas";

const nylas = new Nylas({
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
});

const updated = await nylas.connectors.credentials.update({
  provider: "google",
  credentialsId: "<CREDENTIAL_ID>",
  requestBody: {
    name: "google",
    credentialData: {
      client_id: "<PROVIDER_CLIENT_ID>",
      client_secret: "<PROVIDER_CLIENT_SECRET>",
    },
  },
});

console.log("Credential updated:", updated);

```

### Python SDK

```python
from nylas import Client

nylas = Client(
    "<NYLAS_API_KEY>",
    "<NYLAS_API_URI>",
)

credential = nylas.connectors.credentials.update(
    provider="google",
    credential_id="<CREDENTIAL_ID>",
    request_body={
        "name": "Updated connector override",
    },
)

print("Updated credential:", credential)

```

### Java SDK

```java
import com.nylas.NylasClient;
import com.nylas.models.AuthProvider;
import com.nylas.models.Credential;
import com.nylas.models.CredentialData;
import com.nylas.models.NylasApiError;
import com.nylas.models.NylasSdkTimeoutError;
import com.nylas.models.Response;
import com.nylas.models.UpdateCredentialRequest;

public class UpdateCredential {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();

    CredentialData.ConnectorOverride credentialData = new CredentialData.ConnectorOverride(
        "<PROVIDER_CLIENT_ID>", "<PROVIDER_CLIENT_SECRET>", null);

    UpdateCredentialRequest requestBody = new UpdateCredentialRequest.Builder()
        .name("google")
        .credentialData(credentialData)
        .build();

    Response<Credential> updated = nylas.connectors().credentials()
        .update(AuthProvider.GOOGLE, "<CREDENTIAL_ID>", requestBody);

    System.out.println("Credential updated: " + updated.getData());
  }
}

```

### Kotlin SDK

```kotlin
import com.nylas.NylasClient
import com.nylas.models.AuthProvider
import com.nylas.models.CredentialData
import com.nylas.models.UpdateCredentialRequest

fun main() {
  val nylas = NylasClient.Builder("<NYLAS_API_KEY>").build()

  val credentialData = CredentialData.ConnectorOverride(
      clientId = "<PROVIDER_CLIENT_ID>",
      clientSecret = "<PROVIDER_CLIENT_SECRET>")

  val requestBody = UpdateCredentialRequest.Builder()
      .name("google")
      .credentialData(credentialData)
      .build()

  val updated = nylas.connectors().credentials()
      .update(AuthProvider.GOOGLE, "<CREDENTIAL_ID>", requestBody)

  println("Credential updated: ${updated.data}")
}

```
