Skip to content

Commit 3d81199

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

File tree

1 file changed

+84
-17
lines changed

1 file changed

+84
-17
lines changed

fern/docs/pages/custom-objects.mdx

Lines changed: 84 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
1. [Introduction](#custom-objects)
44
2. [Quick start](#quick-start)
5-
- [Create a Schema and a custom object](#create-a-schema-and-a-custom-object)
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)
@@ -13,8 +13,9 @@
1313
- - -
1414

1515
## 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.
16+
Custom objects allow you to extend DevRev's data model beyond the standard use-cases
17+
served by the native apps like Build and Support. Custom objects allow you to create
18+
and manage object types tailored to your specific business needs.
1819

1920
## Quick start
2021

@@ -78,40 +79,43 @@ curl --location 'https://api.devrev.ai/custom-objects.create' \
7879
--header 'Authorization: <YOUR_API_TOKEN>' \
7980
--data '{
8081
"leaf_type": "campaign",
82+
"unique_key": "CAMP-001",
83+
"custom_schema_spec": {
84+
"tenant_fragment": true
85+
},
8186
"custom_fields": {
8287
"tnt__name": "Summer Sale 2023",
8388
"tnt__start_date": "2023-06-01",
8489
"tnt__end_date": "2023-08-31",
8590
"tnt__budget": 10000,
8691
"tnt__target_audience": "Professionals"
87-
},
88-
"unique_key": "CAMP-001"
92+
}
8993
}'
9094
```
9195

9296
The response of the above API call will be the ID of the custom object created.
9397
```
9498
{
9599
"custom_object": {
96-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1",
100+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1",
97101
"created_by": {...},
98102
"created_date": "2024-10-01T07:02:58.958Z",
99103
"modified_by": {...},
100104
"modified_date": "2024-10-01T07:02:58.958Z",
101105
"display_id": "C-CAMP-1",
102106
"leaf_type": "campaign",
103107
"unique_key": "CAMP-001"
104-
"stock_schema_fragment": "don:core:dvrv-us-1:stock_sf/1522526",
108+
"stock_schema_fragment": "don:core:dvrv-us-1:stock_sf/1",
105109
"custom_schema_fragments": [
106-
"don:core:dvrv-us-1:devo/11FVC3ScK:tenant_fragment/261"
110+
"don:core:dvrv-us-1:devo/demo:tenant_fragment/1"
107111
],
108112
"custom_fields": {
109-
"tnt__budget": 10000,
110-
"tnt__end_date": "2023-08-31",
111113
"tnt__name": "Summer Sale 2023",
112114
"tnt__start_date": "2023-06-01",
115+
"tnt__end_date": "2023-08-31",
116+
"tnt__budget": 10000,
113117
"tnt__target_audience": "Professionals"
114-
},
118+
}
115119
}
116120
}
117121
```
@@ -130,7 +134,7 @@ curl --location 'https://api.devrev.ai/custom-objects.get' \
130134
--header 'Accept: application/json' \
131135
--header 'Authorization: <YOUR_API_TOKEN>' \
132136
--data '{
133-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1"
137+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1"
134138
}'
135139
```
136140

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

156160
### Update a custom object
157161

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:
162+
To update an existing custom object, use the `custom-objects.update` endpoint. The
163+
following example updates the budget of the previously created campaign custom object:
160164

161165
```
162166
curl --location 'https://api.devrev.ai/custom-objects.update' \
163167
--header 'Content-Type: application/json' \
164168
--header 'Accept: application/json' \
165169
--header 'Authorization: <YOUR_API_TOKEN>' \
166170
--data '{
167-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1",
171+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1",
168172
"custom_fields": {
169173
"tnt__budget": 15000
170174
}
@@ -182,7 +186,7 @@ curl --location 'https://api.devrev.ai/custom-objects.delete' \
182186
--header 'Accept: application/json' \
183187
--header 'Authorization: <YOUR_API_TOKEN>' \
184188
--data '{
185-
"id": "don:core:dvrv-us-1:devo/11FVC3ScK:custom_object/campaign/1"
189+
"id": "don:core:dvrv-us-1:devo/demo:custom_object/campaign/1"
186190
}'
187191
```
188192

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

196-
For more details on customization concepts, please refer to the [Customization](./object-customization) documentation.
200+
For more details on customization concepts, please refer to the
201+
[Customization](./object-customization) documentation.
197202

198203
## Custom object lifecycle
199204

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

0 commit comments

Comments
 (0)