# Sending data to Google Sheets with vanilla Javascript

### Picking a Google Sheet

![](https://506014553-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDC2UBVsxTCFgqgM3sK%2F-MDSqvGLhshZRsfr2l88%2F-MDSrUFdU7mZmqHKyR6N%2Fimage.png?alt=media\&token=fd67ebab-ff4a-4d4a-b6b0-2752b1b01609)

Because Sheet Monkey automatically builds the columns, it may be easiest to start with a blank sheet if you already have a form and just want to connect it to a sheet. But if you're looking for something to help you get started, you can pick one of our templates. Sheet Monkey will automatically save the sheet with some initial columns in your Google Drive.

### The form action is the link to your Google Sheet

Once you create a form, Sheet Monkey will provide a form url or "form action" where you can start posting data. This unique action is all you need to post data into the Google Sheet.

![](https://506014553-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDC2UBVsxTCFgqgM3sK%2F-MDSxUvdkFRP-Hw3f_AH%2F-MDSxtbhSrETiJCIz-sa%2Fimage.png?alt=media\&token=ea727e34-5d51-4a9b-b839-d58d96663e58)

### Mapping the object keys to your sheet columns

Sheet Monkey will automatically match property names to Google Sheet columns. In the example of a mailing list, submitting the following object...

```javascript
const data = {
    Email: 'steve.ballmer@microsoft.com',
    Name: 'Steve B.',
    Created: 'x-sheetmonkey-current-date-time'
};
```

...will create the following entry in the linked Google Sheet:

![](https://506014553-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MDC2UBVsxTCFgqgM3sK%2F-MDSxUvdkFRP-Hw3f_AH%2F-MDSzD13KKiGlfPf5PbO%2Fimage.png?alt=media\&token=cfa3aad6-9136-474f-850c-4360c3058cc1)

### Posting your data

Sheet Monkey accepts textual data in `application/json` or `mutipart/form-data` encoding. You can pick either one of these when posting with Javascript.

Here's an example of how you can post data using JSON encoding.

```javascript
const data = {
    Email: 'steve.ballmer@microsoft.com',
    Name: 'Steve B.',
    Created: 'x-sheetmonkey-current-date-time'
};

fetch('https://api.sheetmonkey.io/forms/vB1pUYCBvUqnSarEvAgsd6', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(data),
}).then((result) => {
  // Handle the result
});

```

### Responses

#### Error Status Codes:

* `401` Indicates that the domain is blocked from submitting to this form.
* `404` Indicates that the form could not be found.
* `500` Indicates that an unexpected error occurred or the system may be down.

**Success status codes:**

* `200` Indicates that the form was successfully submitted and the data should be added to the sheet.
