Messages
Send an Instagram message
Send an Instagram customer-channel message.
POST
/
meta
/
v25.0
/
{INSTAGRAM_ACCOUNT_ID}
/
messages
Send an Instagram message
curl --request POST \
--url https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages \
--header 'Content-Type: application/json' \
--data '
{
"recipient.id": "<string>",
"message": {}
}
'import requests
url = "https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages"
payload = {
"recipient.id": "<string>",
"message": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'recipient.id': '<string>', message: {}})
};
fetch('https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'recipient.id' => '<string>',
'message' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages"
payload := strings.NewReader("{\n \"recipient.id\": \"<string>\",\n \"message\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages")
.header("Content-Type", "application/json")
.body("{\n \"recipient.id\": \"<string>\",\n \"message\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipient.id\": \"<string>\",\n \"message\": {}\n}"
response = http.request(request)
puts response.read_bodySend an Instagram message through one customer’s connected channel.
Use the HookMyApp channel ID (
ch_...) when you fetch the channel token. Use the connected Instagram account ID in the gateway path. Use the inbound sender.id as the outbound recipient.id.
Authentication
Use the returnedhmat_ channel token to send the message. Do not use an hmok_ API key for the send call.
Authorization: Bearer hmat_...
Path parameters
string
required
The connected Instagram account ID for the customer channel, from
INSTAGRAM_ACCOUNT_ID.Request body
string
required
The Instagram sender ID from the inbound webhook
sender.id.object
required
The Instagram message payload, such as text, media attachment, quick replies, cards, reactions, or sender actions.
Example
curl -X POST "https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages" \
-H "Authorization: Bearer hmat_..." \
-H "Content-Type: application/json" \
-d '{
"recipient": { "id": "17841400000000001" },
"message": { "text": "Hello from HookMyApp" }
}'
Successful response
{
"recipient_id": "17841400000000001",
"message_id": "m_0AbCdEfGhIjKlMnOpQrSt"
}
⌘I
Send an Instagram message
curl --request POST \
--url https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages \
--header 'Content-Type: application/json' \
--data '
{
"recipient.id": "<string>",
"message": {}
}
'import requests
url = "https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages"
payload = {
"recipient.id": "<string>",
"message": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'recipient.id': '<string>', message: {}})
};
fetch('https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'recipient.id' => '<string>',
'message' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages"
payload := strings.NewReader("{\n \"recipient.id\": \"<string>\",\n \"message\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages")
.header("Content-Type", "application/json")
.body("{\n \"recipient.id\": \"<string>\",\n \"message\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://gateway.hookmyapp.com/meta/v25.0/{INSTAGRAM_ACCOUNT_ID}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"recipient.id\": \"<string>\",\n \"message\": {}\n}"
response = http.request(request)
puts response.read_body