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

# Get Label

> Retrieve a specific label by ID

## Get Label

Retrieves detailed information about a specific label, including its name, color, and associated workspace.

### Request

<ParamField path="id" type="integer" required>
  The ID of the label to retrieve
</ParamField>

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

### Response

<ResponseField name="id" type="integer">
  Unique identifier for the label
</ResponseField>

<ResponseField name="name" type="string">
  The name of the label
</ResponseField>

<ResponseField name="color" type="string">
  The hex color code of the label
</ResponseField>

<ResponseField name="workspace" type="object">
  Information about the label's workspace
</ResponseField>

<ResponseField name="created_at" type="string">
  Creation timestamp in workspace timezone
</ResponseField>

<ResponseField name="updated_at" type="string">
  Last update timestamp in workspace timezone
</ResponseField>

<ResponseExample>
  ```json theme={null}
  { 
    "id": 16,
    "name": "Product Launch",
    "color": "#ff0000",
    "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/123" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```

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

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

  getLabel(123);
  ```

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

  $labelId = 123;

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

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

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

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

  if response.status_code == 200:
      label = response.json()
      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>

<ResponseField name="404" type="Not Found">
  Label not found or user does not have access to the label's workspace
</ResponseField>
