Kontak: aktivitas

Ambil statistik

Total seluruh akun dalam satu panggilan: kontak, kontak per status, anggota per list, dan kontak per tag.

POSThttps://g.sendcorex.com/v1/contactscommand: get_stats
i

Membutuhkan scope contact:read pada API key Anda.

i

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

  • total

    Kontak di akun.

  • status

    Kontak per status global.

  • lists.<id>

    total anggota, ok anggota yang dapat dikirimi, dan anggota yang opened atau clicked.

  • tags

    Kontak per tag.

Error

Error di level HTTP mengembalikan type, code, dan message. Error yang ditandai CMD dikembalikan di dalam hasil perintah, dengan HTTP 200.

  • 401INVALID_API_KEY

    API key tidak ada, sudah dicabut, atau dinonaktifkan di dashboard.

  • 429RATE_LIMITED

    Lebih dari 15 request/detik atau 15 bersamaan untuk IP + API key yang sama. Tunggu sesuai jumlah detik di Retry-After.

  • CMDMISSING_SCOPE

    API key tidak memiliki scope yang dibutuhkan perintah ini. Perintah lain dalam request tetap berjalan.

  • CMDINTERNAL

    Error server. Detailnya hanya ditulis ke log server.