> For the complete documentation index, see [llms.txt](https://docs-embed.anyflow.jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-embed.anyflow.jp/recipe/crm/hubspot-custom-companies.md).

# HubSpotの会社データを取得する

{% hint style="success" %}

### このレシピについて

このレシピは、[CRM API | 会社](https://developers.hubspot.jp/docs/api/crm/companies) を参考に記述されています。
{% endhint %}

## **HubSpotの「会社データ」とは**

HubSpot に登録された、自社とやり取りする組織に関する情報です。\
（参考：[CRM API | 会社](https://developers.hubspot.jp/docs/api/crm/companies)）

HubSpot の CRM API を利用することで、HubSpot に登録された**会社データ**の一覧を取得できます。

### **HubSpotの「会社データ」の構造**

```json
{
  "paging": {
    "next": {
      "link": "?after=NTI1Cg%3D%3D",
      "after": "NTI1Cg%3D%3D"
    }
  },
  "results": [
    {
      "associations": {
        "additionalProp1": {
          "paging": {
            "next": null,
            "prev": {
              "before": "string",
              "link": "string"
            }
          },
          "results": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "additionalProp2": {
          "paging": {
            "next": null,
            "prev": {
              "before": "string",
              "link": "string"
            }
          },
          "results": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        },
        "additionalProp3": {
          "paging": {
            "next": null,
            "prev": {
              "before": "string",
              "link": "string"
            }
          },
          "results": [
            {
              "id": "string",
              "type": "string"
            }
          ]
        }
      },
      "createdAt": "2024-04-15T01:19:55.574Z",
      "archived": true,
      "archivedAt": "2024-04-15T01:19:55.574Z",
      "propertiesWithHistory": {
        "additionalProp1": [
          {
            "sourceId": "string",
            "sourceType": "string",
            "sourceLabel": "string",
            "updatedByUserId": 0,
            "value": "string",
            "timestamp": "2024-04-15T01:19:55.574Z"
          }
        ],
        "additionalProp2": [
          {
            "sourceId": "string",
            "sourceType": "string",
            "sourceLabel": "string",
            "updatedByUserId": 0,
            "value": "string",
            "timestamp": "2024-04-15T01:19:55.574Z"
          }
        ],
        "additionalProp3": [
          {
            "sourceId": "string",
            "sourceType": "string",
            "sourceLabel": "string",
            "updatedByUserId": 0,
            "value": "string",
            "timestamp": "2024-04-15T01:19:55.574Z"
          }
        ]
      },
      "id": "string",
      "properties": {
        "additionalProp1": "string",
        "additionalProp2": "string",
        "additionalProp3": "string"
      },
      "updatedAt": "2024-04-15T01:19:55.574Z"
    }
  ]
}
```

## **Anyflow Embedで取得する**

Anyflow Embed で HubSpot の会社データを取得する手順を紹介します。

HubSpot の会社データを**スプレッドシートに一括追加する**というシンプルなソリューションを作成し、会社に含まれるデータを把握します。

<figure><img src="https://files.readme.io/63951b6-CleanShot_2024-04-13_at_11.11.242x.png" alt=""><figcaption></figcaption></figure>

### **1.Clickトリガーを設定する**

Clickトリガーを設定します。

<figure><img src="https://files.readme.io/b9650b7-image.png" alt=""><figcaption></figcaption></figure>

### **2.HubSpot コネクタを設定する**

HubSpot コネクタを追加します。

<figure><img src="https://files.readme.io/c1e1552-CleanShot_2024-04-13_at_11.12.372x.png" alt="" width="563"><figcaption></figcaption></figure>

### **3.HubSpot のカスタムアクションを設定する**

ソリューションエディタに戻り、freee人事労務コネクタを以下の通りに設定します。

<table><thead><tr><th width="298.42578125">設定項目名</th><th>設定値</th></tr></thead><tbody><tr><td>カスタムアクション名</td><td>会社データを取得する</td></tr><tr><td>HTTPメソッド</td><td>GET</td></tr><tr><td>リクエストパス</td><td>/crm/v3/objects/companies</td></tr><tr><td>リクエストヘッダー</td><td>※ 設定不要</td></tr><tr><td>リクエストタイプ</td><td>※ 設定不要</td></tr><tr><td>レスポンスヘッダー定義</td><td>※ 設定不要</td></tr><tr><td>レスポンスタイプ</td><td>json</td></tr></tbody></table>

また、「レスポンスボディ定義」には「JSONを追加」で以下を設定します。

```json
{
  "results": [
    {
      "id": "string",
      "properties": {
        "name": "string",
        "domain": "string"
      },
      "createdAt": "2024-04-15T00:14:10.990Z",
      "updatedAt": "2024-04-15T00:14:10.990Z"
    }
  ]
}
```

「element」の名前は「company」に変更しておきます。

<figure><img src="https://files.readme.io/ced85ad-image.png" alt="" width="563"><figcaption></figcaption></figure>

以下が設定後のイメージです。

<figure><img src="https://files.readme.io/0964a55-CleanShot_2024-04-13_at_11.15.232x.png" alt="" width="563"><figcaption></figcaption></figure>

### **4.スプレッドシートの列名を設定する**

スプレッドシートコネクタを追加し、以下の通りに設定を行います。

| 設定項目名      | 設定値           |
| ---------- | ------------- |
| アクション      | 1行追加          |
| スプレッドシートID | 任意のスプレッドシートID |
| シートID      | 任意のシートID      |

<figure><img src="https://files.readme.io/677257c-_2024-02-26_17.45.08.png" alt=""><figcaption></figcaption></figure>

「ヘッダーの列名」は以下の通りに設定します。

```
id
name
domain
createdAt
updatedAt
```

「行データ」にも同じ様に設定します。

<figure><img src="https://files.readme.io/e368655-CleanShot_2024-04-13_at_11.16.172x.png" alt="" width="563"><figcaption></figcaption></figure>

### **5.スプレッドシートに一括追記する**

スプレッドシートコネクタを追加し、以下の通りに設定を行います。

| 設定項目名      | 設定値           |
| ---------- | ------------- |
| アクション      | 行を一括追加        |
| スプレッドシートID | 任意のスプレッドシートID |
| シートID      | 任意のシートID      |

「ヘッダーの列名」は以下の通りに設定します。

```
id
name
domain
createdAt
updatedAt
```

「リストソース」は以下の通りに設定します。

<figure><img src="https://files.readme.io/5ec1755-CleanShot_2024-04-13_at_11.17.182x.png" alt=""><figcaption></figcaption></figure>

「要素フィールド」は以下の通りに設定します。（「i番目のcompany」から項目を選択します。）

<figure><img src="https://files.readme.io/08bd454-CleanShot_2024-04-13_at_11.18.142x.png" alt=""><figcaption></figcaption></figure>

### **6.ウィザードを設定する**

必要な認証をウィザードに追加します。

### **7.テストを行う**

テストを行うと、スプレッドシートにデータが追加されていることがわかります。


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs-embed.anyflow.jp/recipe/crm/hubspot-custom-companies.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
