> For the complete documentation index, see [llms.txt](https://docs.groobee.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groobee.ai/ja/developer-guide/api-guide/custom-data/v2.md). Agents can also search and read this documentation through its [MCP server](https://docs.groobee.ai/~gitbook/mcp).

# カスタムデータ v2.0.1

## **連携方式**

HTTPSプロトコルを使ったREST API

***

## **必須項目**

| 項目      | 説明               |
| ------- | ---------------- |
| API Key | 設定画面で発行したAPIキーの値 |

***

## **リクエストURL**

[https://api.groobee.io](https://api.groobee.io/)

***

## **共通事項**

### **リクエスト方法**

REST APIをリクエストするときは、ヘッダーの x-api-key にAPIキーを値として含めてください。

```
curl --location --request GET 'https://api.groobee.io/<エンドポイント>' \
--header 'x-api-key: <発行したAPIキーの値>'
```

* **APIキーの確認方法**
  * <https://app.groobee.io/> にアクセスしてアカウントでログイン
  * [設定 > サイト > サイト設定 > キー管理](https://app.groobee.io/setting/main)でキーを作成すると確認できます

### **レスポンス**

JSON形式で返します。形式は次のとおりです。

```
{
    "httpStatus": {
        "code": <HTTPステータスコード>,
        "reasonPhrase": <HTTPステータスの内容>
    },
    "processCode": <結果コード>,
    "processValue": <リクエストしたエンドポイントのレスポンス値>
}
```

### **processCode の値**

| コード値  | 説明                             |
| ----- | ------------------------------ |
| 0     | すべて成功                          |
| 1     | 一部成功                           |
| -1000 | 失敗 - リクエストヘッダーに x-api-key がない  |
| -1001 | 失敗 - 利用企業が存在しない                |
| -1002 | 失敗 - 利用企業が未承認（承認が必要）           |
| -1003 | 失敗 - 利用企業の契約期間が満了              |
| -1004 | 失敗 - データのリクエスト数を超過             |
| -1005 | 失敗 - 処理中のプロセスがある               |
| -1009 | 失敗 - このデータは30分後に削除をリクエストしてください |
| -1010 | 失敗 - データ削除のエラー                 |
| -9997 | 失敗 - データが正しくありません。             |
| -9998 | 失敗 - HTTP関連のエラー                |
| -9999 | 失敗 - APIサーバーのエラー               |

***

### **データ形式**

{% hint style="warning" %}
カスタムデータは、文字列・数値・日付のデータタイプに対応しています。以下は共通フォーマットのガイドです。

日付は必ず YYYY-MM-DD 形式で登録してください。
{% endhint %}

**文字列**

```
"memberId" : {
    "customDataKey" : "GOLD"
}
```

**数値**

```
"memberId" : {
    "customDataKey1" : 34,
    "customDataKey2" : "12" // ""で囲んでも正しく登録されます
}
```

**日付**

```
"memberId" : {
    "customDataKey" : "2022-12-30" // YYYY-MM-DD
}
```

***

## **エンドポイント**

### **カスタムデータの照会**

カスタムデータを照会するAPI

* **リクエストの形式（共通）**：初回の照会以降は、次のページを照会するための nextPageSeq を返します。（1ページあたりの照会件数：1000件）

```
/v2/custom?seq=<nextPageSeqの値>
```

* **全件リクエストの形式**

| Method | URI        | リクエスト/レスポンス形式 |
| ------ | ---------- | ------------- |
| GET    | /v2/custom | JSON          |

* **単一リクエストの形式**

| Method | URI                          | リクエスト/レスポンス形式 |
| ------ | ---------------------------- | ------------- |
| GET    | /v2/custom?memberId=<会員IDの値> | JSON          |

* **共通レスポンスデータ**

```
{
    "httpStatus": {
        "code": <HTTPステータスコード>, 
        "reasonPhrase": <HTTPステータスの内容> 
    }, 
    "processCode": <成否>, 
    "processValue": { 
        "nextPageSeq": <次のページを照会するためのseqの値>, 
        "dataList": [ 
            { 
                "memberId": <会員ID>, 
                "customDataKey": <カスタムデータキー>, 
                "customDataValue": <カスタムデータの値> 
            }, 
            ... 
        ] 
    } 
} 
```

### **カスタムデータの登録**

カスタムデータを登録するAPI

{% hint style="warning" %}
※ 登録をリクエストするデータが null の場合は、そのデータを除いて送信することをおすすめします。

groobee内部では、null のデータを次のように処理します。

* 文字列（String）型：groobee内部の変換処理で空の値として処理
* 日付（Date）または数値（Int）型：F02（形式の不一致）コードを返す

登録済みのデータに対して、同じ会員ID・カスタムデータキーで追加の登録をリクエストすると、更新として処理されます。
{% endhint %}

* **リクエストの形式とデータ**：登録するカスタムデータの情報を配列でリクエストします。（1回のリクエストにつき、会員IDの数で最大1000件）

| Method | URI        | リクエスト/レスポンス形式 |
| ------ | ---------- | ------------- |
| POST   | /v2/custom | JSON          |

```
{
    <会員IDの値> : {
        <カスタムデータキー>: <カスタムデータの値>, 
        ...
    },
    ...
}          
```

<br>

* **レスポンスデータ**

"processCode" : 1（一部成功）

{% hint style="danger" %}
カスタムデータキーが登録されていない、またはデータ形式が一致しないことが原因で、一部が失敗する場合があります。
{% endhint %}

```
{
     "httpStatus": {
         "code": <HTTPステータスコード>,
         "reasonPhrase": <HTTPステータスの内容>
     },
     "processCode": <成否>,
     "processValue": [
         {
             "memberId" : <登録に失敗した会員IDの値>,
             "failKey" : <登録に失敗したカスタムデータキー>,
             "failValue" : <登録に失敗したカスタムデータの値>,
             "failCode" : <登録失敗コード>
         },
         ...（登録をリクエストしたうち、失敗したカスタムデータの情報）
     ]
 
}
```

* **登録失敗コード**

| コード値 | 説明             |
| ---- | -------------- |
| F01  | カスタムデータキーが未登録  |
| F02  | カスタムデータの形式が不一致 |

### **カスタムデータの変更**

* **リクエストの形式とデータ**：変更するカスタムデータの情報をオブジェクトでリクエストします。（1回のリクエストにつき、会員IDの数で最大1000件）

| Method | URI        | リクエスト/レスポンス形式 |
| ------ | ---------- | ------------- |
| PUT    | /v2/custom | JSON          |

```
 {
    <会員IDの値> : {
         <カスタムデータキー>: <カスタムデータの値>,
         ... 
    },
    ...
 } 
```

<br>

* **レスポンスデータ**

"processCode" : 1（一部成功）

{% hint style="danger" %}
カスタムデータキーが登録されていない、またはデータ形式が一致しないことが原因で、一部が失敗する場合があります。
{% endhint %}

```
{
     "httpStatus": {
         "code": <HTTPステータスコード>,
         "reasonPhrase": <HTTPステータスの内容>
     },
     "processCode": <成否>,
     "processValue": [
         {
             "memberId" : <変更に失敗した会員IDの値>
             "failKey" : <変更に失敗したカスタムデータキー>
             "failValue" : <変更に失敗したカスタムデータの値>,
             "failCode" : <変更失敗コード>
         },
         ...（変更をリクエストしたうち、失敗したカスタムデータの情報）
     ]
}
```

* **変更失敗コード**

| コード値 | 説明             |
| ---- | -------------- |
| F01  | カスタムデータキーが未登録  |
| F02  | カスタムデータの形式が不一致 |

### **カスタムデータの削除**

カスタムデータを削除するAPI

{% hint style="danger" %}
削除をリクエストすると、データの削除に失敗して -1009 または -1010 エラーが発生する場合があります。

この場合は、30分後に削除を再試行してください。
{% endhint %}

* 複数リクエストの形式とデータ：削除する会員IDの値を配列でリクエストします。（1回のリクエストにつき最大1000件）

| Method | URI        | リクエスト/レスポンス形式 |
| ------ | ---------- | ------------- |
| DELETE | /v2/custom | JSON          |

```
[
    <削除する会員IDの値>,
    ... 
]
```

<br>

* 単一リクエストの形式とデータ（1つの会員IDについて、削除したいカスタムデータキーだけを指定）：\
  削除するカスタムデータの情報をオブジェクトでリクエストします。（1回のリクエストにつき、会員IDの数で最大1000件）

| Method | URI                         | リクエスト/レスポンス形式 |
| ------ | --------------------------- | ------------- |
| DELETE | /v2/custom/data-format-name | JSON          |

```
{
     <削除する会員IDの値> : [
         <削除するカスタムデータキー>,
         ...
     ],
     ...
}
```

* 共通レスポンスデータ

```
{
    "httpStatus": {
        "code": <HTTPステータスコード>,
        "reasonPhrase": <HTTPステータスの内容> 
    },
    "processCode": <成否>,                    
    "processValue": <削除されたデータの数> 
}
```

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.groobee.ai/ja/developer-guide/api-guide/custom-data/v2.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
