Input field not submitted in form when added through JS
You can add a hidden field in buildForm() like below 

/**
 * {@inheritdoc}
 */
public function buildForm(array $form, FormStateInterface $form_state) {
  :
  :
  $form['token'] = [
    '#type' =&gt; 'hidden',
    '#default_value' =&gt; ''
  ]; 
  :
  :
}


or, if you're not building the form yourself, i.e. you're altering an already existing form, you can add the hidden field via hook_form_alter or hook_form_FORM_ID_alter.

Then update value of it using JS if needed