documentation-samples

User Defined Fields with the API

Several API resources for our v2 REST API have a user-defined-fields attribute. You can make GET requests to find UDFs and POST/PATCH requests to set or update UDFs:

Examples:

For example, let’s say you wanted to update the birthday user defined field on a customer’s address. You could make an API call like this

curl -X PATCH "https://api.subscribepro.com/services/v2/addresses/123" \
-H 'Authorization: Bearer XXXXXX' \
-d '[{"op": "add","path": "/user_defined_fields/birthday","value": "1985-01-01"}]' 

Then, you could get the customer’s address data including that UDF value with an API request like this:

curl -X GET "https://api.subscribepro.com/services/v2/addresses/123" \
-H 'Authorization: Bearer XXXXXX' 

Validation

When User Defined Fields are set or updated via the API, we only validate that the UDF data is valid JSON. When UDF fields with the “Validate Data” setting are edited through the SubscribePro application, we will enforce the validation rules for that field.