Contacts: Activity
Get Stats
Totals for the whole account in one call: contacts, contacts per status, members per list and contacts per tag.
https://g.sendcorex.com/v1/contactscommand: get_statsNeeds the contact:read scope on your API key.
These are counters kept up to date on every change, so this is cheap to call when a dashboard opens.
Arguments
This endpoint takes no arguments.
Quick start
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1/contacts',
{
commands: [
{
command: "get_stats"
}
]
},
{ headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);
const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);Response
{
"type": "SUCCESS",
"results": [
{
"command": "get_stats",
"id": "0",
"type": "SUCCESS",
"took_ms": 14,
"data": {
"total": 2040,
"status": {
"subscribed": 1951,
"unsubscribed": 61,
"bounced": 22,
"complained": 3,
"blocked": 3
},
"lists": {
"customers": {
"total": 1834,
"ok": 1790,
"opened": 912,
"clicked": 233
},
"newsletter": {
"total": 640,
"ok": 602,
"opened": 288,
"clicked": 41
}
},
"tags": {
"customer": 1834,
"vip": 120,
"black-friday": 512
}
}
}
]
}Response fields
totalContacts in the account.
statusContacts per global status.
lists.<id>totalmembers,oksendable members, and members whoopenedorclicked.tagsContacts per tag.
Errors
HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.
- 401
INVALID_API_KEYThe API key does not exist, was revoked or was disabled in the dashboard.
- 429
RATE_LIMITEDMore than 15 requests/s or 15 in flight for the same IP + API key. Wait the number of seconds in Retry-After.
- CMD
MISSING_SCOPEThe API key does not have the scope this command needs. The other commands in the request still run.
- CMD
INTERNALServer error. The detail is only written to the server log.