# Whatsapp API send message GO (Golang)

Whapi.Cloud provides a gateway to interact with customers through WhatsApp. This tutorial will help you learn how to send messages through the WhatsApp API using the Go Programming Language.&#x20;

### Getting Started

After [registering](https://panel.whapi.cloud/register) on our platform, go to the channel page, which will be immediately available to you.

You will now need to link any number to the channel. To do this, use the QR code that is displayed inside the channel.

Open your WhatsApp mobile app, navigate to **Settings** -> **Linked devices** -> **Link a device** -> **Scan QR code**

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2Fpf5TOcIsKhmMv9fcG5ZX%2F00000.png?alt=media&#x26;token=e82d421c-c25e-4858-a18d-e3f8c72c69ab" alt=""><figcaption></figcaption></figure>

Our service enables you to interact with the API without the need for an uninterrupted phone connection. Operate WhatsApp on up to four paired devices and one mobile device concurrently.

Now save the generated API-Key token on channel page:

<figure><img src="https://2417185145-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhsdgGmVCG31mEaHyRvxC%2Fuploads%2F05KGZwXRsJPZ4roIjwHs%2Fchannel-tips.png?alt=media&#x26;token=eba3a04d-0a26-49cc-84a4-fc56260eed1f" alt=""><figcaption><p>Grab your token</p></figcaption></figure>

### How to Send WhatsApp API Message using GO, Example

To send a text message, you need to make a request to:&#x20;

`POST https://gate.whapi.cloud/messages/text`

{% embed url="<https://whapi.readme.io/reference/sendmessagetext>" %}
Test requests and sample code snippets
{% endembed %}

Here's how you can dispatch a WhatsApp message using Golang:

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://gate.whapi.cloud/messages/text"

	payload := strings.NewReader("{\"typing_time\":10,\"to\":\"14409416972\",\"body\":\"Hello!\"}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("accept", "application/json")
	req.Header.Add("content-type", "application/json")
	req.Header.Add("authorization", "Bearer iNdBBvVS4sbBmwcPwcX1pzBDChVo2bcs")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

The parameters are as follows:

* `to`: The recipient’s WhatsApp number in international format (e.g., 14409416972) or [chatID](https://support.whapi.cloud/help-desk/faq/chat-id.-what-is-it-and-how-to-get-it) for contact or group (e.g <14409416972@s.whatsapp.net> or <12560234567890@g.us>).
* `body`: The content of the message.
* `typing_time`: The time in seconds when it is displayed that you are typing a message. Not a required parameter.

If you have any inquiries or would like to share your experiences with us, please feel free to reach out.

[<mark style="background-color:yellow;">**Get Started Free**</mark>](https://panel.whapi.cloud/register)

***

### Send Media Message

Additional endpoint for easy send media-file as message. Use request body as file and inpath parameters for send parameters. Media message can be one of the following types:

{% embed url="<https://whapi.readme.io/reference/sendmediamessage>" %}

### Send Image <a href="#send-image" id="send-image"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessageimage>" %}

### Send Document <a href="#send-document" id="send-document"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessagedocument>" %}

### Send Audio <a href="#send-audio" id="send-audio"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessageaudio>" %}

### Send Voice <a href="#send-voice" id="send-voice"></a>

You can Send a ppt audio recording to the phone number or group, But WhatsApp is sensitive to this extension, you need to be in OGG format and the **codecs** should be the **opus**. Our API has an automatic video and audio converter for the necessary codecs compatible with WhatsApp. For more information, you can check out this [article](https://support.whapi.cloud/help-desk/sending/overview-of-other-methods-for-sending/send-voice-message).

{% embed url="<https://whapi.readme.io/reference/sendmessagevoice>" %}

### Send Video <a href="#send-video" id="send-video"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessagevideo>" %}

### Send GIF

{% embed url="<https://whapi.readme.io/reference/sendmessagegif>" %}

### Send Contact <a href="#send-contact" id="send-contact"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessagecontact>" %}

### Send Contact List

{% embed url="<https://whapi.readme.io/reference/sendmessagecontactlist>" %}

### Send Location <a href="#send-location" id="send-location"></a>

{% embed url="<https://whapi.readme.io/reference/sendmessagelocation>" %}

### Send Sticker

{% embed url="<https://whapi.readme.io/reference/sendmessagesticker>" %}
