# Batch Endpoints

You can use batch endpoints to insert, delete or read multiple entries at once. These three endpoints are only available when running Stream on your backend.

### Upsert

Upsert allows you to insert or update up to 1000 entries with a single API call. The payload is an array of entries.
Entries that already exist (same ID) will be updated with the new version.

| name       | type   | description                                                         | default | optional |
| ---------- | ------ | ------------------------------------------------------------------- | ------- | -------- |
| collection | string | The name of the collection                                          | -       |          |
| entry_id   | string | The id of the entry, if not given an ID will be generated by Stream | -       | ✓        |
| data       | object | The data related to the user                                        | -       |          |

<Tabs>

```csharp label="C#"
// Update the information for user with ID 123
var obj = new CollectionObject("123");
obj.SetData("name", "johndoe");
obj.SetData("favorite_color", "blue");
await client.Collections.UpsertAsync("user", obj);
```

```js label="JavaScript"
client.collections.upsert("user", [
  { id: "123", name: "johndoe", favorite_color: "blue" },
]);
```

```python label="Python"
# Update the information for user with id 123
client.collections.upsert('user', [{'id': '123', 'username': 'johndoe', 'favorite_color': 'blue'}])
```

```ruby label="Ruby"
# Update the information for user with ID 123
client.collections.upsert('user', [{id: '123', name: 'johndoe', favorite_color: 'blue'}])
```

```php label="PHP"
// Update the information for user with id 123
$client-&gt;collections()-&gt;upsert('user', [
  [
    'id' =&gt; '123',
    'username' =&gt; 'johndoe',
    'favorite_color' =&gt; 'blue',
  ]
]);
```

```java label="Java"
// Update the information for user with ID 123
client.collections().upsert("user", new CollectionData("123")
    .set("username", "johndoe")
    .set("favorite_color", "blue")).join();
```

```go label="Go"
// Update the information for collection users with ID 123
	object := stream.CollectionObject{
		ID: "123",
		Data: map[string]any{
			"name":      "john doe",
			"favorite_color": "blue",
		},
	}
	resp, err := client.Collections().Upsert(context.TODO(), "users", object)
	if err != nil {
		panic(err)
	}
```

</Tabs>

### Select

This method allows you to retrieve up to 1000 entries by ID.

| name        | type           | description                                                                        | default | optional |
| ----------- | -------------- | ---------------------------------------------------------------------------------- | ------- | -------- |
| foreign_ids | list of string | The list of collection:id entries to retrieve (eg. ["visitor:123", "visitor:124"]) | -       | ✓        |
| data        | object         | The data related to the user                                                       | -       |          |

<Tabs>

```csharp label="C#"
// select the entries with ID 123 and 124 from items collection
var objects = await client.Collections.SelectAsync("items", "123", "124");
```

```js label="JavaScript"
// select the entries with ID 123 and 124 from items collection
let objects = await client.collections.select("items", ["123", "124"]);
```

```python label="Python"
# select the entries with ID 123 and 124 from items collection
objects = client.collections.select('items', ["123", "124"])
```

```ruby label="Ruby"
# select the entries with ID 123 and 124 from items collection
objects = client.collections.select('items', ['123', '124'])
```

```php label="PHP"
// select the entries with ID 123 and 124 from items collection
$objects = $client-&gt;collections()-&gt;select('items', ['123', '124']);
```

```java label="Java"
// select the entries with ID 123 and 124 from items collection
List<collectiondata> objects = client.collections().select("items", "123", "124").join();</collectiondata>
```

```go label="Go"
// select the entries with ID 123 and 124 from items collection
	resp, err := client.Collections().Select(context.TODO(), "items", "123", "124")
	if err != nil {
		panic(err)
	}
```

</Tabs>

### Delete Many

This method allows you to delete up to 1000 entries by ID.

| name       | type            | description                | default | optional |
| ---------- | --------------- | -------------------------- | ------- | -------- |
| collection | string          | The name of the collection | -       |          |
| ids        | list of strings | The list of id to remove   | -       | ✓        |

<Tabs>

```csharp label="C#"
// delete the entries with ID 123 and 124 from visitor collection
await client.Collections.DeleteAsync("visitor", "123", "124");
```

```js label="JavaScript"
// delete the entries with ID 123 and 124 from visitor collection
client.collections.deleteMany("visitor", ["123", "124"]);
```

```python label="Python"
# delete the entries with ID 123 and 124 from visitor collection
response = client.collections.delete_many('visitor', ["123", "124"])
```

```ruby label="Ruby"
# delete the entries with ID 123 and 124 from visitor collection
client.collections.delete_many('visitor', ['123', '124'])
```

```php label="PHP"
// delete the entries with ID 123 and 124 from visitor collection
$response = $client-&gt;collections()-&gt;deleteMany('visitor', ["123", "124"]);
```

```java label="Java"
// delete the entries with ID 123 and 124 from visitor collection
client.collections().deleteMany("visitor", "123", "124").join();
```

```go label="Go"
// delete the entries with ID 123 and 124 from visitor collection
	resp, err := client.Collections().DeleteMany(context.TODO(), "visitor", "123", "124")
	if err != nil {
		panic(err)
	}
```

</Tabs>

<admonition type="info">

When you delete an entry from a collection any references will be converted to a missing reference error when reading feeds with [enrichment](/activity-feeds/docs/node/v2/enrichment/).

</admonition>


---

This page was last updated at 2026-05-22T16:31:50.117Z.

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/javascript/v2/collections-batch/](https://getstream.io/activity-feeds/docs/javascript/v2/collections-batch/).