1
1
## Table of contents
2
2
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 )
6
6
- [ Get a custom object] ( #get-a-custom-object )
7
7
- [ List custom objects] ( #list-custom-objects )
8
8
- [ Update a custom object] ( #update-a-custom-object )
9
9
- [ 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 )
12
15
13
16
- - -
14
17
15
18
## 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.
18
22
19
23
## Quick start
20
24
@@ -78,40 +82,43 @@ curl --location 'https://api.devrev.ai/custom-objects.create' \
78
82
--header 'Authorization: <YOUR_API_TOKEN>' \
79
83
--data '{
80
84
"leaf_type": "campaign",
85
+ "unique_key": "CAMP-001",
86
+ "custom_schema_spec": {
87
+ "tenant_fragment": true
88
+ },
81
89
"custom_fields": {
82
90
"tnt__name": "Summer Sale 2023",
83
91
"tnt__start_date": "2023-06-01",
84
92
"tnt__end_date": "2023-08-31",
85
93
"tnt__budget": 10000,
86
94
"tnt__target_audience": "Professionals"
87
- },
88
- "unique_key": "CAMP-001"
95
+ }
89
96
}'
90
97
```
91
98
92
99
The response of the above API call will be the ID of the custom object created.
93
100
```
94
101
{
95
102
"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",
97
104
"created_by": {...},
98
105
"created_date": "2024-10-01T07:02:58.958Z",
99
106
"modified_by": {...},
100
107
"modified_date": "2024-10-01T07:02:58.958Z",
101
108
"display_id": "C-CAMP-1",
102
109
"leaf_type": "campaign",
103
110
"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 ",
105
112
"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 "
107
114
],
108
115
"custom_fields": {
109
- "tnt__budget": 10000,
110
- "tnt__end_date": "2023-08-31",
111
116
"tnt__name": "Summer Sale 2023",
112
117
"tnt__start_date": "2023-06-01",
118
+ "tnt__end_date": "2023-08-31",
119
+ "tnt__budget": 10000,
113
120
"tnt__target_audience": "Professionals"
114
- },
121
+ }
115
122
}
116
123
}
117
124
```
@@ -130,7 +137,7 @@ curl --location 'https://api.devrev.ai/custom-objects.get' \
130
137
--header 'Accept: application/json' \
131
138
--header 'Authorization: <YOUR_API_TOKEN>' \
132
139
--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"
134
141
}'
135
142
```
136
143
@@ -155,16 +162,16 @@ curl --location 'https://api.devrev.ai/custom-objects.list' \
155
162
156
163
### Update a custom object
157
164
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:
160
167
161
168
```
162
169
curl --location 'https://api.devrev.ai/custom-objects.update' \
163
170
--header 'Content-Type: application/json' \
164
171
--header 'Accept: application/json' \
165
172
--header 'Authorization: <YOUR_API_TOKEN>' \
166
173
--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",
168
175
"custom_fields": {
169
176
"tnt__budget": 15000
170
177
}
@@ -182,7 +189,7 @@ curl --location 'https://api.devrev.ai/custom-objects.delete' \
182
189
--header 'Accept: application/json' \
183
190
--header 'Authorization: <YOUR_API_TOKEN>' \
184
191
--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"
186
193
}'
187
194
```
188
195
@@ -193,10 +200,73 @@ curl --location 'https://api.devrev.ai/custom-objects.delete' \
193
200
3 . ** Custom Fields** : User-defined fields that store specific data for your custom object.
194
201
4 . ** Unique Key** : A unique identifier for each custom object, useful for maintaining idempotency.
195
202
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.
197
205
198
206
## Custom object lifecycle
199
207
200
208
1 . ** Creation** : Define the leaf type, subtype (optional), and custom fields for your custom object.
201
209
2 . ** Usage** : Create, update, and query custom objects as needed in your workflows.
202
210
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