# Refresh authentication for a connected account

**Documentation:** /reference/api-reference/connected-accounts/postConnectedAccountsByNanoidRefresh

Initiates a new authentication flow for a connected account when credentials have expired or become invalid. This may generate a new authentication URL for OAuth flows or refresh tokens for other auth schemes.

---

## POST `/api/v3/connected_accounts/{nanoid}/refresh`

**Endpoint:** `https://backend.composio.dev/api/v3/connected_accounts/{nanoid}/refresh`

**Summary:** Refresh authentication for a connected account

Initiates a new authentication flow for a connected account when credentials have expired or become invalid. This may generate a new authentication URL for OAuth flows or refresh tokens for other auth schemes.

### Authentication

**ApiKeyAuth** - API Key in `header` header `x-api-key` OR **UserApiKeyAuth** - API Key in `header` header `x-user-api-key`

### Path Parameters

- `nanoid` (string (connectedAccountId)) *(required)*: The unique identifier of the connected account

### Query Parameters

- `redirect_url` (string (uri)): 

### Request Body

**Schema:**

- `redirect_url` (string (uri))
- `validate_credentials` (boolean): [EXPERIMENTAL] Whether to validate the provided credentials, validates only for API Key Auth scheme

**Example:**

```json
{
  "redirect_url": "https://example.com",
  "validate_credentials": false
}
```

### Responses

#### 200 - Successfully refreshed the connected account authentication. For OAuth flows, a new redirect URL is provided.

**Response Schema:**

- `id` (string) *(required)*: The unique identifier of the connected account
- `status` (enum: "INITIALIZING" | "INITIATED" | "ACTIVE" | ...) *(required)*: The current status of the connected account (e.g., active, pending, failed)
- `redirect_url` (string,null) *(required)*: The URL to which the user should be redirected to complete the authentication process (null for auth schemes that do not require redirection)

**Example Response:**

```json
{
  "id": "string",
  "status": "INITIALIZING",
  "redirect_url": null
}
```

#### 400 - Bad request - Invalid nanoid format or the account cannot be refreshed in its current state

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 401 - Unauthorized - Authentication failed

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 403 - Forbidden - Insufficient permissions to refresh this connected account

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 404 - Not found - Connected account does not exist or was deleted

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 500 - Internal server error - Failed to refresh the connected account authentication

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 501 - Not implemented - This operation is not supported for the requested connected account or authentication scheme

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

### Example cURL Request

```bash
curl -X POST "https://backend.composio.dev/api/v3/connected_accounts/string/refresh" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "redirect_url": "https://example.com",
    "validate_credentials": false
  }'
```