Contacts: Lists

Delete List

Delete a list. It disappears right away; its members are taken out of it in the background. The contacts themselves are kept.

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

Needs the contact:delete scope on your API key.

i

Only the membership is removed. The contacts, their tags, fields and other lists stay. To delete the people too, query them first and use Delete Contacts.

Arguments

  • list_idstringrequired

    The list to delete.

    e.g. "old-leads"

Quick start

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "delete_list",
        args: {
          list_id: "old-leads"
        }
      }
    ]
  },
  { 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_list",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "deleted": true,
        "purging": true
      }
    }
  ]
}

Response fields

  • deleted

    true. The list no longer shows in List Lists or Get List.

  • purging

    true while the members are being removed from the list in the background.

What happens in the background

Large lists are cleaned up in batches. Until it finishes, list_lists with include_deleting: true still shows the list with status: "deleting".

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.