# JSON Ledger APIのコマンドの送信

> JSON Ledger APIでコマンドを待たずに送る形と結果まで待つ形を見分け、完了の受け取りと、reassignmentで移したコントラクトの結果を、章の中の図解で追います。

- URL: https://cardene.dev/diagrams/canton-json-command-flow
- 公開日: 2026-11-23
- 更新日: 2026-11-23
- トピック: Blockchain
- タグ: Canton
- 親の図解: [Canton Networkの全体像](https://cardene.dev/diagrams/canton-network.md): トランザクションの中身を関わるpartyにだけ見せるCanton Networkについて、部品ごとの役割と、1つのトランザクションが部品の間をどう流れるかを段ごとに追います。
- 子の図解: [JSON APIでコマンドを送る](https://cardene.dev/diagrams/canton-json-submit.md): JSON Ledger APIの待たずに送る2つのエンドポイントで、4種のコマンドとreassignmentの書き方と、change IDと重複排除とledger timeと開示したコントラクトの指定を追います。
- 子の図解: [コマンドを送って結果を待つ](https://cardene.dev/diagrams/canton-json-submit-wait.md): JSON Ledger APIで1つの複合のコマンドを送り結果が出るまで待つエンドポイントが、何を受け取り何を返し、どの欄の条件を守るかと、失敗した時の返り方を追います。
- 子の図解: [JSONで完了の知らせを受け取る](https://cardene.dev/diagrams/canton-json-completions.md): JSON Ledger APIで送ったコマンドの完了を取り出すエンドポイントの呼び方と、完了とOffsetCheckpointの欄と、offsetからの読み直しと、返るエラーを追います。
- 子の図解: [reassignmentでコントラクトを移す](https://cardene.dev/diagrams/canton-json-reassignment.md): コントラクトを別のSynchronizerへ移すreassignmentのコマンドをJSON Ledger APIで送り結果を待つと、何が返りどのイベントが記録されるかを、2つの図で追います。

前の章「JSON Ledger APIの入口」では、JSON Ledger APIのエンドポイントと認証とエラーの返し方を見ました。
この章では、JSON Ledger APIにHTTPでコマンドを送り、結果を受け取る所を追います。

:::details JSON
JSONは、データを文字で表すための形式で、Webのプログラムどうしのデータのやり取りに広く使われています。
:::

HTTPは、ブラウザやプログラムがWebのサーバーと要求と応答をやり取りする決まりです。

gRPCのLedger APIで同じことを書いたのは、章「コマンドの送信と完了」なので、仕組みはその章の頁を指し、この章はJSONの呼び方と欄の形を書きます。

:::details gRPC
gRPCは、Googleが開発した、ネットワーク越しに別のプログラムの処理を呼び出すための通信の仕組みです。
:::

https://cardene.dev/diagrams/canton-command-submission-flow

まず、コマンドを待たずに送る2つのエンドポイントを見ます。
受付で返る200の本文は、空のJSONのオブジェクトで、受付だけを表します。
完了の成否は完了の知らせで読み、台帳に記録された変更は更新から読みます。
4種のコマンドとreassignmentのコマンドの書き方と、change IDと重複排除とledger timeと開示したコントラクトの指定を追います。

reassignmentは、移す元のSynchronizerでunassignし、移す先のSynchronizerでassignする2段の手順です。

https://cardene.dev/diagrams/canton-json-submit

次に、結果が出るまで待つエンドポイントを見ます。
何を渡し、何が返り、どの欄の条件を守るかを追います。
失敗した時の返り方は、本文を読めない時の400のプレーンテキストと、コマンドの処理が断られた時のJSONのエラーに分けて追います。

https://cardene.dev/diagrams/canton-json-submit-wait

さらに、送ったコマンドの完了を取り出すエンドポイントを見ます。
完了の欄と、offsetからの読み直しと、返るエラーを追います。

offsetは、streamの中の位置を表す値です。

https://cardene.dev/diagrams/canton-json-completions

最後に、reassignmentで別のSynchronizerへコントラクトを移すコマンドを、結果まで待って送る呼び出しを見ます。
返るreassignmentの欄と、記録されるイベントを追います。

https://cardene.dev/diagrams/canton-json-reassignment

図の語は、それぞれの頁が説明します。

下の図は、この章の4つの頁が扱う物を、アプリからJSON Ledger APIの順に置きます。
虫眼鏡の印が付いた部品を押すと、その部品の中へ入ります。
外側へ戻る時は、右上の「戻る」か、上に並んだ名前を押します。
部品の中へ入ると、名前の並びの下にその部品を説明する頁の題が出て、押すとその頁を開きます。

図の上の全体の木の部品を押すと、一番外や別の部品へ直接移れます。

```dragon
architecture アプリからJSON Ledger APIへ
group Top as アプリからJSON Ledger APIへ [icon: net]
  box App as アプリ [note: コマンドを送る, color: blue, icon: app, link: /diagrams/canton-json-submit]
  box Json as JSON Ledger API [note: HTTPで受ける, color: slate, icon: server, link: /diagrams/canton-json-submit]
end
group JsonIn as JSON Ledger APIの中 [color: slate, icon: server]
  box Send as コマンドの送信 [note: コマンドを送る呼び出し, icon: refresh, link: /diagrams/canton-json-submit]
  box Comp as 完了の知らせ [note: 送ったコマンドの完了の一覧を返す, icon: card, link: /diagrams/canton-json-completions]
end
group SendIn as コマンドの送信の中 [color: slate, icon: refresh]
  box Async as 待たずに送る [note: 受付だけを空のJSONのオブジェクトで返す, icon: refresh, link: /diagrams/canton-json-submit]
  box Wait as 結果まで待つ [note: 成功すると結果を返し、失敗するとエラーを返す, icon: card, link: /diagrams/canton-json-submit-wait]
end
group WaitIn as 結果まで待つの中 [color: slate, icon: card]
  box Cmd as コマンド [note: 成功するとトランザクションのIDと完了のoffsetを返す, icon: card, link: /diagrams/canton-json-submit-wait]
  box Reas as reassignment [note: 成功すると完了後のreassignmentを返す, icon: card, link: /diagrams/canton-json-reassignment]
end

step アプリからJSON Ledger APIへ
  say アプリは、コマンドをHTTPでJSON Ledger APIへ送ります。
  App -> Json: コマンドを送る
  source CantonのJSON API [url: https://docs.canton.network/sdks-tools/api-reference/json-api]
  source CantonのLedger APIのサービス [url: https://docs.canton.network/sdks-tools/api-reference/ledger-api-services]
  source CantonのPOST /v2/commands/async/submit [url: https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit]
  source CantonのPOST /v2/commands/async/submit-reassignment [url: https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit-reassignment]
  source CantonのExplicit Contract Disclosure [url: https://docs.canton.network/appdev/deep-dives/explicit-contract-disclosure]
  source CantonのCommand Deduplication [url: https://docs.canton.network/appdev/deep-dives/command-deduplication]

step JSON Ledger APIの中
  say JSON Ledger APIは、コマンドを送る呼び出しと、送ったコマンドの完了の知らせを返す呼び出しを受け付けます。
  act Send: コマンドを送る
  act Comp: 完了の一覧を返す
  source CantonのJSON API [url: https://docs.canton.network/sdks-tools/api-reference/json-api]
  source CantonのLedger APIのサービス [url: https://docs.canton.network/sdks-tools/api-reference/ledger-api-services]
  source CantonのPOST /v2/commands/async/submit [url: https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit]
  source CantonのPOST /v2/commands/async/submit-reassignment [url: https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit-reassignment]
  source CantonのExplicit Contract Disclosure [url: https://docs.canton.network/appdev/deep-dives/explicit-contract-disclosure]
  source CantonのCommand Deduplication [url: https://docs.canton.network/appdev/deep-dives/command-deduplication]
  source CantonのPOST /v2/commands/command-completions [url: https://docs.canton.network/reference/json-api-reference/post-v2commandscommand-completions]

step コマンドの送信の中
  say 待たずに送るエンドポイントは、受付だけを空のJSONのオブジェクトで返します。結果まで待つエンドポイントは、成功すると結果を返し、失敗するとエラーを返します。
  act Async: 受付だけを返す
  act Wait: 結果まで待つ
  source CantonのJSON API [url: https://docs.canton.network/sdks-tools/api-reference/json-api]
  source CantonのLedger APIのサービス [url: https://docs.canton.network/sdks-tools/api-reference/ledger-api-services]
  source CantonのPOST /v2/commands/async/submit [url: https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit]
  source CantonのPOST /v2/commands/async/submit-reassignment [url: https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit-reassignment]
  source CantonのExplicit Contract Disclosure [url: https://docs.canton.network/appdev/deep-dives/explicit-contract-disclosure]
  source CantonのCommand Deduplication [url: https://docs.canton.network/appdev/deep-dives/command-deduplication]
  source CantonのPOST /v2/commands/submit-and-wait [url: https://docs.canton.network/reference/json-api-reference/post-v2commandssubmit-and-wait]

step 結果まで待つの中
  say アプリが結果まで待つコマンドを送ると、成功した時に、トランザクションのIDと完了のoffsetが返ります。アプリがreassignmentを送ると、成功した時に、完了後のreassignmentが返ります。
  act Cmd: コマンドを送って待つ
  act Reas: reassignmentを送って待つ
  source CantonのJSON API [url: https://docs.canton.network/sdks-tools/api-reference/json-api]
  source CantonのExplicit Contract Disclosure [url: https://docs.canton.network/appdev/deep-dives/explicit-contract-disclosure]
  source CantonのPOST /v2/commands/submit-and-wait [url: https://docs.canton.network/reference/json-api-reference/post-v2commandssubmit-and-wait]
  source CantonのPOST /v2/commands/submit-and-wait-for-reassignment [url: https://docs.canton.network/reference/json-api-reference/post-v2commandssubmit-and-wait-for-reassignment]
  source Cantonの複数のSynchronizerの仕組み [url: https://docs.canton.network/overview/learn/multi-synchronizer]
```

一番外の階では、アプリがコマンドをJSON Ledger APIへ送ります。
JSON Ledger APIの中では、コマンドの送信と完了の知らせを置きます。

コマンドの送信の中では、待たずに送るエンドポイントを頁「JSON APIでコマンドを送る」が、結果まで待つエンドポイントを頁「コマンドを送って結果を待つ」が追います。
完了の知らせは、頁「JSONで完了の知らせを受け取る」が追います。
結果まで待つの中では、コマンドを頁「コマンドを送って結果を待つ」が、reassignmentを頁「reassignmentでコントラクトを移す」が追います。

この図では、JSON Ledger APIからアプリへ返る向きの線を引かず、返る応答は各頁の図に任せます。
この図では、reassignmentを、アプリが結果まで待って送る呼び出しとして、結果まで待つの中に置きます。

## 出典

https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit

https://docs.canton.network/reference/json-api-reference/post-v2commandsasyncsubmit-reassignment

https://docs.canton.network/reference/json-api-reference/post-v2commandssubmit-and-wait

https://docs.canton.network/reference/json-api-reference/post-v2commandscommand-completions

https://docs.canton.network/reference/json-api-reference/post-v2commandssubmit-and-wait-for-reassignment

https://docs.canton.network/sdks-tools/api-reference/json-api

https://docs.canton.network/sdks-tools/api-reference/ledger-api-services

https://docs.canton.network/overview/learn/multi-synchronizer

https://docs.canton.network/appdev/deep-dives/explicit-contract-disclosure

https://docs.canton.network/appdev/deep-dives/command-deduplication
