# Insert Many

Use bulk insert when you want to insert many records into the database with one API call. This can be useful when you import data from any other sources.

{% openapi src="/files/xbBaDgC6opDYR2pG5sLT" path="/{version}/db/{CollectionName}/bulk" method="post" expanded="true" %}
[openapi.json](https://760328771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwSkuCpTNI_AerL8J2a%2Fuploads%2FCpzJktmKXD6FMPSah1nK%2Fopenapi.json?alt=media\&token=854cdd6a-61b2-49a5-99f4-6bc091e5c3d6)
{% endopenapi %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);

var person1 = new Person { Name = "John" };
var person2 = new Person { Name = "Peter" };

var entities = new List<Person> { person1, person2 };

await service.InsertManyAsync(entities, new DatabaseInsertManyOptions());
```

{% hint style="info" %}
Check the information about [entities](broken://pages/-M-6_vT8PDXfwQxGKlF9) on how your class objects are serialized.
{% endhint %}
{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashDb;

class CodemashService
{
    protected CodemashDb $codemashDb;
    protected string $collectionName = '{YOUR_COLLECTION_NAME}';

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $this->codemashDb = new CodemashDb($client);
    }

    public function insertEmployees()
    {
        $employees = [];
        $employees[] = ['name' => 'John', 'email' => 'john@example.com', 'address' => 'New York'];
        $employees[] = ['name' => 'Peter', 'email' => 'peter@example.com', 'address' => 'Los Angeles'];
        
        $responseData = $this->codemashDb->insertMany([
        	'collectionName' => 'employees',
        	'documents' => $employees,
        ]);
    }
}
```

{% 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.codemash.io/api/database/collections/insert-many.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.
