> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetConnection

# Package: googleSearchConsole

# Namespace: GscConnectionService

# Method link: https://dev.wix.com/docs/api-reference/business-management/seo/google-search-console/connection-v1/get-connection.md

## Permission Scopes:
View SEO Settings: SCOPE.PROMOTE.VIEW-SEO

## Introduction

Retrieves the site's Google Search Console connection status.

One endpoint for both polling and steady-state reads: poll it after
surfacing the URL from Get Connect URL until the status is `VALID`, or
call it any time to learn whether the site is connected and as whom.
When polling, every few seconds is enough. Stop after 2 hours, when the
authorization attempt expires.

Returns `PENDING` while a connect started with Get Connect URL awaits the
user's authorization on Google, and `NOT_CONNECTED` when the site has no
Google account connected and no connect is in flight.

---

## REST API

### Schema

```
 Method: getConnection
 Description: Retrieves the site's Google Search Console connection status.  One endpoint for both polling and steady-state reads: poll it after surfacing the URL from Get Connect URL until the status is `VALID`, or call it any time to learn whether the site is connected and as whom. When polling, every few seconds is enough. Stop after 2 hours, when the authorization attempt expires.  Returns `PENDING` while a connect started with Get Connect URL awaits the user's authorization on Google, and `NOT_CONNECTED` when the site has no Google account connected and no connect is in flight.
 URL: https://www.wixapis.com/gsc/connection/v1/connection
 Method: GET
 Return type: GetConnectionResponse
  - name: connection | type: Connection | description: The site's current Google Search Console connection.  
     - name: status | type: ConnectionStatus | description: Status of the site's Google Search Console connection.  | read-only: true 
         - enum:
         -     UNKNOWN_CONNECTION_STATUS: Unknown connection status.
         -     NOT_CONNECTED: The site has no Google account connected. It was never connected, or a past connection was removed.
         -     PENDING: An authorization attempt was started with Get Connect URL and hasn't completed yet. Keep polling; the status becomes `VALID` when the person finishes authorizing. Only reported while the site has no stored credentials.
         -     VALID: The connection is usable.
         -     INVALID: Stored credentials exist, but the last Google Search Console call Wix made with them was rejected as an authorization or permission failure. For example, the account owner revoked Wix's access, or the account lost access to the property. Connect again with Get Connect URL.  This is only ever set by a real call to Google, so a site Wix has not queried since the credentials broke still reports `VALID`.
     - name: connectedEmailMasking | type: string | description: Masked email address of the connected Google account. For example, `m*********@gmail.com`.  Only returned when `status` is `VALID` or `INVALID`.  | read-only: true | validation: maxLength 320
     - name: ownedByCaller | type: boolean | description: Whether the connection is owned by the calling Wix user, meaning the caller is the one who connected the Google account. Only meaningful when `status` is `VALID` or `INVALID`.  | read-only: true 

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SITE_NOT_RESOLVED | Description: The site could not be resolved from the request context.


```

### Examples

### Get Connection
```curl
curl -X GET \
'https://www.wixapis.com/gsc/connection/v1/connection' \
-H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.gsc.connection.getConnection()
 Description: Retrieves the site's Google Search Console connection status.  One endpoint for both polling and steady-state reads: poll it after surfacing the URL from Get Connect URL until the status is `VALID`, or call it any time to learn whether the site is connected and as whom. When polling, every few seconds is enough. Stop after 2 hours, when the authorization attempt expires.  Returns `PENDING` while a connect started with Get Connect URL awaits the user's authorization on Google, and `NOT_CONNECTED` when the site has no Google account connected and no connect is in flight.
 Return type: PROMISE<GetConnectionResponse>
  - name: connection | type: Connection | description: The site's current Google Search Console connection.  
     - name: status | type: ConnectionStatus | description: Status of the site's Google Search Console connection.  | read-only: true 
         - enum:
         -     UNKNOWN_CONNECTION_STATUS: Unknown connection status.
         -     NOT_CONNECTED: The site has no Google account connected. It was never connected, or a past connection was removed.
         -     PENDING: An authorization attempt was started with Get Connect URL and hasn't completed yet. Keep polling; the status becomes `VALID` when the person finishes authorizing. Only reported while the site has no stored credentials.
         -     VALID: The connection is usable.
         -     INVALID: Stored credentials exist, but the last Google Search Console call Wix made with them was rejected as an authorization or permission failure. For example, the account owner revoked Wix's access, or the account lost access to the property. Connect again with Get Connect URL.  This is only ever set by a real call to Google, so a site Wix has not queried since the credentials broke still reports `VALID`.
     - name: connectedEmailMasking | type: string | description: Masked email address of the connected Google account. For example, `m*********@gmail.com`.  Only returned when `status` is `VALID` or `INVALID`.  | read-only: true | validation: maxLength 320
     - name: ownedByCaller | type: boolean | description: Whether the connection is owned by the calling Wix user, meaning the caller is the one who connected the Google account. Only meaningful when `status` is `VALID` or `INVALID`.  | read-only: true 

 Possible Errors:
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: SITE_NOT_RESOLVED | Description: The site could not be resolved from the request context.


```

### Examples

### Get the site's Google Search Console connection status
```javascript
import { connection } from "@wix/gsc";

async function getConnection() {
  const response = await connection.getConnection();
}

/* Promise resolves to:
 * {
 *   "connection": {
 *     "status": "NOT_CONNECTED",
 *     "connectedEmailMasking": "",
 *     "ownedByCaller": false
 *   }
 * }
 */

```

### getConnection (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { connection } from '@wix/gsc';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { connection },
  // Include the auth strategy and host as relevant
});


async function getConnection() {
  const response = await myWixClient.connection.getConnection();
};
```

---