---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/ja/api-reference/contacts/fields/define-field

連絡先：カスタム項目

# 項目の定義

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

POST `https://g.sendcorex.com/v1/contacts` command: define_field

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

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

## 引数

- `key` string 必須
`a-z`、`0-9`、`_`。英字で始め、40文字まで。
例： `"plan"`
- `type` string 必須
`text`、`number`、`date`、`bool`、`enum`、`multi_enum`。
例： `"enum"`
- `name` string 任意
表示名。デフォルトはキー。
例： `"Plan"`
- `options` string[] 任意
`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でコマンドの結果内に返ります。

- 401`INVALID_API_KEY`
API keyが存在しないか、取り消されたか、ダッシュボードで無効化されています。
- 429`RATE_LIMITED`
同じIP + API keyで毎秒15リクエストまたは同時15件を超えました。Retry-Afterの秒数だけ待ってください。
- CMD`MISSING_SCOPE`
API keyにこのコマンドに必要なスコープがありません。リクエスト内のほかのコマンドは実行されます。
- CMD`INVALID_ARGS`
必須の引数がないか不正です：メールアドレス、項目の値、enumの選択肢、whereのキー、リストのid…
- CMD`TYPE_LOCKED`
define_fieldが既存の項目のタイプを変更しようとしました。削除してから作り直してください。
- CMD`LIMIT_REACHED`
アカウントにはすでにカスタム項目が100件あります。
- CMD`INTERNAL`
サーバーエラー。詳細はサーバーのログにのみ記録されます。
