Values on a member
A member’s custom field values are returned in itsmetafields object, under custom, keyed by each field’s key:
metafields is returned when reading, creating, or updating a single member. When browsing members, it’s returned when ?include=metafields is requested. It’s left out for members with no custom field values, and values of archived fields are left out until the field is restored.
Metafields are grouped by namespace, and custom is the namespace for the fields a site defines. It’s the only namespace today. More may be added in future, so it’s recommended to read the namespaces you know and ignore any others.
Setting values
Values are set by includingmetafields when creating or updating a member. When updating, values are merged, not replaced. Only the fields included in metafields.custom are changed, and for an address, only the parts included. A request without metafields leaves all values unchanged.
To clear a value, set it to null. Setting a part of an address to null clears just that part. An empty string or an empty list is refused rather than clearing the value.
Field types
The shape of a value depends on the type of its field:
Text is trimmed before it’s checked, and text left empty is refused. A list value keeps the options a member picked, even if the publisher later removes one of them from the field.
Values are checked against their field when a member is created or updated. Values for a field that doesn’t exist or is archived are refused. If any value is invalid, nothing in the request is saved, and the API returns a
422 error whose property names the value, for example metafields.custom.company, or metafields.custom.shipping_address.country for one part of an address.
