sunabarAPI一覧

###利用できるAPI一覧
|カテゴリ|method|API|概要|個人|法人|
|:--|:--|:--|:--|:-:|:-:
|口座 |GET |口座一覧照会　|保有する全ての口座情報一覧を照会|○ |○ |
|口座 |GET |残高照会　|保有する口座の残高情報を照会 |○ |○ |
|口座 |GET |入出金明細照会　|指定した円普通預金口座の入出金明細情報を照会 |○ |○ |
|口座 |GET |振込入金明細照会　|被仕向振込の入金明細情報を照会|○ |○ |
|振込/振替 |GET |振込状況照会　|仕向の振込の履歴・状況の照会|○ |○ |
|振込/振替 |GET |振込依頼結果照会　|振込依頼、振込取消依頼の処理状態を照会 |○ |○ |
|振込/振替 |GET |振込手数料事前照会　|仕向の振込依頼の手数料を事前に照会|○ |○ |
|振込/振替 |GET |振込依頼　|仕向の振込依頼の指示 |○ |○ |
|振込/振替 |GET |振込取消依頼　|振込予約、振込申請の取消依頼を指示|○ |○ |
|振込/振替 |GET |つかいわけ口座間振替　|つかいわけ口座間の振替の指示 |○ |- |
|総合振込 |GET |総合振込状況照会 　|仕向の総合振込の履歴・状況の照会|- |○ |
|総合振込 |GET |総合振込依頼結果照会 　|総合振込依頼の処理状態を照会|- |○ |
|総合振込 |GET |総合振込手数料事前照会　|仕向の総合振込依頼の手数料を事前に照会 |- |○ |
|総合振込 |GET |総合振込依頼　|仕向の総合振込依頼の指示 |- |○ |
|総合振込 |GET |総合振込取消依頼 　|総合振込予約、総合振込申請の取消依頼を指示|- |○ |
|振込入金口座|GET |振込入金口座一覧照会 　|発行済みの振込入金口座の一覧を照会|- |○ |
|振込入金口座|GET |振込入金口座入金明細照会 　|入金口座または振込入金口座を指定し、該当する入金明細を照会|- |○ |
|振込入金口座|GET |振込入金口座発行 　|振込入金口座の発行|- |○ |
|振込入金口座|GET |振込入金口座状態変更 　|振込入金口座の状態変更（停止・再開・削除） |- |○ |
|振込入金口座|GET |振込入金口座解約申込 　|振込入金口座契約の解約申込|- |○ |

---

##口座
###口座一覧照会

```javascript
function accounts() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/accounts";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}

```
###残高照会
```javascript
function accounts_balances() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/accounts/balances";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };
 
  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###入出金明細照会
```javascript
function transactions() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/accounts/transactions?accountId=" + accountId;
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };
 
  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込入金明細照会
