連絡先:カスタム項目

項目の定義

カスタム項目を作成するか、名前や選択肢を変更します。各項目は個別にインデックスされるため、すぐに絞り込みや並べ替えに使えます。

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

API keyにcontact:createスコープが必要です。

同じkeyとtypeで再度呼び出すと、名前と選択肢が更新されます。型は変更できず、試みるとTYPE_LOCKEDで失敗します。変更するには項目を削除して作り直してください。

引数

  • keystring必須

    a-z、0-9、_。英字で始め、40文字まで。

    例: "plan"

  • typestring必須

    text、number、date、bool、enum、multi_enum。

    例: "enum"

  • namestring任意

    表示名。デフォルトはキー。

    例: "Plan"

  • optionsstring[]任意

    enumとmulti_enumでは必須:許可される値。

    例: ["free", "pro", "business"]

クイックスタート

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);

レスポンス

{
  "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"
      }
    }
  ]
}

レスポンスの項目

  • (field)

    保存された項目:key、name、type、options、created_at、updated_at。

型

  • text

    最大2,000文字。等しい(大文字小文字とアクセントを無視)、contains、existsで絞り込み。

  • number

    整数または小数(負の数を含む)。"1234,5"は1234.5として読み取ります。範囲指定と並べ替えに対応。

  • date

    YYYY-MM-DDまたはISO。範囲指定と並べ替えに対応。

  • bool

    trueまたはfalse。"yes"、"sim"、"1"はtrueとして読み取ります。

  • enum

    optionsのいずれか1つ。"PRO"は"pro"として保存されます。選択肢にない値ではその要素が失敗します。

  • multi_enum

    任意の数のoptions。リストまたは"tech, golf"の形で。並べ替えには使えません。

すべての項目を一度に設定

リクエストボディ

{
  "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"
      }
    }
  ]
}

1アカウントの項目は最大100件。超えるとdefine_fieldはLIMIT_REACHEDで失敗します。

エラー

HTTPレベルのエラーはtype、code、messageを返します。CMDと表示されたエラーは、HTTP 200でコマンドの結果内に返ります。

  • 401INVALID_API_KEY

    API keyが存在しないか、取り消されたか、ダッシュボードで無効化されています。

  • 429RATE_LIMITED

    同じIP + API keyで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。

  • CMDMISSING_SCOPE

    API keyにこのコマンドに必要なスコープがありません。リクエスト内のほかのコマンドは実行されます。

  • CMDINVALID_ARGS

    必須の引数がないか不正です:メールアドレス、項目の値、enumの選択肢、whereのキー、リストのid…

  • CMDTYPE_LOCKED

    define_fieldが既存の項目のタイプを変更しようとしました。削除してから作り直してください。

  • CMDLIMIT_REACHED

    アカウントにはすでにカスタム項目が100件あります。

  • CMDINTERNAL

    サーバーエラー。詳細はサーバーのログにのみ記録されます。