> 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/accounting/freee-accounting-custom-partners.md).

# freee会計の取引先データを取得する

{% hint style="success" %}

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

このレシピは、[freee会計 APIリファレンス - 取引先API](https://developer.freee.co.jp/reference/accounting/reference#operations-tag-Partners) を参考に記述されています。
{% endhint %}

## **freee会計の「取引先データ」とは**

freee会計では、取引先の情報をマスタとして登録することで、取引の際に入力する摘要の管理を効率化できます。\
（参考：[取引先を登録する - freeeヘルプセンター](https://support.freee.co.jp/hc/ja/articles/360028278932-%E5%8F%96%E5%BC%95%E5%85%88%E3%82%92%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B)）

freee 会計API を利用することで、指定した事業所に登録された**取引先データ（マスタ）**&#x306E;一覧を取得できます。

### **freee会計の「取引先データ」の構造**

```json
{
  "partners": [
    {
      "id": 1,
      "code": "code001",
      "company_id": 1,
      "name": "ABC商店",
      "update_date": "2019-12-17",
      "available": true,
      "shortcut1": "ABC",
      "shortcut2": "501",
      "org_code": 1,
      "country_code": "JP",
      "long_name": "新しい取引先正式名称",
      "name_kana": "アタラシイトリヒキサキメイショウ",
      "default_title": "御中",
      "phone": "03-1234-xxxx",
      "contact_name": "営業担当",
      "email": "[email protected]",
      "payer_walletable_id": 1,
      "transfer_fee_handling_side": "payer",
      "qualified_invoice_issuer": false,
      "invoice_registration_number": "T1000000000001",
      "address_attributes": {
        "zipcode": "000-0000",
        "prefecture_code": 4,
        "street_name1": "ＸＸ区ＹＹ１−１−１",
        "street_name2": "ビル１Ｆ"
      },
      "partner_doc_setting_attributes": {
        "sending_method": "posting"
      },
      "partner_bank_account_attributes": {
        "bank_name": "freee銀行",
        "bank_name_kana": "フリーギンコウ",
        "bank_code": "0001",
        "branch_name": "銀座支店",
        "branch_kana": "ギンザシテン",
        "branch_code": "999",
        "account_type": "ordinary",
        "account_number": "1010101",
        "account_name": "フリータロウ",
        "long_account_name": "freee太郎"
      }
    }
  ]
}
```

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

Anyflow Embedでfreee会計の取引先データを取得する手順を紹介します。

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

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

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

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

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

### **2. freee会計コネクタを設定する**

freee会計コネクタを追加します。

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

### **3. 事業所の入力アシストを設定する**

以下の通りエンドユーザー変数を作成します。

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

ウィザードの設定に移動します。\
「事業所」のエンドユーザー変数の入力方法を**アシスト**にし、事業所一覧を取得できるようにします。

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

### **4. freee会計のカスタムアクションを設定する**

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

| 設定項目名       | 設定値              |
| ----------- | ---------------- |
| カスタムアクション名  | 取引先データを取得        |
| HTTPメソッド    | GET              |
| リクエストパス     | `api/1/partners` |
| リクエストヘッダー   | ※ 設定不要           |
| リクエストタイプ    | ※ 設定不要           |
| レスポンスヘッダー定義 | ※ 設定不要           |
| レスポンスタイプ    | json             |

「リクエストURLパラメータ」ではキーに`company_id`を、値にはエンドユーザー変数の「事業所」を設定します。

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

また、「レスポンスボディ定義」には以下の設定を行います。

<figure><img src="https://files.readme.io/276a5ce-CleanShot_2024-03-02_at_10.41.242x.png" alt="" width="563"><figcaption></figcaption></figure>

```json
{
  "partners": [
    {
      "id": 1,
      "name": "ABC商店",
      "name_kana": "アタラシイトリヒキサキメイショウ",
      "contact_name": "営業担当",
      "email": "[email protected]"
    }
  ]
}
```

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

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

| 設定項目名      | 設定値           |
| ---------- | ------------- |
| アクション      | 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
name_kana
contact_name
email
```

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

<figure><img src="https://files.readme.io/fc3592b-CleanShot_2024-03-02_at_10.36.562x.png" alt="" width="563"><figcaption></figcaption></figure>

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

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

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

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

```
id
name
name_kana
contact_name
email
```

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

<figure><img src="https://files.readme.io/284e326-CleanShot_2024-03-02_at_10.25.472x.png" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

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


---

# 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/accounting/freee-accounting-custom-partners.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.
