連絡先:カスタム項目
項目の定義
カスタム項目を作成するか、名前や選択肢を変更します。各項目は個別にインデックスされるため、すぐに絞り込みや並べ替えに使えます。
https://g.sendcorex.com/v1/contactscommand: define_fieldAPI 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として読み取ります。範囲指定と並べ替えに対応。dateYYYY-MM-DDまたはISO。範囲指定と並べ替えに対応。booltrueまたはfalse。"yes"、"sim"、"1"はtrueとして読み取ります。enumoptionsのいずれか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でコマンドの結果内に返ります。
- 401
INVALID_API_KEYAPI keyが存在しないか、取り消されたか、ダッシュボードで無効化されています。
- 429
RATE_LIMITED同じIP + API keyで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。
- CMD
MISSING_SCOPEAPI keyにこのコマンドに必要なスコープがありません。リクエスト内のほかのコマンドは実行されます。
- CMD
INVALID_ARGS必須の引数がないか不正です:メールアドレス、項目の値、enumの選択肢、whereのキー、リストのid…
- CMD
TYPE_LOCKEDdefine_fieldが既存の項目のタイプを変更しようとしました。削除してから作り直してください。
- CMD
LIMIT_REACHEDアカウントにはすでにカスタム項目が100件あります。
- CMD
INTERNALサーバーエラー。詳細はサーバーのログにのみ記録されます。