Overview
A Custom Object is a schema-less, flexible data structure that can be linked to a specific account. It dynamically adapts, allowing additional fields or data formats to be added as needed.
Custom Objects allow you to analyze and retrieve insights into how data is stored within your LoginRadius Cloud Directory. They provide a flexible, schema-less structure, enabling dynamic data storage and customization based on your needs.
Note: To use Custom Object APIs, contact LoginRadius Support to have custom objects added to your account and the data indexed according to your requirements.
Running Custom Objects API
You need to be informed of the following information to run the Custom Objects API.
- Base URL
- Schema Definition
- Formatting Custom Object Queries
- Rules & Groups
- Example Query
The following is the base URL for all API requests:
https://cloud-api.loginradius.com/customobject
The schema must specify each field type, including subfields within nested objects, and identify required fields that should be queryable. Supported types include string, date, integer, double, float, short, long, text, boolean, object, and nested (array of objects).
The type should be the corresponding basic type for arrays containing strings, integers, texts, or booleans. For example, to query Key1: [1, 2, 3]
, the type should be set as integer
.
Additionally, nested types must include type definitions for all their subfields.
The LoginRadius query notation supports multiple terms using AND/OR clauses and grouped clauses.
A group operator is only required when multiple rules are present, not for a single rule.
Each key has an associated type, which the rule object uses to construct the database query.
- A query object should have at least one group, or it can be
{}
, which retrieves all the data based on theFrom
andTo
values. - Each group can have one or more rules and sub-groups.
- Each rule should have the following:
- Field name
- Operator
- Value (based on the field type)
Please make sure of the following for defining Rules & Groups:
- The query object should have at least one group.
- Each group can have one or more rules and sub-groups.
- Each group will have an operator (AND or OR) and an array of rules or sub-groups.
- This operator is not required for a single rule.
- Each rule should have the Field name, operator, and value based on the field type.
Here is an example query for reference:
"group": {
"operator": "AND",
"rules": [
<rule>,
<rule>,
<sub-group>
]
}
Supported Types and Corresponding Operators/Values
The following are the different types of operators based on the type and corresponding values they can have
- Integer/Date
- String/Array of Strings
- Boolean
- Text
- Objects
- Array of Objects
Supported Operators: >
, >=
, <
, <=
, BETWEEN
, =
, !=
Description: These operators are used for fields with integer or date types.
Example:
Age > 18
DateCreated BETWEEN '2022-01-01' AND '2022-12-31'
Supported Operators: =
, !=
Description: These operators are used for fields with string types or arrays of strings.
Example:
Role = 'Admin'
Tags != 'Inactive'
Supported Operators: =
, !=
Description: These operators are used for fields with boolean types.
Example:
IsActive = true
IsDeleted != true
Supported Operators: Contains
, Not_Contains
Description: These operators are used for fields with text types.
Example:
Description Contains 'LoginRadius'
Notes Not_Contains 'Deprecated'
Description: Querying objects depends on the sub-fields. Refer to the documentation for details.
Example:
- Querying nested fields like
CustomObject.key1 = 'value1'
.
Description: Querying arrays of objects depends on the sub-fields. Refer to the documentation for details.
Example:
- Querying nested fields within an array like
CustomObject.key4.Value = 'vimeo'
.
Sample and Formats
Please refer to the Format of Custom Objects and Schema of the Custom Objects for reference.
- Format of Custom Object
- Sample Custom Object Schema
Here is a sample format of Custom Objects:
{
"IsActive": true,
"DateCreated": "2018-01-31T09:02:40.290Z",
"DateModified": "2018-01-31T09:02:40.290Z",
"IsDeleted": false,
"Uid": 123456,
"CustomObject": <Actual Custom Object>
}
Internal fields include:
IsActive
(boolean)DateModified
(date)DateCreated
(date)IsDeleted
(boolean)Uid
(string)
CustomObject keys and their types are retrieved from the Schema Definition.
Here is a sample Custom Object Schema:
{
"title": "CustomObject Title",
"type": "object",
"properties": {
"key1": { "type": "string" },
"key2": { "type": "string" },
"key3": { "type": "integer" },
"key4": {
"type": "nested",
"properties": {
"Value": { "type": "string" },
"Type": { "type": "string" }
}
},
"key5": {
"properties": {
"Code": { "type": "string" },
"Name": { "type": "string" }
}
},
"key6": { "type": "text" }
},
"required": [
"key1",
"key2",
"key3",
"key4.Value",
"key4.Type",
"key5.Code",
"key5.Name",
"key6"
]
}
Note: If the Custom Object contains fields other than those specified in the schema, they are not queryable.
Querying Basic Fields
Here are a few examples of querying basic fields:
Query for searching Custom Objects where the “State” field of Custom Object has a value of “British Columbia”
"rule": {
"name": "CustomObject.State",
"operator": "=",
"value": "British Columbia"
}
Query for searching Custom Objects where the “Price” field of Custom Object is between “200” and “500”
"rule": {
"name": "CustomObject.Price",
"operator": "BETWEEN",
"value": [200, 500]
}
Note for Array of Strings/Integers: Querying a field that contains an array of strings will return the document if the array includes the specified value. For example, if a document has a "Roles" field with values ['Admin', 'Developer', 'QA'], a query for Roles = Admin or Roles = Developer will return the document. However, a query for Roles = Business will not return it.
Note for Range Fields: For the BETWEEN operator, the value should be an array. The first value will be used as FROM and the second as TO. The values are inclusive. Example "value": [20, 50] translates to value being in between 20 & 50(inclusive). The range is inclusive.
Querying Objects
You can use dot notation to query nested fields within objects.
Example: Object Structure
"CustomObject": {
"key1": ...,
"key2": ...,
"key3": ...,
"key4": ...,
"key5": {
"Code": "Dr",
"Name": "Doctor"
}
}
Example Query
To filter records where CustomObject.key5.Code is "Dr", use the following rule:
"rule": {
"name": "CustomObject.key5.Code",
"operator": "=",
"value": "Dr"
}
This query will return all records where the Code field inside key5 has the value "Dr".
Querying an Array of Objects
You can use dot notation to query fields within an array of objects. The query will return results where at least one object in the array meets the specified condition.
Example: Array of Objects Structure
"CustomObject": {
"key1": ...,
"key2": ...,
"key3": ...,
"key4": [
{
"Type": "Primary",
"Value": "youtube"
},
{
"Type": "Secondary",
"Value": "vimeo"
}
],
"key5": ...
}
Example Queries
Querying for specific values in CustomObject.key4:
{
"name": "CustomObject.key4.Value",
"operator": "=",
"value": "vimeo"
}
{
"name": "CustomObject.key4.Type",
"operator": "=",
"value": "Primary"
}
These queries will return records where:
-
At least one object in key4 has Value = "vimeo".
-
At least one object in key4 has Type = "Primary".
Note: Ensure the sub-field type is correct before querying.
Combining Rules into a Group
A group can contain one or more rules and sub-groups. Each group requires an operator (AND or OR) and an array of rules or sub-groups.
Group Structure
"group": {
"operator": "AND",
"rules": [<rule>, <rule>, <sub-group>]
}
Example: Complex Query Group
"group": {
"operator": "AND",
"rules": [
{
"name": "IsActive",
"operator": "=",
"value": true
},
{
"name": "DateCreated",
"operator": ">",
"value": "2017-01-01"
},
{
"group": {
"operator": "OR",
"rules": [
{
"name": "CustomObject.key1",
"operator": "=",
"value": "value1"
},
{
"name": "CustomObject.key2",
"operator": "=",
"value": "value2"
}
]
}
}
]
}
Example Query: Filtering Custom Objects
Retrieve all Custom Objects created between 2017-01-01 and 2017-12-31 while ensuring:
-
IsActive is true
-
DateCreated is after 2017-01-01
-
Either CustomObject.key1 = "value1" OR CustomObject.key2 = "value2"
Query Representation:
(IsActive = true) AND (DateCreated > 2017-01-01) AND (CustomObject.key1 = value1 OR CustomObject.key2 = value2)
API Query Example
{
"from": "2017-01-01",
"to": "2017-12-31",
"q": {
"group": {
"operator": "AND",
"rules": [
{
"name": "IsActive",
"operator": "=",
"value": true
},
{
"name": "DateCreated",
"operator": ">",
"value": "2017-01-01"
},
{
"group": {
"operator": "OR",
"rules": [
{
"name": "CustomObject.key1",
"operator": "=",
"value": "value1"
},
{
"name": "CustomObject.key2",
"operator": "=",
"value": "value2"
}
]
}
}
]
}
}
}
Note: If the object structure changes (e.g., a new field is added), you can still use the Data Query Tool to search based on the updated field. However, you must update the schema before querying the new field.
To reindex data with the updated schema, please contact the LoginRadius Support Team.
Custom Objects with Identity APIs
The Custom Object with Identity API retrieves a customer's identity information and associated Custom Object data in a single API call.
Note: Before leveraging these APIs, contact LoginRadius Support to ensure you have set the schema for the Custom Object and indexed it. You can review the set schema for your Custom Object in our Admin Console.
We are providing the following APIs in this section:
- User Identity with Custom Object API: This API retrieves customer profiles with custom object data attached to the profile.
- Get User Identity with Custom Object: This API is used to get the next batch of identity and custom objects with Pagination ID.
- Base URL
- Example Query
Following is the Base URL for all API requests:
https://cloud-api.loginradius.com/identity/customobject
Retrieve all users created between 2018-01-01
and 2020-02-06
with an age of 16 years or older:
{
"from": "2018-01-01",
"to": "2020-02-06",
"q": {
"group": {
"operator": "AND",
"rules": [
{
"name": "Age",
"operator": ">=",
"value": 16
}
]
}
},
"size": 1000
}