Skip to content

Commit b26dec3

Browse files
committed
Add extended use cases
1 parent 6e378f0 commit b26dec3

File tree

1 file changed

+91
-21
lines changed

1 file changed

+91
-21
lines changed

fern/docs/pages/custom-objects.mdx

Lines changed: 91 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
## Table of contents
22

3-
1. [Introduction](#custom-objects)
4-
2. [Quick start](#quick-start)
5-
- [Create a Schema and a custom object](#create-a-schema-and-a-custom-object)
3+
* [Introduction](#custom-objects)
4+
* [Quick start](#quick-start)
5+
- [Create a schema and a custom object](#create-a-schema-and-a-custom-object)
66
- [Get a custom object](#get-a-custom-object)
77
- [List custom objects](#list-custom-objects)
88
- [Update a custom object](#update-a-custom-object)
99
- [Delete a custom object](#delete-a-custom-object)
10-
3. [Key concepts](#key-concepts)
11-
4. [Custom object lifecycle](#custom-object-lifecycle)
10+
* [Key concepts](#key-concepts)
11+
* [Custom object lifecycle](#custom-object-lifecycle)
12+
* [Extended use cases](#extended-use-cases)
13+
- [Referencing custom objects in other objects](#referencing-custom-objects-in-other-objects)
14+
- [Adding subtypes to custom objects](#adding-subtypes-to-custom-objects)
1215

1316
- - -
1417

1518
## Introduction
16-
Custom objects allow you to extend DevRev's data model beyond the standard use-cases served by the native apps like Build and Support.
17-
Custom objects allow you to create and manage object types tailored to your specific business needs.
19+
Custom objects allow you to extend DevRev's data model beyond the standard use-cases
20+
served by the native apps like Build and Support. Custom objects allow you to create
21+
and manage object types tailored to your specific business needs.
1822

1923
## Quick start
2024

@@ -78,40 +82,43 @@ curl --location 'https://api.devrev.ai/custom-objects.create' \
7882
--header 'Authorization: <YOUR_API_TOKEN>' \
7983
--data '{
8084
"leaf_type": "campaign",
85+
"unique_key": "CAMP-001",
86+
"custom_schema_spec": {
87+
"tenant_fragment": true
88+
},
8189
"custom_fields": {
8290
"tnt__name": "Summer Sale 2023",
8391
"tnt__start_date": "2023-06-01",
8492
"tnt__end_date": "2023-08-31",
8593
"tnt__budget": 10000,
8694
"tnt__target_audience": "Professionals"
87-
},
88-
"unique_key": "CAMP-001"
95+
}
8996
}'
9097
```
9198

9299
The response of the above API call will be the ID of the custom object created.
93100
```
94101
{
95102
"custom_object": {
96-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1",
103+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1",
97104
"created_by": {...},
98105
"created_date": "2024-10-01T07:02:58.958Z",
99106
"modified_by": {...},
100107
"modified_date": "2024-10-01T07:02:58.958Z",
101108
"display_id": "C-CAMP-1",
102109
"leaf_type": "campaign",
103110
"unique_key": "CAMP-001"
104-
"stock_schema_fragment": "don:core:dvrv-us-1:stock_sf/1522526",
111+
"stock_schema_fragment": "don:core:dvrv-us-1:stock_sf/1",
105112
"custom_schema_fragments": [
106-
"don:core:dvrv-us-1:devo/11FVC3ScK:tenant_fragment/261"
113+
"don:core:dvrv-us-1:devo/demo:tenant_fragment/1"
107114
],
108115
"custom_fields": {
109-
"tnt__budget": 10000,
110-
"tnt__end_date": "2023-08-31",
111116
"tnt__name": "Summer Sale 2023",
112117
"tnt__start_date": "2023-06-01",
118+
"tnt__end_date": "2023-08-31",
119+
"tnt__budget": 10000,
113120
"tnt__target_audience": "Professionals"
114-
},
121+
}
115122
}
116123
}
117124
```
@@ -130,7 +137,7 @@ curl --location 'https://api.devrev.ai/custom-objects.get' \
130137
--header 'Accept: application/json' \
131138
--header 'Authorization: <YOUR_API_TOKEN>' \
132139
--data '{
133-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1"
140+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1"
134141
}'
135142
```
136143

@@ -155,16 +162,16 @@ curl --location 'https://api.devrev.ai/custom-objects.list' \
155162

156163
### Update a custom object
157164

158-
To update an existing custom object, use the `custom-objects.update` endpoint.
159-
The following example updates the budget of the previously created campaign custom object:
165+
To update an existing custom object, use the `custom-objects.update` endpoint. The
166+
following example updates the budget of the previously created campaign custom object:
160167

161168
```
162169
curl --location 'https://api.devrev.ai/custom-objects.update' \
163170
--header 'Content-Type: application/json' \
164171
--header 'Accept: application/json' \
165172
--header 'Authorization: <YOUR_API_TOKEN>' \
166173
--data '{
167-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1",
174+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1",
168175
"custom_fields": {
169176
"tnt__budget": 15000
170177
}
@@ -182,7 +189,7 @@ curl --location 'https://api.devrev.ai/custom-objects.delete' \
182189
--header 'Accept: application/json' \
183190
--header 'Authorization: <YOUR_API_TOKEN>' \
184191
--data '{
185-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1"
192+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1"
186193
}'
187194
```
188195

@@ -193,10 +200,73 @@ curl --location 'https://api.devrev.ai/custom-objects.delete' \
193200
3. **Custom Fields**: User-defined fields that store specific data for your custom object.
194201
4. **Unique Key**: A unique identifier for each custom object, useful for maintaining idempotency.
195202

196-
For more details on customization concepts, please refer to the [Customization](./object-customization) documentation.
203+
For more details on customization concepts, please refer to the
204+
[Customization](./object-customization) documentation.
197205

198206
## Custom object lifecycle
199207

200208
1. **Creation**: Define the leaf type, subtype (optional), and custom fields for your custom object.
201209
2. **Usage**: Create, update, and query custom objects as needed in your workflows.
202210
3. **Management**: Modify the schema of the custom object as your needs evolve.
211+
212+
## Extended use cases
213+
214+
### Referencing custom objects in other objects
215+
Let's say you want to reference all the campaigns that have been run for a customer
216+
workspace. You can do so by adding a field of type "id" and "id_type: custom_object.campaign"
217+
in the account object.
218+
219+
```
220+
curl --location 'https://api.devrev.ai/schemas.custom.set' \
221+
--header 'Content-Type: application/json' \
222+
--header 'Accept: application/json' \
223+
--header 'Authorization: <YOUR_API_TOKEN>' \
224+
--data '{
225+
"type": "tenant_fragment",
226+
"description": "Tenant attributes for Account",
227+
"leaf_type": "account",
228+
"fields": [
229+
{
230+
"name": "campaigns",
231+
"field_type": "array",
232+
"base_type": "id",
233+
"id_type": "custom_object.campaign",
234+
},
235+
... // other fields
236+
],
237+
}'
238+
```
239+
240+
### Adding subtypes to custom objects
241+
Adding subtypes to custom objects allows you to categorize and manage your custom
242+
objects more effectively. The process is the same as adding subtypes to other standard
243+
DevRev objects like issues and tickets.
244+
245+
Let's say you have run different types of campaigns like social media and email
246+
marketing. You can create a subtype for each of these variants. If you want to create a
247+
campaign custom object with subtype "social_media", you can do so as follows:
248+
249+
```
250+
curl --location 'https://api.devrev.ai/custom-objects.create' \
251+
--header 'Content-Type: application/json' \
252+
--header 'Accept: application/json' \
253+
--header 'Authorization: <YOUR_API_TOKEN>' \
254+
--data '{
255+
"leaf_type": "campaign",
256+
"custom_schema_spec": {
257+
"subtype": "social_media",
258+
"tenant_fragment": true
259+
},
260+
"custom_fields": {
261+
"tnt__name": "Summer Sale 2023",
262+
"tnt__start_date": "2023-06-01",
263+
"tnt__end_date": "2023-08-31",
264+
"tnt__budget": 10000,
265+
"tnt__target_audience": "Professionals",
266+
"ctype__social_media_platform": "Facebook",
267+
"ctype__post_id": "1234567890"
268+
},
269+
"unique_key": "CAMP-001"
270+
}'
271+
```
272+

0 commit comments

Comments
 (0)