Get Label

Retrieve details of a specific WhatsApp label.

GET
https://api.wawp.net/v2/labels/{id}?access_token=123456789&id=1&instance_id=123456789

Authentication Required

Login to swap the placeholders with your real Instance ID and Access Token.

Log In
Test /v2/labels/{id} endpoint
GET
GET

No query parameters required

This endpoint doesn't expect data in the URL.

Precise Discovery: Fetching a Specific Label

While fetching all labels is useful for initializing a broad dashboard, the Get Label by ID endpoint is designed for high-precision synchronization and real-time state verification. it allows you to retrieve the name, color index, and hex code of a single, specific label using its unique identifier.


🏗️ Core Concept: High-Precision Verification

This endpoint acts as a Single Source of Truth (SSoT) for a specific piece of your organizational taxonomy. It is primarily used when your system already knows a Label ID (perhaps from a webhook event or a database record) and needs to verify its current properties on the WhatsApp Business account without fetching the entire account directory.

Key Operational Advantages:

  1. Low Latency Discovery: Fetching a single record is significantly faster and consumes less bandwidth than fetching the entire list of 20 labels, making it ideal for event-driven microservices.
  2. State Integrity: Confirms if a label still exists before your system attempts to apply it to a chat, preventing high-volume API errors during automated tagging cycles.
  3. Visual Hydration: Provides the exact visual metadata (Color Index and Hex) needed to render a specific tag in a contact's profile or a message notification.

🚀 Strategic Operational Use Case

The "Hydration-on-Event" Strategy

When a new activity occurs (e.g., a label.chat.added webhook arrives), Meta only provides the Label ID. For your frontend system to display a meaningful "Sales" or "VIP" badge, it must "hydrate" that ID with its display name and color. This endpoint is the primary bridge for that hydration process.

Intelligent Resource Allocation

In high-volume scenarios, you can use this endpoint to check the "Urgency Index" of a label before prioritizing a message. For example, if the color index returned is 0 (Red), your system can immediately route the inquiry to a senior supervisor.


🛡️ Security & Scalable Access Control

Access to individual label metadata is protected by the same security layer as your core message history.

  • Instance Isolation: You can only fetch labels belonging to the specific instance_id provided in the request. Attempting to fetch a Label ID from another instance will return a 404 Not Found, tips: [ { type: 'info', title: 'Lookup', content: 'Retrieves the numeric ID for a given label ID string.' }, { type: 'info', title: 'Format', content: 'Useful when mapping between GUIDs and internal IDs.' } ], recommendations: [ "Cache this mapping to avoid redundant calls.", "Use this to validate external IDs before processing." ]

ensuring data privacy between different WhatsApp Business accounts.

  • Token-Based Scoping: Your API access token must have the appropriate permissions to view account metadata. This ensures that even if a Label ID is leaked, it cannot be queried without proper authorization.

⚡ Performance Engineering: The Hybrid Caching Model

Fetching a label ID is lightweight, but repeating it for every message in a busy thread is inefficient. We recommend a "Demand-Driven Cache":

  1. Check Local Store: Always look for the Label ID in your internal memory or Redis first.
  2. Just-In-Time Fetch: If the ID is missing (potentially because it was recently created), call this endpoint to fetch and store the details.
  3. Proactive Refresh: Update your local record only when a label.update webhook for that specific ID is received. This minimizes API overhead while maintaining 100% accuracy.

⚠️ Important Behaviors & Edge Cases

  • ID Persistence: A Label ID is a persistent reference. However, if a label is deleted and later recreated with the exact same name, it will receive a new unique ID. Your systems should never hardcode ID strings; they should treat them as dynamic variables fetched from the account directory.
  • Color Index Stability: While the colorHex might shift slightly across different device themes or Meta updates, the color index (0-19) is immutable. Use the index for your internal logic and the hex only for your UI rendering.

🔍 Debugging & Troubleshooting

Handling the 404 "Ghost" State

If this endpoint returns a 404 for a previously known ID, it indicates that the label was deleted—either via the API or manually by an agent in the WhatsApp Business app. Your system should handle this by gracefully removing the ID from its internal store and updating any active UI components to a neutral "Uncategorized" state.


🎯 Best Practices

  1. Graceful Fallbacks: If a label fetch fails, default to a neutral grey badge in your UI to avoid breaking the layout.
  2. Index-Centric Themes: Build your custom dashboard themes around the 20 standard indices to ensure a "native" feel for agents familiar with the WhatsApp mobile experience.
  3. Store Mapping Locally: Save the returned metadata alongside the ID in your system to avoid redundant fetches during high-traffic periods.

Request Parameters

Configure the parameters required to interact with this endpoint. All query and body arguments are listed below with their details.

URL Parameters

Passed in the URL query string
string

Your unique WhatsApp Instance ID

Example:
string

Your API Access Token

Example:
string

The unique ID of the label

Example:

Request Samples

Use these ready-to-go code snippets to integrate our API into your project quickly and efficiently. Choose your preferred language and library.

1const baseUrl = "https://api.wawp.net";
2const endpoint = "/v2/labels/1";
3const params = new URLSearchParams({
4 "instance_id": "123456789",
5 "access_token": "123456789"
6}).toString();
7
8
9fetch(`${baseUrl}${endpoint}${params ? '?' + params : ''}`, {
10 method: "GET",
11 headers: { "Content-Type": "application/json" },
12
13})
14 .then(async (response) => {
15 if (response.ok) {
16 const data = await response.json();
17 console.log("Success:", data);
18 return data;
19 }
20
21 // Error Handling
22 if (response.status === 400) {
23 console.error("Error 400: Bad Request - Missing Required Parameter(s)");
24 }
25 if (response.status === 400) {
26 console.error("Error 400: Bad Request (XML Format)");
27 }
28 if (response.status === 400) {
29 console.error("Error 400: Bad Request (Plain Text)");
30 }
31 if (response.status === 401) {
32 console.error("Error 401: Unauthorized - Invalid or Missing Access Token");
33 }
34 if (response.status === 401) {
35 console.error("Error 401: Unauthorized (XML Format)");
36 }
37 if (response.status === 404) {
38 console.error("Error 404: Not Found - Session Does Not Exist");
39 }
40 if (response.status === 404) {
41 console.error("Error 404: Not Found (XML Format)");
42 }
43 if (response.status === 500) {
44 console.error("Error 500: Internal Server Error - Unexpected Failure");
45 }
46 if (response.status === 500) {
47 console.error("Error 500: Internal Server Error (HTML)");
48 }
49 if (response.status === 502) {
50 console.error("Error 502: Bad Gateway - Connection Failed to Upstream");
51 }
52 if (response.status === 502) {
53 console.error("Error 502: Bad Gateway (XML Format)");
54 }
55
56 const errorText = await response.text();
57 console.error(`Error ${response.status}: ${errorText}`);
58 })
59 .catch((error) => console.error("Network Error:", error));
Interactive Samples
Ln 59, Col 1javascript

Expected Responses

Explore all possible responses and outcomes from the server. We have documented each status code with data examples to make success and error handling easier.

Label info retrieved
Type:
Scenario:
application/json
string *
string *
number *
string *

Example

{
"id": "1",
"name": "New Customer",
"color": 0,
"colorHex": "#ff9485"
}
Bad Request - Missing Required Parameter(s)
Unauthorized - Invalid or Missing Access Token
Not Found - Session Does Not Exist
Internal Server Error - Unexpected Failure
Bad Gateway - Connection Failed to Upstream
Previous TopicGet All Labels
Next TopicCreate Label

Command Palette

Search for a command to run...