# Sending Successful Form Submission

![](/files/-MYJKReaM-vsWpZagmk7)

If you configured sending successful form submission on the dashboard, and you're using the JS SDK (`cotter` or `cotter-react`), you can add the following to your success function:

{% tabs %}
{% tab title="`cotter` JS SDK" %}

```javascript

import Cotter, { CotterEnum } from 'cotter';

var cotterApiKeyID = "<YOUR_API_KEY_ID>"
var cotter = new Cotter(cotterApiKeyID); // 👈 Specify your API KEY ID here
var formID = "form_default"
cotter
  .withFormID(formID) // Use customization for form "form_default"
  .signInWithLink() // Sign In with Magic Link
  .showPhoneForm() // Send Magic Link via Phone Number
  .then((resp) => {   
  
      // == 
      // RUN SUCCESSFUL FORM SUBMISSION 
      // SETUP THAT YOU HAVE IN THE DASHBOARD 
      // ==
      fetch(`${CotterEnum.WorkerURL}/completion/form?form-id=${encodeURIComponent(formID)}`,{
          method: "POST",
          headers: {
            API_KEY_ID: cotterApiKeyID,
            "Content-type": "application/json",
          },
          body: JSON.stringify(resp),
        }).then((_) => {
            window.location.href = "/protected";// redirect to the protected page
        })       
      // == 
      
  })
  .catch(err => {
    console.log(err) // handle error
  });
```

{% endtab %}

{% tab title="`cotter-react` React SDK" %}

```jsx
import { LoginForm } from "cotter-react";
import { CotterEnum } from 'cotter';
//...

const onSuccess = (resp) => {
  // == 
  // RUN SUCCESSFUL FORM SUBMISSION 
  // SETUP THAT YOU HAVE IN THE DASHBOARD 
  // ==
  fetch(`${CotterEnum.WorkerURL}/completion/form?form-id=${encodeURIComponent(formID)}`,{
      method: "POST",
      headers: {
        API_KEY_ID: cotterApiKeyID,
        "Content-type": "application/json",
      },
      body: JSON.stringify(resp),
    }).then((_) => { 
        window.location.href = "/protected";// redirect to the protected page
    })       
  // == 
}

//...
<LoginForm
  type="EMAIL" // - EMAIL or PHONE
  authMethod="MAGIC_LINK" // - OTP or MAGIC_LINK
  onSuccess={onSuccess} // - A function that runs after the login/signup is successful
  onError={(err) => console.log(err)} // - A function that runs if the login/signup encountered an error
  width={340} // - Width & height of the form
  height={300} //  Recommended at least 300x300
  formID={"form_default"}
/>
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://docs.cotter.app/sdk-reference/web/sending-successful-form-submission.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
