Custom objects
This functionality is in Beta. It is not recommended for use in production applications.
Custom objects allow you to extend DevRev’s data model beyond the standard use-cases served by the native apps like Build and Support. Custom objects allow you to create and manage object types tailored to your specific business needs.
Key concepts
- Leaf type: The base type of a custom object. For example, “campaign”.
- Subtype: A categorization of a leaf type. For example, “promotion” or “advertising” for a “campaign” leaf type.
- Schema fragment: A schema fragment defines the schema for an object.
- Custom fields: User-defined fields that store specific data for your custom object.
- Unique key: A unique identifier for each custom object. This is useful for maintaining idempotency when retrying custom object creation requests.
- ID prefix: A unique prefix used to generate the display ID for the custom object. If the
id_prefix
is “CAMP”, the generated custom object display ID is “C-CAMP-1”. The display ID is used to identify the custom object in the UI, similar to the standard DevRev object display IDs like “ISS-001” for issues.
For more details on customization concepts, please refer to the Customization documentation.
Custom object lifecycle
Let’s say you want to manage marketing campaigns on DevRev. This guide goes through the process of creating a “Campaign” custom object with relevant fields.
All DevRev objects require a schema. First, create a schema for the “Campaign” custom object. Make sure to replace the <TOKEN>
with your API token.
Create a schema and a custom object
Note that for custom object schemas, is_custom_leaf_type
must be set to true
to
differentiate it from standard DevRev object schemas.
Once the schema is created, you can create a custom object of type “Campaign”:
The response of the above API call is the ID of the custom object created.
Note that the id
field in the above response is the system generated unique ID for the custom object.
The sections below provide more details on the available API endpoints for interacting with custom objects.
Get a custom object
To get a custom object, use the custom-objects.get
endpoint:
List custom objects
To list custom objects, use the custom-objects.list
endpoint:
Update a custom object
To update an existing custom object, use the custom-objects.update
endpoint. The
following example updates the budget of the previously created campaign custom object:
Delete a custom object
To delete a custom object, use the custom-objects.delete
endpoint.
The following example deletes the previously created campaign custom object:
Extended use cases
Reference custom objects in other objects
Let’s say you want to reference all the campaigns that have been run for a customer workspace. You can do so by adding a field of type “id” and “id_type: custom_object.campaign” in the account tenant schema.
Add subtypes to custom objects
Adding subtypes to custom objects allows you to categorize and manage your custom objects more effectively. The process is the same as adding subtypes to other standard DevRev objects like issues and tickets.
Let’s say you have run different types of campaigns like social media and email marketing. You can create a subtype for each of these variants. If you want to create a campaign custom object with subtype “social_media”, you can do so as follows: