> ## 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 Labels

> Retrieve all labels from your workspaces

## List Labels

Retrieves all labels from workspaces that the authenticated user has access to.

### Request

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

### Response

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

<ResponseExample>
  ```json theme={null}
  {
    "data": [
      {
        "id": 1,
        "name": "Product Launch",
        "color": "#ff0000",
         "workspace": {
            "id": 12,
            "name": "abdulmejidshemsuawel",
            "slug": "abdulmejidshemsuawel",
            "type": "PERSONAL",
            "logo": null,
            "timezone": "Africa/Addis_Ababa",
            "language": "en"
        }
      },
      {
        "id": 2,
        "name": "Winter",
        "color": "#0000ff",
         "workspace": {
            "id": 12,
            "name": "abdulmejidshemsuawel",
            "slug": "abdulmejidshemsuawel",
            "type": "PERSONAL",
            "logo": null,
            "timezone": "Africa/Addis_Ababa",
            "language": "en"
        }
      }
    ]
  }
  ```
</ResponseExample>

### Code Examples

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

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

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

  getLabels();
  ```

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

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://postsyncer.com/api/v1/labels');
  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) {
      $labels = json_decode($response, true);
      echo "Found " . count($labels['data']) . " labels";
  } else {
      echo "Error: " . $response;
  }
  ?>
  ```

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

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

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

  if response.status_code == 200:
      labels = response.json()
      print(f"Found {len(labels['data'])} labels")
      for label in labels['data']:
          print(f"Label {label['id']}: {label['name']} ({label['color']})")
  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 'labels' permission
</ResponseField>
