---
title: "Collection.SetCustomField"
slug: "collectionsetcustomfield"
updated: 2024-05-14T14:23:04Z
published: 2024-05-14T14:23:04Z
canonical: "help.mozenda.com/collectionsetcustomfield"
---
> ## 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.SetCustomField
### Description
Set a custom field to a value on a specified collection.
### URL parameters
URL parameter ordering
The **URL parameters** below are listed in the order they should be entered in the API **URL**.
| Name | Required | Type | Description |
| --- | --- | --- | --- |
| `CollectionID` | True | string | Collection ID number. |
| `CustomFieldName` | True | string | Name of the custom field. |
| `CustomFieldValue` | False | string | Value for the custom field. If excluded, the value will return to the default value for the account. |
### Request body (optional)
The **collections** and values of the custom field you want to edit in bulk. You can format these in XML or JSON.
Custom Field Bulk Edit
When updating in bulk you still must specify the single custom field you are working with but can specify multiple `CollectionID`'s and different values.
#### XML
| Name | Required | Type | Description |
| --- | --- | --- | --- |
| `File` | False | XML | A **file** containing the **collections** with values for the custom field. `POST` using Content-Type `multipart/form-data`. |
```
-
1005
asd
-
1006
Vasd
-
1004
Value4
```
#### JSON
| Name | Required | Type | Description |
| --- | --- | --- | --- |
| `POSTDATA` | False | JSON | JSON array of **collections** with values for the custom field. `POST` using Content-Type `application/x-www-form-urlencoded`. |
```
[
{ "CollectionID": "1002", "value": "update2" },
{ "CollectionID": "1003", "Value": "update3" },
{ "CollectionID": "1004", "Value": "update4" },
{ "CollectionID": "1005", "Value": "update5" }
]
```
### Responses
| Name | Type | Description |
| --- | --- | --- |
| `Result` | string | `Success` if the operation was successful. |
| `CollectionID` | string | Collection ID number. |
| `<FieldName>`* | string | The set value for the field. |
*When the user sends a bulk request, it will return an ItemList with each `CollectionID` and `<FieldName>`.
### Sample requests
#### `GET` with collection, custom field and value specified in the URL
```
curl -X GET 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.SetCustomField&CollectionID=1022&CustomFieldName=TestBoy&CustomFieldValue=test'
```
#### `POST` - XML body
```
curl -X POST 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.SetCustomField&CustomFieldName=TestBoy'
-F 'file=@/path/to/file.xml'
```
#### `POST` - JSON body
```
curl -X POST 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.SetCustomField&CustomFieldName=TestBoy'''
-d '[ { "CollectionID": "1002", "value": "update2" }, { "CollectionID": "1003", "Value": "update3" }]'
```
### Sample responses
#### XML
```
Success
-
1002
update2
-
1003
update3
-
1004
update4
-
1005
update5
```
#### JSON (add `&ResponseFormat=JSON`)
```
{
"CollectionID":1022,
"TestBoy":"test",
"JsonResult":{
"Command":"Collection.SetCustomField",
"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
}
}
}
```