Kontak: aktivitas
Ambil statistik
Total seluruh akun dalam satu panggilan: kontak, kontak per status, anggota per list, dan kontak per tag.
https://g.sendcorex.com/v1/contactscommand: get_statsMembutuhkan scope contact:read pada API key Anda.
Ini adalah penghitung yang diperbarui setiap ada perubahan, jadi murah untuk dipanggil saat dashboard dibuka.
Argumen
Endpoint ini tidak menerima argumen.
Mulai cepat
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);Respons
{
"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
}
}
}
]
}Field respons
totalKontak di akun.
statusKontak per status global.
lists.<id>totalanggota,okanggota yang dapat dikirimi, dan anggota yangopenedatauclicked.tagsKontak per tag.
Error
Error di level HTTP mengembalikan type, code, dan message. Error yang ditandai CMD dikembalikan di dalam hasil perintah, dengan HTTP 200.
- 401
INVALID_API_KEYAPI key tidak ada, sudah dicabut, atau dinonaktifkan di dashboard.
- 429
RATE_LIMITEDLebih dari 15 request/detik atau 15 bersamaan untuk IP + API key yang sama. Tunggu sesuai jumlah detik di Retry-After.
- CMD
MISSING_SCOPEAPI key tidak memiliki scope yang dibutuhkan perintah ini. Perintah lain dalam request tetap berjalan.
- CMD
INTERNALError server. Detailnya hanya ditulis ke log server.