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

# Update API key

> Rename an existing API key or adjust its expiration date.

Update API key metadata.

### Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the API key.
</ParamField>

### Body Parameters

<ParamField body="name" type="string">
  New descriptive label.
</ParamField>

<ParamField body="expires_at" type="string">
  New expiration date in ISO 8601 format, or `null` for no expiration.
</ParamField>

### Response

<ResponseField name="data" type="object">
  <ResponseField name="id" type="string">Key ID.</ResponseField>
  <ResponseField name="name" type="string">Updated name.</ResponseField>
  <ResponseField name="expires_at" type="string">Updated expiration.</ResponseField>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PATCH https://api.mailofly.com/api/v1/api-keys/key_123456 \
    -H "Authorization: Bearer mf_live_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Staging Backend"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "id": "key_123456",
      "name": "Staging Backend",
      "secret_suffix": "9aBc",
      "expires_at": null
    }
  }
  ```
</ResponseExample>


## Related topics

- [Leaked API Keys](/guides/api-keys/leaked-api-keys.md)
- [API Key Security](/guides/api-keys/api-key-security.md)
- [Manage API Keys](/guides/api-keys/manage-api-keys.md)
- [Delete API key](/api/api-keys/delete-api-key.md)
- [Create API key](/api/api-keys/create-api-key.md)
