> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revoengine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# serviceAccount.rotateKey()

> Public low-code contract, signatures and examples for serviceAccount.rotateKey.

## `serviceAccount.rotateKey()`

Creates a new credential; gracePeriodMs defaults to 0, max 365 days.
Omit expireAt to inherit it, pass null for no expiration, or a date at least four hours ahead.

### Signature

```ts theme={null}
static rotateKey(ref: ServiceAccountRef, userKeyId: string, input: ServiceAccountKeyRotateInput): Promise<ServiceAccountKeyRotated>;
```

### Example

```ts theme={null}
const key = await serviceAccount.getKey('erp-sync', input.userKeyId);
const { newKey } = await serviceAccount.rotateKey('erp-sync', key.userKeyId, { version: key.version, gracePeriodMs: 60000 });
await vault.rotate('ERP_API_KEY', { value: newKey.secret });
```

See [all serviceAccount methods](https://docs.revoengine.com/low-code/reference/serviceAccount.md) or [runtime basics](https://docs.revoengine.com/low-code/overview.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.