---
title: "Collection.AddUpdate - Web Scraping API - Mozenda"
slug: "collectionaddupdate"
description: "Collection.AddUpdate updates an existing collection or adds a new collection to your Mozenda web scraping project. "
updated: 2024-05-14T14:22:15Z
published: 2024-05-14T14:22:15Z
canonical: "help.mozenda.com/collectionaddupdate"
---
> ## Documentation Index
> Fetch the complete documentation index at: https://help.mozenda.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Collection.AddUpdate
### Description
Adds a new **collection** or updates an existing **collection** of the same name with the **fields** and data **items** provided. Accepts same data formats as `Collection.AddItem` bulk insertion. Your app should make a `POST` request to the request **URL**, passing the JSON or XML file as part of a standard form-encoded post body.
### URL parameters
| Name | Required | Type | Description |
| -------------- | -------- | ------ | ----------------------------- |
| `Name` | True | string | Name of the new or updated **collection**. |
### Request body
Accepts same data formats as `Collection.AddItem` bulk insertion. The **fields** and values of the rows you want to add in bulk. You can format these in XML or in JSON.
#### XML
| Name | Required | Type | Description |
| ---- | -------- | ---- | ------------------------------------------------------------ |
| `File` | True | XML | A file containing the **items**, **fields**, and values of the data to be added. `POST` using Content-Type `multipart/form-data`. |
```xml
-
Value1
Value2
-
Value3
Value4
```
#### JSON
| Name | Required | Type | Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| `POSTDATA` | True | JSON | JSON array of objects with **fields** and values of the data to be added. `POST` using Content-Type `application/x-www-form-urlencoded`. |
```json
[
{ "Field1": "Value1", "Field2": "Value2" },
{ "Field1": "Value3", "Field2": "Value4" }
]
```
#### Responses
| Name | Type | Description |
| --------------- | ------- | ------------------------------------------------------------ |
| `Result` | string | `Success` if the operation was successful. |
| `CollectionID` | numeric | Unique identifier for the new or updated **collection**. |
| `CollectionName` | string | Name for the new or updated **collection**. |
| `CollectionAdded` | boolean | Whether or not a new **collection** was added. |
| `FieldsAdded` | numeric | Total **fields** added. |
| `ItemsAdded` | numeric | Total **items** added. |
### Sample requests
#### XML
```bash
curl -X POST "https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.AddUpdate&Name=MyUpdatedCollection" \
-F "file=@/path/to/file.xml"
```
#### JSON
```bash
curl -X POST "https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.AddUpdate&Name=MyUpdatedCollection" \
-d '[{"Field1": 1, "Field2": 2}, {"Field1": 3, "Field2": 4}]'
```
#### Sample responses
#### XML
```xml
Success
1201
AddUpdateCollectionJSON
True
3
8
```
#### JSON (add `&ResponseFormat=JSON`)
```json
{
"CollectionID": 5356,
"CollectionName": "testapi",
"CollectionAdded": false,
"FieldsAdded": 0,
"ItemsAdded": 2,
"JsonResult": {
"Command": "Collection.AddUpdate",
"AutoLoggedIn": false,
"WebConsoleKey": "",
"Result": "Success",
"ErrorCode": "",
"ErrorDescription": "",
"ErrorList": [],
"ExecutionTime": {
"Ticks": 0,
"Days": 0,
"Hours": 0,
"Milliseconds": 0,
"Minutes": 0,
"Seconds": 0,
"TotalDays": 0,
"TotalHours": 0,
"TotalMilliseconds": 0,
"TotalMinutes": 0,
"TotalSeconds": 0
}
}
}
```