Contacts: Custom fields

Define Field

Create a custom field, or rename it and change its options. Every field is indexed on its own, so you can filter and sort by it right away.

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

Needs the contact:create scope on your API key.

i

Calling it again with the same key and type updates the name and options. The type never changes: trying fails with TYPE_LOCKED. To change it, delete the field and create it again.

Arguments

  • keystringrequired

    a-z, 0-9 and _, starting with a letter, up to 40 characters.

    e.g. "plan"

  • typestringrequired

    text, number, date, bool, enum or multi_enum.

    e.g. "enum"

  • namestringoptional

    Display name. Defaults to the key.

    e.g. "Plan"

  • optionsstring[]optional

    Required for enum and multi_enum: the allowed values.

    e.g. ["free", "pro", "business"]

Quick start

import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/contacts',
  {
    commands: [
      {
        command: "define_field",
        args: {
          key: "plan",
          name: "Plan",
          type: "enum",
          options: [
            "free",
            "pro",
            "business"
          ]
        }
      }
    ]
  },
  { 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": "define_field",
      "id": "0",
      "type": "SUCCESS",
      "took_ms": 14,
      "data": {
        "key": "plan",
        "name": "Plan",
        "type": "enum",
        "options": [
          "free",
          "pro",
          "business"
        ],
        "created_at": "2026-10-01T10:00:00.000Z",
        "updated_at": "2026-10-01T10:00:00.000Z"
      }
    }
  ]
}

Response fields

  • (field)

    The field as stored: key, name, type, options, created_at, updated_at.

Types

  • text

    Up to 2,000 characters. Filter by equal (ignoring case and accents), contains or exists.

  • number

    Integers or decimals, negatives included. "1234,5" is read as 1234.5. Ranges and sorting.

  • date

    YYYY-MM-DD or ISO. Ranges and sorting.

  • bool

    true or false. "yes", "sim" and "1" are read as true.

  • enum

    One of options. "PRO" is stored as "pro". A value outside the options fails the item.

  • multi_enum

    Any number of options, as a list or as "tech, golf". Cannot be used to sort.

Set up all your fields at once

Request body

{
  "commands": [
    {
      "command": "define_field",
      "args": {
        "key": "plan",
        "name": "Plan",
        "type": "enum",
        "options": [
          "free",
          "pro",
          "business"
        ]
      }
    },
    {
      "command": "define_field",
      "args": {
        "key": "age",
        "name": "Age",
        "type": "number"
      }
    },
    {
      "command": "define_field",
      "args": {
        "key": "city",
        "name": "City",
        "type": "text"
      }
    },
    {
      "command": "define_field",
      "args": {
        "key": "birthday",
        "name": "Birthday",
        "type": "date"
      }
    },
    {
      "command": "define_field",
      "args": {
        "key": "interests",
        "name": "Interests",
        "type": "multi_enum",
        "options": [
          "golf",
          "tech",
          "travel"
        ]
      }
    },
    {
      "command": "define_field",
      "args": {
        "key": "vip",
        "name": "VIP",
        "type": "bool"
      }
    }
  ]
}
i

An account can have up to 100 fields. Past that, define_field fails with LIMIT_REACHED.

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…

  • CMDTYPE_LOCKED

    define_field tried to change the type of an existing field. Delete it and create it again.

  • CMDLIMIT_REACHED

    The account already has 100 custom fields.

  • CMDINTERNAL

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