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

# rotateApiKey

> Rotate an API key to generate a new token



**mutation** `rotateApiKey(input: RotateApiKeyInput!): RotateApiKeyResult!`

## Arguments

**`input`**: `RotateApiKeyInput!` (required)

## Returns

`RotateApiKeyResult!`

**`newApiKey`**: `ApiKey!`

The newly created API key details

---

**`oldApiKey`**: `ApiKey`

The old API key that is being rotated out

## Examples

```graphql Mutation
mutation RotateApiKey($input: RotateApiKeyInput!) {
  rotateApiKey(input: $input) {
    newApiKey {
      createdAt
      description
      displayName
      environmentId
      expireAt
      id
    }
    oldApiKey {
      createdAt
      description
      displayName
      environmentId
      expireAt
      id
    }
  }
}
```

```json Variables
{
  "input": {
    "id": "value"
  }
}
```

```json Response
{
  "data": {
    "rotateApiKey": {
      "newApiKey": {
        "createdAt": "value",
        "description": "string",
        "displayName": "string",
        "environmentId": "value",
        "expireAt": "value",
        "id": "value"
      },
      "oldApiKey": {
        "createdAt": "value",
        "description": "string",
        "displayName": "string",
        "environmentId": "value",
        "expireAt": "value",
        "id": "value"
      }
    }
  }
}
```


## Related topics

- [RotateApiKeyInput](https://docs.stigg.io/graphql-reference/types/RotateApiKeyInput.md)
- [RotateApiKeyResult](https://docs.stigg.io/graphql-reference/types/RotateApiKeyResult.md)
- [API Keys](https://docs.stigg.io/documentation/managing-your-account/environments/api-keys.md)
- [Go SDK](https://docs.stigg.io/api-and-sdks/changelog/backend-graphql/go.md)
- [ApiKey](https://docs.stigg.io/graphql-reference/types/ApiKey.md)


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