> For the complete documentation index, see [llms.txt](https://formdr.gitbook.io/formdr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://formdr.gitbook.io/formdr/documentation/submissions/create-submission.md).

# Create Submission

This endpoint is used for creating a submission for your form(s). During onboarding, your administrator will have been informed about field names. Your submission data must match these names. An example has been provided down below.

## Create a new submission

<mark style="color:green;">`POST`</mark> `https://api.formdr.com/api/v1/practice/{practiceId}`

#### Query Parameters

| Name                                                | Type        | Description                               |
| --------------------------------------------------- | ----------- | ----------------------------------------- |
| firstName<mark style="color:red;">\*</mark>         | String      | Patient First Name                        |
| lastName<mark style="color:red;">\*</mark>          | String      | Patient Last Name                         |
| formUuid<mark style="color:red;">\*</mark>          | String      | Form UUID                                 |
| email                                               | String      | Patient Email Address                     |
| phone                                               | String      | Patient Phone Number                      |
| sendForm<mark style="color:red;">\*</mark>          | String      | "email" \| "phone" \| "both"              |
| submissionData<mark style="color:red;">\*</mark>    | JSON String | Stringified JSON data. See example below. |
| appointment<mark style="color:red;">\*</mark>       | String      | Must be in "YYYY-MM-DD hh:mm:ss" format.  |
| securityCode<mark style="color:red;">\*</mark>      | String      | Security code used to open the form.      |
| securityCodeHint<mark style="color:red;">\*</mark>  | String      | Hint provided for the security code.      |
| automaticReminder<mark style="color:red;">\*</mark> | Boolean     | Automatic appointment reminder.           |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "submissionId": number,
    "formId": number,
    "formName": string,
    "name": string,
    "formUuid": string,
    "submissionToken": string,
    "submissionUrl": string, //publicly accessible URL for patient
}
```

{% endtab %}

{% tab title="401: Unauthorized No access token provided." %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```
You must supply an email when sendform === 'email' and you must supply phone when sendForm === 'phone'. Obviously, supply both when sendForm === 'both'
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
firstName and lastName parameters are used for patient records and will be the same when you're searching for records. **Warning: these differ from firstName and lastName in the submissionData.**
{% endhint %}

The submissionData is a JSON string that maps to each field in the form. During form creation, each field is generated with a unique ID. This ID can be changed to best suit your purposes. Some fields, like the Single-Select Option field, can be given specific values.&#x20;

You will notice below there is a takingMedicineCheckbox which returns a boolean value, but a painYesNo variable that is a string of 'true'. This is because the field is a Single-Select Option field. The default value of which is 'true', but it can be any value that the form creator wants.

{% hint style="danger" %}
This endpoint does not enforce key names. Any typos or extra keys will result in the insertion of this data and may cause display errors or data to not be displayed if it wasn't configured in the form.
{% endhint %}

#### submissionData example

```json
{
  "takingMedicineCheckbox": true,
  "signedDate": "11/07/2022",
  "firstName": "Aaron",
  "lastName": "Jackson",
  "painYesNo": "true"
}
```

{% hint style="info" %}
Use the standard **JSON.stringify()** function to properly send JSON as a string parameter.
{% endhint %}

{% hint style="warning" %}
Once the patient has opened and submitted their form, the submissionUrl is no longer valid and cannot be accessed. Use the [Get Submission](/formdr/documentation/submissions/get-submission.md) endpoint to see their submitted data.
{% endhint %}
