Set contact status
Update a contact’s messaging status.
curl --request POST \
--url https://api.heymarket.com/v1/contact/set_status \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": 10000,
"phone": "12345678900",
"status": "active",
"inbox_ids": [
2,
5
],
"user_id": 4242
}
'import requests
url = "https://api.heymarket.com/v1/contact/set_status"
payload = {
"id": 10000,
"phone": "12345678900",
"status": "active",
"inbox_ids": [2, 5],
"user_id": 4242
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 10000,
phone: '12345678900',
status: 'active',
inbox_ids: [2, 5],
user_id: 4242
})
};
fetch('https://api.heymarket.com/v1/contact/set_status', 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://api.heymarket.com/v1/contact/set_status",
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([
'id' => 10000,
'phone' => '12345678900',
'status' => 'active',
'inbox_ids' => [
2,
5
],
'user_id' => 4242
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.heymarket.com/v1/contact/set_status"
payload := strings.NewReader("{\n \"id\": 10000,\n \"phone\": \"12345678900\",\n \"status\": \"active\",\n \"inbox_ids\": [\n 2,\n 5\n ],\n \"user_id\": 4242\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.heymarket.com/v1/contact/set_status")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": 10000,\n \"phone\": \"12345678900\",\n \"status\": \"active\",\n \"inbox_ids\": [\n 2,\n 5\n ],\n \"user_id\": 4242\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.heymarket.com/v1/contact/set_status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 10000,\n \"phone\": \"12345678900\",\n \"status\": \"active\",\n \"inbox_ids\": [\n 2,\n 5\n ],\n \"user_id\": 4242\n}"
response = http.request(request)
puts response.read_bodysuccesserrorUnauthorized{}too many requestserrorAuthorizations
Recommended authentication for new integrations. Generate a short-lived JWT from your API Secret ID and API Secret Key, then pass the signed JWT as a bearer token in the Authorization header.
API Secret credentials are available in the Heymarket app under Settings > Integrations > API. The Secret Key is shown only when it is generated, so copy and store it securely before closing the dialog.
Use the following JWT values:
{
"alg": "HS256",
"typ": "JWT"
}
{
"iss": "YOUR_API_SECRET_ID",
"iat": CURRENT_UNIX_TIMESTAMP
}
Replace CURRENT_UNIX_TIMESTAMP with the current Unix timestamp in seconds when generating the token.
Sign the JWT with HMAC-SHA256 using this signing secret:
YOUR_API_SECRET_ID||YOUR_API_SECRET_KEY
Send the signed JWT as a bearer token:
Authorization: Bearer YOUR_SIGNED_JWT
Tokens expire 5 minutes after the iat timestamp. Generate a new JWT per request, or cache it briefly for less than 5 minutes. Generate JWTs only from trusted server-side code; do not expose the API Secret Key in browser, mobile, or other client-side code.
Body
Heymarket ID of the contact and status to set
Optional inbox ids to scope a subscribed/active/unsubscribed status change to specific inboxes instead of team-wide. Applies only to teams on per-inbox opt-out mode (requires the inbox-level opt-out entitlement). Omitting this field keeps the existing global (team-wide) behavior, or pass user_id to cover that user's inboxes. Ignored for the blocked/unblocked statuses.
[2, 5]
Optional acting user, applied to subscribed/active/unsubscribed. On a team using per-inbox opt-out, supplying user_id WITHOUT inbox_ids scopes the change to the inboxes that user belongs to (skipping inboxes with no phone number). Supplied together with inbox_ids it does not change the scope, but every requested inbox must be one the user can access. On a team using global opt-out the change stays team-wide with user_id recorded as the actor. The user must be an active member of the authenticated team. For blocked/unblocked, user_id only sets who the conversation history shows as making the change; an omitted or non-member user_id is shown as Heymarket and is not rejected.
4242
Response
Status set. Returns the text body success, except when the change landed team-wide although the request tried to scope it: that answers JSON with applied_scope: team_wide and no inbox list, so a wider-than-requested scope is visible in the body. Two cases reach it — user_id supplied on a team whose mode keeps every change team-wide, and a subscribed/active request scoped with inbox_ids against a removable team-wide opt-out, which is revoked in full across every inbox on the team.
The response is of type string.
Was this page helpful?
curl --request POST \
--url https://api.heymarket.com/v1/contact/set_status \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": 10000,
"phone": "12345678900",
"status": "active",
"inbox_ids": [
2,
5
],
"user_id": 4242
}
'import requests
url = "https://api.heymarket.com/v1/contact/set_status"
payload = {
"id": 10000,
"phone": "12345678900",
"status": "active",
"inbox_ids": [2, 5],
"user_id": 4242
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: 10000,
phone: '12345678900',
status: 'active',
inbox_ids: [2, 5],
user_id: 4242
})
};
fetch('https://api.heymarket.com/v1/contact/set_status', 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://api.heymarket.com/v1/contact/set_status",
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([
'id' => 10000,
'phone' => '12345678900',
'status' => 'active',
'inbox_ids' => [
2,
5
],
'user_id' => 4242
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.heymarket.com/v1/contact/set_status"
payload := strings.NewReader("{\n \"id\": 10000,\n \"phone\": \"12345678900\",\n \"status\": \"active\",\n \"inbox_ids\": [\n 2,\n 5\n ],\n \"user_id\": 4242\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.heymarket.com/v1/contact/set_status")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": 10000,\n \"phone\": \"12345678900\",\n \"status\": \"active\",\n \"inbox_ids\": [\n 2,\n 5\n ],\n \"user_id\": 4242\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.heymarket.com/v1/contact/set_status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 10000,\n \"phone\": \"12345678900\",\n \"status\": \"active\",\n \"inbox_ids\": [\n 2,\n 5\n ],\n \"user_id\": 4242\n}"
response = http.request(request)
puts response.read_bodysuccesserrorUnauthorized{}too many requestserror