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

# WhatsApp Number Checker and Contacts API in Go

> Check if a phone number has WhatsApp, list and save contacts, get profile pictures, and resolve LIDs from Golang with the Hypersender WhatsApp API.

## Overview

Look up information about WhatsApp contacts. Contact methods live under `client.WhatsApp.Contacts`. The examples assume `ctx` is a `context.Context`, such as `context.Background()`.

## Contacts

### Check if a Number Has WhatsApp

Use this as a WhatsApp number checker: find out whether a phone number has a WhatsApp account before you message it, and get its chat ID. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/check-contact-exists.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.WhatsApp.Contacts.CheckContactExists(ctx, "20123456789")
> if err != nil {
>     log.Fatal(err)
> }
>
> exists, _ := res["numberExists"].(bool)
> chatID, _ := res["chatId"].(string)
>
> fmt.Println(exists, chatID)
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | phone | string | yes | Phone number with country code, without `+` or spaces |

### Get All Contacts

List the contacts saved on the instance, with pagination and sorting. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-all-contacts.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.WhatsApp.Contacts.GetAllContacts(ctx, &hypersender.GetAllContactsOptions{
>     Limit:     100,
>     Offset:    0,
>     SortBy:    "name",
>     SortOrder: "asc",
> })
> if err != nil {
>     log.Fatal(err)
> }
>
> contacts, _ := res["data"].([]any)
>
> fmt.Println(len(contacts))
> ```

> [tab] Parameters
>
> All fields are optional. Pass `nil` to use the defaults.
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | opts.Limit | int | no | Number of contacts to return, 1-1000 (default: 100) |
> | opts.Offset | int | no | Number of contacts to skip (default: 0) |
> | opts.SortBy | string | no | `"id"` or `"name"` (default: `"name"`) |
> | opts.SortOrder | string | no | `"asc"` or `"desc"` (default: `"asc"`) |

### Get a Contact

Get a single contact by phone number or chat ID. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-contact.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.WhatsApp.Contacts.GetContact(ctx, "20123456789@c.us")
> if err != nil {
>     log.Fatal(err)
> }
>
> data, _ := res["data"].(map[string]any)
>
> fmt.Println(data["name"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatID | string | yes | Phone number (`123123123`) or chat ID (`123123@c.us` or `123123@lid`) |

### Get WhatsApp Profile Picture

Get the URL of a contact's WhatsApp profile picture. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-profile-picture.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.WhatsApp.Contacts.GetProfilePicture(ctx, "20123456789@c.us")
> if err != nil {
>     log.Fatal(err)
> }
>
> data, _ := res["data"].(map[string]any)
>
> fmt.Println(data["profilePictureURL"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatID | string | yes | Phone number (`123123123`) or chat ID (`123123@c.us` or `123123@lid`) |

### Create or Update a Contact

Save a contact on the instance, or update its name if it already exists. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/upsert-contact.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> _, err := client.WhatsApp.Contacts.UpsertContact(ctx, "20123456789@c.us", "John",
>     &hypersender.UpsertContactOptions{LastName: "Doe"})
> if err != nil {
>     log.Fatal(err)
> }
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chatID | string | yes | Phone number (`123123123`) or chat ID (`123123@c.us` or `123123@lid`) |
> | firstName | string | yes | The contact's first name |
> | opts.LastName | string | no | The contact's last name |

## LIDs

WhatsApp sometimes identifies contacts by a LID (linked identifier, e.g. `1111111@lid`) instead of their phone number. Use these methods to map between the two. [(learn more about LIDs)](https://docs.hypersender.com/v2/hypersender/overview/whatsapp/whatsapp-lid-issue.md)

### Get Phone Number by LID

Resolve a LID to the contact's phone-number chat ID. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-phone-number-by-lid.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> mapping, err := client.WhatsApp.Contacts.GetPhoneNumberByLID(ctx, "1111111@lid")
> if err != nil {
>     log.Fatal(err)
> }
>
> // map[lid:1111111@lid pn:3333333@c.us]
> fmt.Println(mapping["pn"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | lid | string | yes | The LID to resolve, e.g. `1111111@lid` or `1111111` |

### Get LID by Phone Number

Find the LID linked to a phone number. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-lid-by-phone-number.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> mapping, err := client.WhatsApp.Contacts.GetLIDByPhoneNumber(ctx, "3333333@c.us")
> if err != nil {
>     log.Fatal(err)
> }
>
> // map[lid:1111111@lid pn:3333333@c.us]
> fmt.Println(mapping["lid"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | phoneNumber | string | yes | The phone number to resolve, e.g. `3333333@c.us` or `3333333` |

### Get All Known LIDs

List the LID to phone number mappings the instance knows about. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-all-known-lids.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> mappings, err := client.WhatsApp.Contacts.GetAllKnownLIDs(ctx, &hypersender.GetAllKnownLIDsOptions{
>     Limit:  100,
>     Offset: 0,
> })
> if err != nil {
>     log.Fatal(err)
> }
>
> // []hypersender.Result{{"lid": "1111111@lid", "pn": "3333333@c.us"}, ...}
> fmt.Println(len(mappings))
> ```

> [tab] Parameters
>
> All fields are optional. Pass `nil` to use the defaults.
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | opts.Limit | int | no | Maximum number of mappings to return (default: 100) |
> | opts.Offset | int | no | Number of mappings to skip (default: 0) |

### Get LIDs Count

Get how many LID mappings the instance knows about. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-count-of-lids.md)

> [tab] Basic Usage
>
> ```go theme={null}
> client := hypersender.NewClient()
>
> res, err := client.WhatsApp.Contacts.GetLIDsCount(ctx)
> if err != nil {
>     log.Fatal(err)
> }
>
> fmt.Println(res["count"])
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.