Request Format
To create a Custom Attribute
, you must send a JSON:API spec JSON object. The list of attributes and relationships can be found in BODY PARAMS section
The Resource
Custom Attributes
can be created for a select number of resources. The current list of supported resources is available in the data.relationships. custom_attributable.data.type
field documentation in BODY PARAMS section.
The Custom Field
Custom Field
Before creating a Custom Attribute
for a resource, decide which Custom Field
the attribute will be for. As described here, a Custom Attribute
stores a value for a predefined field (CustomField
) which can be considered a label or key.
If you haven't yet defined any Custom Fields
, there are two ways to do so:
- Use the Create Custom Field API endpoint.
- In the UI - refer to this help guide.
Custom Field
resource type
Please bear in mind that
Custom Field
s are defined for a specific resource type (e.g.job
).
resource_type
of theCustom Field
must match the type of the resource that you want to create a newCustom Attribute
for.Example
When
CustomField.resource_type
isjob
then it can only be used to createCustomAttributes
for Jobs (custom_attributable.type == jobs
)
After setting up your Custom Field
s, you can create Custom Attribute
s for them. This requires knowing the id
of the Custom Field
, which you can obtain from the List Custom Fields endpoint.
The Value Type
Custom Attribute
s can support multiple data types.
Important
The data type stored in the
Custom Attribute
must match the data type of the associatedCustom Field
(field_type
).
To check the data type of a Custom Field
for which you wish to create a Custom Attribute
, you can:
- Fetch the
Custom Field
using Fetch Custom Field or List Custom Fields and check thefield_type
attribute. - Open the
Custom Field
for editing in the UI (navigate to the Custom Fields page from the Pinpoint settings menu).
The list of supported Custom Field
types can be found here.
When you know the data type, fill in the corresponding _value
field when creating a new Custom Attribute
. Leave the rest of the _value
fields empty.
Example
If the
field_type
of theCustom Field
you wish to create aCustom Attribute
for isboolean
, then place the value in theboolean_value
attribute.
Uniqueness
There can only be one Custom Attribute
for a specific Custom Field
and a given resource.
If you need to replace an existing one, please Update Custom Attribute or Delete Custom Attribute and create a new one.
Summary
When creating a Custom Attribute
make sure that:
Custom Field
resource_type
matches the type of the resource (custom_attributable
) for which you are creating theCustom Attribute
- You fill the
_value
attribute which corresponds to thefield_type
of the associatedCustom Field
and leave the rest of the attributes empty.