Update order note dynamically from POS UI Extension

I have a use case i want to call an external api and based on the result from the api i want to update the order notes or add extra details to the order. How can i achieve this. Also After adding the details I also want that these details and notes come with each order when i go to previous orders.
For example I want some thing like this:

  • I go to the order and call the api by clicking on the button or in some other waythe api returns me a ref number.
  • I save the ref number in the order notes and save the order.
  • When i go to all orders and go to the order i just updated and I should be able to see the notes.

Is this possible?