Contacts: Contacts

Delete Contacts

Permanently delete up to 500 contacts per command, with their list memberships, tags, fields and event history.

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

Needs the contact:delete scope on your API key.

!

This cannot be undone. To stop emailing someone but keep their history, use Set Status with unsubscribed or blocked instead.

Arguments

  • emailsstring[]optional

    Up to 500 emails. Case and surrounding spaces are ignored, and repeated emails count once.

  • emailstringoptional

    A single email. Use this or emails.

Quick start

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "delete_contacts",
        args: {
          emails: [
            "bob@gmail.com",
            "old@acme.com"
          ]
        }
      }
    ]
  },
  { 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": "delete_contacts",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "items": [
          {
            "id": "bob@gmail.com",
            "ok": true,
            "data": {
              "deleted": true
            }
          },
          {
            "id": "old@acme.com",
            "ok": true,
            "data": {
              "deleted": true
            }
          }
        ],
        "ok_count": 2,
        "failed_count": 0
      }
    }
  ]
}

Response fields

  • items[].data.deleted

    true when the contact was deleted.

  • items[].code

    NOT_FOUND when the email was not a contact, or was already deleted.

  • ok_count / failed_count

    How many contacts were deleted and how many failed.

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.

  • CMDINVALID_ARGS

    A required argument is missing or invalid: email, field value, enum option, where key, list id…

  • CMDNOT_FOUND

    The contact, list, field or segment does not exist.

  • CMDINTERNAL

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