---
id: insert
title: "Create data: insert()"
slug: insert
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
Performs an INSERT into the table.
```js
const { data, error } = await supabase
.from('cities')
.insert([
{ name: 'The Shire', country_id: 554 }
])
```
```py
# Not yet implemented
```
## Parameters
-
values
required
|
The values to insert.
-
__namedParameters
required
object
No description provided.
Properties
-
onConflict
required
|
By specifying the `on_conflict` query parameter, you can make UPSERT work on a column(s) that has a UNIQUE constraint.
-
upsert
required
boolean
If `true`, performs an UPSERT.
## Examples
### Create a record
```js
const { data, error } = await supabase
.from('cities')
.insert([
{ name: 'The Shire', country_id: 554 }
])
```
```py
# Not yet implemented
```
### Bulk create
```js
const { data, error } = await supabase
.from('cities')
.insert([
{ name: 'The Shire', country_id: 554 },
{ name: 'Rohan', country_id: 555 },
])
```
```py
# Not yet implemented
```
### Upsert
For upsert, if set to true, primary key columns would need to be included
in the data parameter in order for an update to properly happen. Also, primary keys
used must be natural, not surrogate. There are however,
[workarounds](https://github.com/PostgREST/postgrest/issues/1118)
for surrogate primary keys.
```js
const { data, error } = await supabase
.from('cities')
.insert(
[
{ name: 'The Shire', country_id: 554 },
{ name: 'Rohan', country_id: 555 },
{ name: 'City by the Bay', country_id:840}
],
{ upsert: true })
```
```py
# Not yet implemented
```