> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postsyncer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List Accounts

> Retrieve all social media accounts from your workspaces

## List Accounts

Retrieves all social media accounts from workspaces that the authenticated user has access to.

### Request

<RequestExample>
  ```bash theme={null}
  curl -X GET "https://postsyncer.com/api/v1/accounts" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```
</RequestExample>

### Response

<ResponseField name="data" type="array">
  Array of account objects
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
    "data": [
      {
          "id": 136,
          "workspace_id": 12,
          "platform": "twitter",
          "username": "heyabdulmejid",
          "name": "Abdul",
          "avatar": "https://pbs.twimg.com/profile_images/1878383928995684352/3Xw5HTsk_400x400.jpg"
      },
      {
          "id": 245,
          "workspace_id": 12,
          "platform": "twitter",
          "username": "username1",
          "name": "Account Name",
          "avatar": "https://pbs.twimg.com/profile_images/188258dddddddd5070692626432/3oMtYxt5_normal.png"
      }
    ]
  }
  ```
</ResponseExample>

### Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://postsyncer.com/api/v1/accounts" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  const getAccounts = async () => {
    try {
      const response = await axios.get('https://postsyncer.com/api/v1/accounts', {
        headers: {
          'Authorization': 'Bearer YOUR_API_TOKEN'
        }
      });
      
      console.log('Accounts:', response.data);
      return response.data;
    } catch (error) {
      console.error('Error fetching accounts:', error.response?.data || error.message);
    }
  };

  getAccounts();
  ```

  ```php PHP theme={null}
  <?php

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://postsyncer.com/api/v1/accounts');
  curl_setopt($ch, CURLOPT_HTTPGET, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Authorization: Bearer YOUR_API_TOKEN'
  ]);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode === 200) {
      $accounts = json_decode($response, true);
      echo "Found " . count($accounts['data']) . " accounts";
  } else {
      echo "Error: " . $response;
  }
  ?>
  ```

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

  headers = {
      'Authorization': 'Bearer YOUR_API_TOKEN'
  }

  response = requests.get(
      'https://postsyncer.com/api/v1/accounts',
      headers=headers
  )

  if response.status_code == 200:
      accounts = response.json()
      print(f"Found {len(accounts['data'])} accounts")
      for account in accounts['data']:
          print(f"Account {account['id']}: {account['platform']} - {account['username']}")
          print(f"  Active: {account['is_active']}")
  else:
      print(f"Error: {response.status_code}")
      print(response.text)
  ```
</CodeGroup>

### Error Codes

<ResponseField name="401" type="Unauthorized">
  Missing or invalid API token
</ResponseField>

<ResponseField name="403" type="Forbidden">
  Token does not have 'accounts' permission
</ResponseField>
