# Retrieving Devices or Access Control Systems Connected Through a Connect Webview

When your app user completes a [Connect Webview](/latest/core-concepts/connect-webviews.md) authorization flow successfully, the resulting [`connected_account.connected` event](https://docs.seam.co/latest/api/events/) includes a `connected_account_id`. Also, once the connection is successful, the [`connect_webview` object](https://docs.seam.co/latest/api/connect_webviews/) includes the `connected_account_id`.

The first step in controlling connected devices or a connected ACS is to retrieve the newly-connected set of devices or ACS.

***

## Retrieve Connected Devices

Use this `connected_account_id` in a [List Devices](https://docs.seam.co/latest/api/devices/list) command to retrieve the devices that your user has just connected to Seam.

{% hint style="info" %}
If you set `wait_for_device_creation` to `false` when [creating the Connect Webview](https://docs.seam.co/latest/core-concepts/connect-webviews/pages/z175ORX3nDmSL90MmIaG#id-1.-create-a-connect-webview), you should wait for the [`connected_account.completed_first_sync` event](https://docs.seam.co/latest/api/events/) before retrieving the user's devices. This event indicates that Seam has finished the first sync of the connected account and the devices are now available.
{% endhint %}

{% tabs %}
{% tab title="JavaScript" %}
**Code:**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Retrieve all devices for the connected_account_id.
</strong>const connectedDevices = await seam.devices.list({
  connected_account_id: "11111111-1111-1111-1111-222222222222"
});
</code></pre>

**Output:**

```json
[
  {
    connected_account_id: '11111111-1111-1111-1111-222222222222',
    device_id: '11111111-1111-1111-1111-444444444444',
    display_name: 'Front Door Lock',
    is_managed: true,
    ...
  },
  ...
]
```

{% endtab %}

{% tab title="cURL" %}
**Code:**

```bash
# Retrieve all devices for the connected_account_id.
connected_devices=$(
  # Use GET or POST.
  curl -X 'GET' \
    'https://connect.getseam.com/devices/list' \
    -H 'accept: application/json' \
    -H "Authorization: Bearer ${SEAM_API_KEY}" \
    -H 'Content-Type: application/json' \
    -d '{
    "connected_account_id": "11111111-1111-1111-1111-222222222222"
  }')
```

**Output:**

```json
{
  "devices": [
    {
      "connected_account_id": "11111111-1111-1111-1111-222222222222",
      "device_id": "11111111-1111-1111-1111-444444444444",
      "display_name": "Front Door Lock",
      "is_managed": true,
      ...
    },
    ...
  ],
  "ok": true
}
```

{% endtab %}

{% tab title="Python" %}
**Code:**

```python
# Retrieve all devices for the connected_account_id.
connected_devices = seam.devices.list(
  connected_account_id="11111111-1111-1111-1111-222222222222"
)
```

**Output:**

```
[
  Device(
    connected_account_id='11111111-1111-1111-1111-222222222222',
    device_id='11111111-1111-1111-1111-444444444444',
    display_name='Front Door Lock',
    is_managed=True,
    ...
  ),
  ...
]
```

{% endtab %}

{% tab title="Ruby" %}
**Code:**

```ruby
# Retrieve all devices for the connected_account_id.
connected_devices = seam.devices.list(
  connected_account_id: "11111111-1111-1111-1111-222222222222"
)
```

**Output:**

```json
[
  <
    Seam::Device:0x00438
      connected_account_id="11111111-1111-1111-1111-222222222222"
      device_id="11111111-1111-1111-1111-444444444444"
      display_name='Front Door Lock'
      is_managed=true
      ...
  >,
  ...
]
```

{% endtab %}

{% tab title="PHP" %}
**Code:**

```php
// Retrieve all devices for the connected_account_id.
$connected_devices = $seam->devices->list(
  connected_account_id: "11111111-1111-1111-1111-222222222222"
);
```

**Output:**

```json
[
  {
    "connected_account_id": "11111111-1111-1111-1111-222222222222",
    "device_id": "11111111-1111-1111-1111-444444444444",
    "display_name": "Front Door Lock",
    "is_managed": true,
    ...
  },
  ...
]
```

{% endtab %}

{% tab title="C#" %}
**Code:**

```csharp
// Retrieve all devices for the connectedAccountId.
var connectedDevices = seam.Devices.List(
  connectedAccountId: "11111111-1111-1111-1111-222222222222"
);
```

**Output:**

```json
{
  "connected_account_id": "11111111-1111-1111-1111-222222222222",
  "device_id": "11111111-1111-1111-1111-444444444444",
  "display_name": "Front Door Lock",
  "is_managed": true,
  ...
}
...
```

{% endtab %}
{% endtabs %}

***

## Retrieve a Connected Access Control System

Use this `connected_account_id` in a [List ACS Systems](https://docs.seam.co/latest/api/acs/systems/list) command to retrieve the ACS that your user has just connected to Seam.

{% hint style="info" %}
If you set `wait_for_device_creation` to `false` when [creating the Connect Webview](https://docs.seam.co/latest/core-concepts/connect-webviews/pages/z175ORX3nDmSL90MmIaG#id-1.-create-a-connect-webview), you should wait for the [`connected_account.completed_first_sync` event](https://docs.seam.co/latest/api/events/) before retrieving the user's ACS. This event indicates that Seam has finished the first sync of the connected account and the `acs_system` is now available.
{% endhint %}

{% tabs %}
{% tab title="JavaScript" %}
**Code:**

<pre class="language-javascript"><code class="lang-javascript"><strong>// Retrieve all acs_systems for the connected_account_id.
</strong>const connectedAcsSystems = await seam.acs.systems.list({
  connected_account_id: "11111111-1111-1111-2222-111111111111"
});
</code></pre>

**Output:**

```json
[
  {
    connected_account_ids: [
      '11111111-1111-1111-2222-111111111111'
    ],
    acs_system_id: '11111111-1111-1111-1111-111111111111',
    name: 'My ACS',
    ...
  },
  ...
]
```

{% endtab %}

{% tab title="cURL" %}
**Code:**

```bash
# Retrieve all acs_systems for the connected_account_id.
connected_acs_systems=$(
  # Use GET or POST.
  curl -X 'GET' \
    'https://connect.getseam.com/acs/systems/list' \
    -H 'accept: application/json' \
    -H "Authorization: Bearer ${SEAM_API_KEY}" \
    -H 'Content-Type: application/json' \
    -d '{
    "connected_account_id": "11111111-1111-1111-2222-111111111111"
  }')
```

**Output:**

```json
{
  "acs_systems": [
    {
      "connected_account_ids": [
        "11111111-1111-1111-2222-111111111111"
      ],
      "acs_system_id": "11111111-1111-1111-1111-111111111111",
      "name": "My ACS",
      ...
    },
    ...
  ],
  "ok": true
}
```

{% endtab %}

{% tab title="Python" %}
**Code:**

```python
# Retrieve all acs_systems for the connected_account_id.
connected_acs_systems = seam.acs.list(
  connected_account_id="11111111-1111-1111-2222-111111111111"
)
```

**Output:**

```
[
  AcsSystem(
    connected_account_ids=[
      '11111111-1111-1111-2222-111111111111'
    ],
    acs_system_id='11111111-1111-1111-1111-111111111111',
    name='My ACS',
    ...
  ),
  ...
]
```

{% endtab %}

{% tab title="Ruby" %}
**Code:**

```ruby
# Coming soon!
```

**Output:**

```
# Coming soon!
```

{% endtab %}

{% tab title="PHP" %}
**Code:**

```php
// Retrieve all acs_systems for the connected_account_id.
$connected_acs_systems = $seam->acs->systems->list(
  connected_account_id: "11111111-1111-1111-2222-111111111111"
);
```

**Output:**

```json
[
  {
    "connected_account_ids": [
      "11111111-1111-1111-2222-111111111111"
    ],
    "acs_system_id": "11111111-1111-1111-1111-111111111111",
    "name": "My ACS",
    ...
  },
  ...
]
```

{% endtab %}

{% tab title="C#" %}
**Code:**

```csharp
// Retrieve all acs_systems for the connectedAccountId.
var connectedAcsSystems = seam.Acs.Systems.List(
  connectedAccountId: "11111111-1111-1111-2222-111111111111"
);
```

**Output:**

```json
{
  "connected_account_ids": [
    "11111111-1111-1111-2222-111111111111"
  ],
  "acs_system_id": "11111111-1111-1111-1111-111111111111",
  "name": "My ACS",
  ...
}
...
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.seam.co/latest/core-concepts/connect-webviews/retrieving-devices-or-access-control-systems-connected-through-a-connect-webview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
