Update or add custom fields to a list
Parameter |
Description |
Required |
list_id | ID of the list to add to | YES |
field_n | Custom field value where n is an integer between 1 and 10. You can also use the names of the custom fields you have chosen for your list, e.g. field.birthday. | YES (at least 1) |
Example
curl https://api.transmitsms.com/add-field-to-list.json \
-u 2e24c1cbdd987221e165d543f34b84bf:secret \
-d list_id=1234567 \
-d 'field_1=Sydney'
JSON Response |
XML Response |
{ custom_1: "Sydney", id: 1234567, error: { code: "SUCCESS", description: "OK" } } |
<?xmlversion="1.0"encoding="UTF-8"?> <response> <custom_1>Sydney</custom_1> <id>1234567</id> <error> <code>SUCCESS</code> <description>OK</description> </error> </response> |
Error Codes
Code |
Header |
Description |
KEY_NO_EXISTS | 400 | List with such id is not existing |
MISSING_PARAM | 400 | Field param is missing (eg. field_n) |
PHP Examples
<?php include'../../APIClient2.php'; $api=new transmitsmsAPI("API_KEY",'API_SECRET'); $customFields=array('custom1_value','custom2_value'); $result=$api->addFieldToList(6195,$customFields); if($result->error->code=='SUCCESS') { echo "Custom field(s) added"; } else { echo "Error: {$result->error->description}"; }