Contacts: Activity

Get Stats

Totals for the whole account in one call: contacts, contacts per status, members per list and contacts per tag.

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

Needs the contact:read scope on your API key.

i

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

  • total

    Contacts in the account.

  • status

    Contacts per global status.

  • lists.<id>

    total members, ok sendable members, and members who opened or clicked.

  • tags

    Contacts per tag.

Errors

HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.

  • 401INVALID_API_KEY

    The API key does not exist, was revoked or was disabled in the dashboard.

  • 429RATE_LIMITED

    More than 15 requests/s or 15 in flight for the same IP + API key. Wait the number of seconds in Retry-After.

  • CMDMISSING_SCOPE

    The API key does not have the scope this command needs. The other commands in the request still run.

  • CMDINTERNAL

    Server error. The detail is only written to the server log.