Associations & Filtering

Associating records and filtering by associated records

You can access, create and find associated records in Raisely by their UUID.
For example, when you fetch a donation record, you will see the following associated records:

{
  // The uuid of this donation
  "uuid": "ad0ed60e-f22f-408b-8bab-052ee2f85254",
  // Profile that this donation was made to
  "profileUuid": "38686564-229a-4301-93a6-9c396d1873d2",
  // User that made this donation
  "userUuid": "ad0ed60e-f22f-408b-8bab-052ee2f85253",
  // Campaign that this donation was made to
  "campaignUuid": "b9ba99cb-8b10-4a0d-9c45-f01d5a4eb77b",
  // (Optional) The regular donation series this donation is part of
  "subscriptionUuid": "e5c69d8e-040d-40b5-989d-bd314b95b9da",
}

Filtering

When fetching records, you can filter by their associated records. Using the example above, you could find all the donations made by that user to the campaign by doing

/v3/campaigns/b9ba99cb-8b10-4a0d-9c45-f01d5a4eb77b/donations?user=ad0ed60e-f22f-408b-8bab-052ee2f85253

Filtering by Multiple Records
You can specify multiple record UUID's (or paths, see below), separating them with a comma.

Continuing the above example, you could find all records by the above user or user 80025d93-f9df-48bf-b10c-a46cd37ac15b by fetching

/v3/campaigns/b9ba99cb-8b10-4a0d-9c45-f01d5a4eb77b/donations?user=ad0ed60e-f22f-408b-8bab-052ee2f85253,80025d93-f9df-48bf-b10c-a46cd37ac15b

Path Aliasing

Records that have a path attribute (eg Campaigns, Profiles, Tags, Bages and Interaction Categories) can use the path in place of the UUID. Most of the times you would use a UUID to identify one of these records, you can also use a path

/v3/campaigns/my-campaign/donations?user=ad0ed60e-f22f-408b-8bab-052ee2f85253,80025d93-f9df-48bf-b10c-a46cd37ac15b

Range Queries

Range queries let you filter records within a range of values, most commonly these are applied to dates, but they can also be applied to numbers or strings.

You can apply range queries to custom fields as well as built-in fields.

You can create a range query on an attribute by putting the attribute in the query and appending a range suffix to it. For example createdAtAfter=2020-12-31 will return records that were created after midnight on the morning of December 31st.

Note that for dates you need to specify a time in ISO8601 format and it will be interpreted as UTC time. If you omit the time portion of a date, the time is assumed to be 00:00.

SuffixExampleDescription
GTEdonations?lastNameGTE=mGreater than or equal to
Fromprofiles?createdAtFrom=2020-03-30Alias for GTE
LTEprofiles?goalLTE=100000
Todonations?createdAtTo=2020-06-31Alias for LTE
GTprofiles?goalGTE=5000Greater than
(names from m)
AfterAlias for GT
LTdonations?createAtTo=2020-07-01T00:00Less than
BeforeAlias for LT
Notprofiles?pathNot=excluded-pathAll records except the one that matches
Indonations?status=["REFUNDED","OK"]Records with values in the JSON array
Notinprofiles?pathNotin=["path1","path2"]All records except those that match the JSON array
Likeprofiles?nameLike=johnMatch text fields that contain the given text (eg Johnny, Christopher-John)
Match is case insensitive
Presentprofiles?private.customFieldPresent=1Match records where custom field is present and is not null or '' (the empty string)
Absentprofiles?private.customFieldAbsent=1Match records where customField has not been set, or has been set to null or '' (the empty string)

Note: for readability the parameters are not encoded, but when sending a request you will need to encode JSON arrays, eg url = profiles?pathNotin=${encodeURIComponent(["path1","path2"])}

Nested Range Queries

You can also apply range queries to certain nested attributes in associations
Generally speaking, this will only work if you normally see the associated records included when you load a collection of the main record.

For example, when you load a collection of profiles, you also get the user records within, so you can use range queries also on the user records.

You can combine many of the above filters to select exactly the records you need to create complex integrations and components:

GET /v3/profiles?user=uuid1,uuid2&createdAtAfter=2019-12-31&user.private.sourceIn=["webinar","event"]&profile.nameLike=school

Examples

// Find profiles owned by user1 or user2
url = `/v3/profiles?user=${user1.uuid},${user2.uuid}`;

// Filter by nested property
url = `/v3/profiles?parent.typeIn=${encodeURIComponent(["INDIVIDUAL","GROUP"])}`;

// Filter by custom user field memberSince which is a date
url = `/v3/profiles?user.memberSinceBefore=2020-01-01`;

// Interactions with category path of signup, 
// by people with memberSince from start of july
// with a custom field on the interaction called volunteerInterest that is
// not set to "art"
url = `/v3/interactions?category=signup&user.memberSinceFrom=2020-07-01&volunteerInterestNotIn=${encodeURIComponent(['art'])}`