> ## Documentation Index
> Fetch the complete documentation index at: https://doc-dev.weir.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Refresh Client Credentials

> Generate new credentials for an API client

# Refresh Client Credentials

Generate new credentials for an existing API client. The old credentials will be invalidated.

<Warning>
  **Important**: Old credentials will be immediately invalidated. Update all applications using the old credentials.
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PATCH 'https://api.weir.ai/org/refresh/client?clientId=cli_123456789' \
    -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
    -H 'x-source: console'
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "data": {
      "clientId": "cli_123456789",
      "credentials": {
        "clientId": "NewClientId123",
        "secretKey": "NewSecretKey456"
      },
      "refreshedAt": "2024-01-22T15:30:00Z"
    },
    "message": "Client credentials refreshed successfully",
    "status": "success"
  }
  ```
</ResponseExample>

## Query Parameters

<ParamField query="clientId" type="string" required>
  Client ID to refresh credentials for.
</ParamField>

## Response Fields

<ResponseField name="data.credentials" type="object" required>
  New client credentials.

  <Expandable title="Credentials">
    <ResponseField name="credentials.clientId" type="string" required>
      New client ID for authentication.
    </ResponseField>

    <ResponseField name="credentials.secretKey" type="string" required>
      New secret key. Store securely - shown only once.
    </ResponseField>
  </Expandable>
</ResponseField>

## Usage Examples

<CodeGroup>
  ```javascript JavaScript theme={null}
  const refreshClient = async (clientId, accessToken) => {
    const response = await fetch(`https://api.weir.ai/org/refresh/client?clientId=${clientId}`, {
      method: 'PATCH',
      headers: {
        'Authorization': `Bearer ${accessToken}`,
        'x-source': 'console'
      }
    });
    if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
    return await response.json();
  };
  ```

  ```python Python theme={null}
  import requests

  def refresh_client(client_id, access_token):
      response = requests.patch(
          f'https://api.weir.ai/org/refresh/client?clientId={client_id}',
          headers={
              'Authorization': f'Bearer {access_token}',
              'x-source': 'console'
          }
      )
      response.raise_for_status()
      return response.json()
  ```
</CodeGroup>

<Tip>
  **Pro Tip**: Refresh credentials if they are compromised or as part of regular security rotation practices.
</Tip>
