> 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: bingWebmasterTools

# Namespace: BwtConnectionService

# Method link: https://dev.wix.com/docs/api-reference/business-management/seo/bing-webmaster-tools/connection-v1/get-connection.md

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

## Introduction

Retrieves the site's Bing Webmaster Tools 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. When polling,
every few seconds is enough. The person must finish on Bing within 10
minutes of opening the URL, so stop polling once that window has passed.

Returns `PENDING` while a connect started with Get Connect URL awaits the
person's authorization on Bing, and `NOT_CONNECTED` when the site has no
Bing account connected and no connect is in flight. An abandoned attempt
can report `PENDING` for up to 2 hours. While stored credentials exist,
the status stays `VALID` or `INVALID` during a reconnect and doesn't
report when it finishes, so call Disconnect before reconnecting. `VALID`
doesn't confirm that Bing still accepts the stored credentials: call Get
Site Readiness in the BWT Site Readiness API for that.

---

## REST API

### Schema

```
 Method: getConnection
 Description: Retrieves the site's Bing Webmaster Tools 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. When polling, every few seconds is enough. The person must finish on Bing within 10 minutes of opening the URL, so stop polling once that window has passed.  Returns `PENDING` while a connect started with Get Connect URL awaits the person's authorization on Bing, and `NOT_CONNECTED` when the site has no Bing account connected and no connect is in flight. An abandoned attempt can report `PENDING` for up to 2 hours. While stored credentials exist, the status stays `VALID` or `INVALID` during a reconnect and doesn't report when it finishes, so call Disconnect before reconnecting. `VALID` doesn't confirm that Bing still accepts the stored credentials: call Get Site Readiness in the BWT Site Readiness API for that.
 URL: https://www.wixapis.com/gsc/connection/v1/bing/connection
 Method: GET
 Return type: GetConnectionResponse
  - name: connection | type: Connection | description: The site's current Bing Webmaster Tools connection.  
     - name: status | type: ConnectionStatus | description: Status of the site's Bing Webmaster Tools connection.  | read-only: true 
         - enum:
         -     UNKNOWN_CONNECTION_STATUS: Unknown connection status.
         -     NOT_CONNECTED: The site has no Bing 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: Stored credentials exist and Wix has not recorded a failure for them.
         -     INVALID: Stored credentials exist, but Wix recorded the site as no longer connected, or can't read the stored credentials. Connect again with Get Connect URL.
     - name: ownedByCaller | type: boolean | description: Whether the connection is owned by the calling Wix user, meaning the caller is the one who connected the Bing 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/bwt/connection/v1/bing/connection' \
-H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bwt.connection.getConnection()
 Description: Retrieves the site's Bing Webmaster Tools 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. When polling, every few seconds is enough. The person must finish on Bing within 10 minutes of opening the URL, so stop polling once that window has passed.  Returns `PENDING` while a connect started with Get Connect URL awaits the person's authorization on Bing, and `NOT_CONNECTED` when the site has no Bing account connected and no connect is in flight. An abandoned attempt can report `PENDING` for up to 2 hours. While stored credentials exist, the status stays `VALID` or `INVALID` during a reconnect and doesn't report when it finishes, so call Disconnect before reconnecting. `VALID` doesn't confirm that Bing still accepts the stored credentials: call Get Site Readiness in the BWT Site Readiness API for that.
 Return type: PROMISE<GetConnectionResponse>
  - name: connection | type: Connection | description: The site's current Bing Webmaster Tools connection.  
     - name: status | type: ConnectionStatus | description: Status of the site's Bing Webmaster Tools connection.  | read-only: true 
         - enum:
         -     UNKNOWN_CONNECTION_STATUS: Unknown connection status.
         -     NOT_CONNECTED: The site has no Bing 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: Stored credentials exist and Wix has not recorded a failure for them.
         -     INVALID: Stored credentials exist, but Wix recorded the site as no longer connected, or can't read the stored credentials. Connect again with Get Connect URL.
     - name: ownedByCaller | type: boolean | description: Whether the connection is owned by the calling Wix user, meaning the caller is the one who connected the Bing 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 Bing Webmaster Tools connection status
```javascript
import { connection } from "@wix/bwt";

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

/* Promise resolves to:
 * {
 *   "connection": {
 *     "status": "NOT_CONNECTED"
 *   }
 * }
 */

```

### 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/bwt';
// 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();
};
```

---