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