```javascript
function deposit_transactions() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/accounts/deposit-transactions?accountId=102010000406" + accountId;
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };
 
  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
##振込/振替
###振込状況照会
```javascript
function transfer_status() {
  //アクセストークン
  const accesstoken="＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/transfer/status?accountId=" + accountId + "&queryKeyClass=2";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込依頼結果照会
```javascript
function transfer_request_result() {
  //アクセストークン
  const accesstoken="＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";
  //受付番号（振込申請番号）
  const applyNo = 2020042500000012;

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/transfer/request-result?accountId=" + accountId + "&applyNo=" + applyNo;
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込手数料事前照会
```javascript
function transfer_transferfee() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";
  //振込指定日
  const transferDesignatedDate = "2020-04-27";
  //振込金額
  const transferAmount = "1000";
  //被仕向金融機関番号
  const beneficiaryBankCode = "0310";
  //被仕向支店番号
  const beneficiaryBranchCode = "102";
  //科目コード（預金種別コード）
  const accountTypeCode = "1";
  //口座番号
  const accountNumber = "0000406";
  //受取人名
  const beneficiaryName = "ｽﾅﾊﾞｾｲｿﾞｳ(ｶ";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/transfer/transferfee";
  const headers = {
    "accept" : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    "x-access-token" : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "accountId": accountId,
      "transferDesignatedDate": transferDesignatedDate,
      "transfers": [
        {
          "transferAmount": transferAmount,
          "beneficiaryBankCode": beneficiaryBankCode,
          "beneficiaryBranchCode": beneficiaryBranchCode,
          "accountTypeCode": accountTypeCode,
          "accountNumber": accountNumber,
          "beneficiaryName": beneficiaryName
        }
      ]
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,
    "muteHttpExceptions" : true
  };
 
  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込依頼
```javascript
function transfer_request() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";
  //振込指定日
  const transferDesignatedDate = "2020-04-27";
  //振込金額
  const transferAmount = "1000";
  //被仕向金融機関番号
  const beneficiaryBankCode = "0310";
  //被仕向支店番号
  const beneficiaryBranchCode = "102";
  //科目コード（預金種別コード）
  const accountTypeCode = "1";
  //口座番号
  const accountNumber = "0000406";
  //受取人名
  const beneficiaryName = "ｽﾅﾊﾞｾｲｿﾞｳ(ｶ";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/transfer/request";
  const headers = {
    "accept" : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    "x-access-token" : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "accountId": accountId,
      "transferDesignatedDate": transferDesignatedDate,
      "transfers": [
        {
          "transferAmount": transferAmount,
          "beneficiaryBankCode": beneficiaryBankCode,
          "beneficiaryBranchCode": beneficiaryBranchCode,
          "accountTypeCode": accountTypeCode,
          "accountNumber": accountNumber,
          "beneficiaryName": beneficiaryName
        }
      ]
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,
    "muteHttpExceptions" : true
  };
 
  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
※振込依頼の承認は対象のテスト口座でsunabarサービスサイトログインし、お知らせ画面で行う。

###振込取消依頼
```javascript
function transfer_cancel() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";
  //取消対象キー区分
  const cancelTargetKeyClass = "2";
  //受付番号（振込申請番号）
  const applyNo = "2020042500000012";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/transfer/cancel";
  const headers = {
    "accept" : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    "x-access-token" : accesstoken,
  };
  const payload = JSON.stringify(
    {
        "accountId": accountId,
        "cancelTargetKeyClass": cancelTargetKeyClass,
        "applyNo": applyNo,
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,
    "muteHttpExceptions" : true
  };
 
  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
※振込取消依頼の承認は対象のテスト口座でsunabarサービスサイトログインし、お知らせ画面で行う。

###つかいわけ口座間振替
```javascript
function transfer_spaccounts_transfer() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "302010000437";
  //つかいわけ口座_入金口座ID
  const depositSpAccountId = "SP50220000499";
  //つかいわけ口座_出金口座ID
  const debitSpAccountId = "SP30210000437";
  //支払金額
  const paymentAmount = "1000";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/personal/v1/transfer/spaccounts-transfer";
  const headers = {
    "accept" : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    "x-access-token" : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "accountId": accountId,
      "depositSpAccountId": depositSpAccountId,
      "debitSpAccountId": debitSpAccountId,
      "paymentAmount": paymentAmount
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,
    "muteHttpExceptions" : true
  };
 
  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
##総合振込
###総合振込状況照会
```javascript
function bulktransfer_status() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "102010000406";
  //照会対象キー区分
  const queryKeyClass = "2";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/bulktransfer/status?accountId=" + accountId + "&queryKeyClass=" + queryKeyClass;
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###総合振込依頼結果照会
```javascript
function bulktransfer_request_result() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "102010000406";
  //受付番号（振込申請番号）
  const applyNo = "2020042600000001";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/bulktransfer/request-result?accountId=" + accountId + "&applyNo=" + applyNo;
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###総合振込手数料事前照会
```javascript
function bulktransfer_transferfee() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "102010000406";
  //振込指定日
  const transferDesignatedDate = "2020-05-27";
  //合計件数
  const totalCount = "1";
  //合計金額
  const totalAmount = "1000";
  //明細番号
  const itemId = "1";
  //被仕向金融機関番号
  const beneficiaryBankCode = "0310";
  //被仕向支店番号
  const beneficiaryBranchCode = "302";
  //科目コード（預金種別コード）
  const accountTypeCode = "1";
  //口座番号
  const accountNumber = "0000437";
  //受取人名
  const beneficiaryName = "ｽﾅﾊﾞ ｱｶﾈ";
  //振込金額
  const transferAmount = "1000";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/bulktransfer/transferfee";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    'x-access-token' : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "accountId": accountId,
      "transferDesignatedDate": transferDesignatedDate,
      "totalCount": totalCount,
      "totalAmount": totalAmount,
      "bulkTransfers": [
        {
          "itemId": itemId,
          "beneficiaryBankCode": beneficiaryBankCode,
          "beneficiaryBranchCode": beneficiaryBranchCode,
          "accountTypeCode": accountTypeCode,
          "accountNumber": accountNumber,
          "beneficiaryName": beneficiaryName,
          "transferAmount": transferAmount
        }
      ]
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###総合振込依頼
```javascript
function bulktransfer_request() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "102010000406";
  //振込指定日
  const transferDesignatedDate = "2020-04-27";
  //合計件数
  const totalCount = "1";
  //合計金額
  const totalAmount = "1000";
  //明細番号
  const itemId = "1";
  //被仕向金融機関番号
  const beneficiaryBankCode = "0310";
  //被仕向支店番号
  const beneficiaryBranchCode = "302";
  //科目コード（預金種別コード）
  const accountTypeCode = "1";
  //口座番号
  const accountNumber = "0000437";
  //受取人名
  const beneficiaryName = "ｽﾅﾊﾞ ｱｶﾈ";
  //振込金額
  const transferAmount = "1000";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/bulktransfer/request";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    'x-access-token' : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "accountId": accountId,
      "transferDesignatedDate": transferDesignatedDate,
      "totalCount": totalCount,
      "totalAmount": totalAmount,
      "bulkTransfers": [
        {
          "itemId": itemId,
          "beneficiaryBankCode": beneficiaryBankCode,
          "beneficiaryBranchCode": beneficiaryBranchCode,
          "accountTypeCode": accountTypeCode,
          "accountNumber": accountNumber,
          "beneficiaryName": beneficiaryName,
          "transferAmount": transferAmount
        }
      ]
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
※総合振込依頼の承認は対象のテスト口座でsunabarサービスサイトログインし、お知らせ画面で行う。

###総合振込取消依頼
```javascript
function bulktransfer_cancel() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //口座ID
  const accountId = "102010000406";
  //取消対象キー区分
  const cancelTargetKeyClass = "4";
  //受付番号（振込申請番号）
  const applyNo = "2020042600000001";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/bulktransfer/cancel";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    'x-access-token' : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "accountId": accountId,
      "cancelTargetKeyClass": cancelTargetKeyClass,
      "applyNo": applyNo
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
※総合振込依頼の承認は対象のテスト口座でsunabarサービスサイトログインし、お知らせ画面で行う。

##振込入金口座
###振込入金口座一覧照会
```javascript
function va_list() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/va/list";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    'x-access-token' : accesstoken,
  };
  const payload = JSON.stringify(
    {}
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,   
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込入金口座入金明細照会
```javascript
function va_deposit_transactions() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //入金口座ID
  const raId = "102010000406";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/va/deposit-transactions?raId=" + raId;
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    'x-access-token' : accesstoken,
  };
  const options = {
    "method" : "GET",
    "headers" : headers,
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込入金口座発行
```javascript
function va_issue() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //振込入金口座　種類コード
  const vaTypeCode = "2";
  //発行口座数
  const issueRequestCount = "1";
  //入金口座ID
  const raId = "102010000406";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/va/issue";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    'x-access-token' : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "vaTypeCode": vaTypeCode,
      "issueRequestCount": issueRequestCount,
      "raId": raId
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,   
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込入金口座状態変更
```javascript
function va_status_change() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";
  //振込入金口座　種類コード
  const vaTypeCode = "2";
  //発行口座数
  const issueRequestCount = "1";
  //入金口座ID
  const raId = "102010000406";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/va/status-change";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    'x-access-token' : accesstoken,
  };
  const payload = JSON.stringify(
    {
      "vaStatusChangeCode": "2",
      "vaIdList": [    
        {
          "vaId": "5020000512"
        }
      ]
    }
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,   
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```
###振込入金口座解約申込 
```javascript
function va_close_request() {
  //アクセストークン
  const accesstoken = "＜アクセストークン＞";

  //リクエストデータ
  const url = "https://api.sunabar.gmo-aozora.com/corporation/v1/va/close-request";
  const headers = {
    'accept' : "application/json;charset=UTF-8",
    "Content-Type" : "application/json",
    'x-access-token' : accesstoken,
  };
  const payload = JSON.stringify(
    {}
  );
  const options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : payload,   
    "muteHttpExceptions" : true
  };

  //レスポンス結果
  const response = UrlFetchApp.fetch(url, options);
  Logger.log(response.getResponseCode());
  Logger.log(response.getContentText());
}
```