Skip to main content
SecurityTrax

User Defined Fields (UDFS)

Overview

User defined fields allow you to create new fields to store data.

Creating UDFS

Getting list of available UDFS

You can retrieve the available UDFS with a GET request to /user/v1/admin_udfs

Creating new UDFS

New UDFS can be created through a POST request to /user/v1/admin_udfs with a body like the one below:

{
  "data": {
    "type": "admin_udfs",
    "attributes": {
      "name": "string",
      "object_type": "customer",
      "value_type": "input",
      "value_info": "string",
      "hide_in_ui": true
    }
  }
}

Note: The first time you create a new UDF you’ll need to create a resource_type relationship before using it. To create that relationship you will send a POST request to /user/v1/admin_udfs/:id/relationships/resource_types with a body like the one below:

{
  "data": [
    {
      "id": "customers",
      "type": "resource_types"
    }
  ]
}

Adding data to UDFS on customer/lead

There are two potential scenarios in which you may edit a UDF value for a customer/lead.

1. The UDF value has never existed for the customer/lead. In this case you’ll want to POST to /user/v1/udfs with a body like the one below:

{
    "data": {
        "type": "udfs",
        "attributes": {
            "value": "foo"
        },
        "relationships": {
            "admin_udf": {
                "data": {
                    "id": "6",
                    "type": "admin_udfs"
                }
            },
            "customer": {
                "data": {
                    "id": "35325",
                    "type": "customers"
                }
            }
        }
    }
}

The admin_udf.data.id will be an id from the list retrieved from the GET request to /user/v1/admin_udfs. The customer.data.id will the be customer/lead id.

2. The UDF value has existed for the customer/lead (i.e. you’re editing the value). In this case you’ll need the ID of the application of the UDF. This can be obtained in the body of the response to a GET request to /user/v1/customers/{id}/relationships/udfs (truncated snippet of an example response showing the ID below).

{
    "data": [
        {
            "meta": {
                "is_slim_model": false
            },
            "type": "udfs",
            "id": "{\\"object_id\\":\\"35325\\",\\"udf_id\\":\\"6\\"}",
            "attributes": {
                "value": "blah",
                "status": "active"
            },
            "links": {
...

After obtaining the ID you’d PATCH to /user/v1/udfs/{id obtained from GET request} with the same body as in #1 above, excluding the “relationships” (so you’d just be editing the data.attributes.value value).

{
    "data": {
        "type": "udfs",
        "attributes": {
            "value": "foo"
        }
    }
}

The UDFs are site-specific.

  • Was this article helpful?