---
title: "Regenerate Key"
method: POST
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/regenerateKey"
tags: ["CommunicationServices"]
---

# Regenerate Key

`POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/regenerateKey`

## Request

- Base URL: `https://management.azure.com`
- URL: `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Communication/communicationServices/{communicationServiceName}/regenerateKey`
- Auth: OAuth 2
  - Implicit: `https://login.microsoftonline.com/common/oauth2/authorize`
  - Scopes: `user_impersonation`

Regenerate CommunicationService access key. PrimaryKey and SecondaryKey cannot be regenerated at the same time.

## Path parameters

- `communicationServiceName` string, required

## Parameters

- `../../../../../common-types/resource-management/v6/types.json#/components/parameters/ApiVersionParameter` (unresolved $ref)
- `../../../../../common-types/resource-management/v6/types.json#/components/parameters/SubscriptionIdParameter` (unresolved $ref)
- `../../../../../common-types/resource-management/v6/types.json#/components/parameters/ResourceGroupNameParameter` (unresolved $ref)

## Request body

- RegenerateKeyParameters: Parameters describes the request to regenerate access keys
  - `keyType` 'Primary' | 'Secondary': The keyType to regenerate. Must be either 'primary' or 'secondary'(case-insensitive).

## Response `200`

Azure operation completed successfully.

- CommunicationServiceKeys: A class representing the access keys of a CommunicationService.
  - `primaryKey` string: The primary access key.
  - `secondaryKey` string: The secondary access key.
  - `primaryConnectionString` string: CommunicationService connection string constructed via the primaryKey
  - `secondaryConnectionString` string: CommunicationService connection string constructed via the secondaryKey

## Other responses

- `default`: An unexpected error response.

---

[API](https://skmtc.dev/azure/apis/azure-communication-services-management-api.md) - [All operations](https://skmtc.dev/azure/apis/azure-communication-services-management-api/llms.txt) - [OpenAPI document](https://skmtc.dev/azure/apis/azure-communication-services-management-api/revisions/e6c2b8feaddf?raw)
