@@ -70,24 +70,44 @@ func (r *WebhookService) Unwrap(payload []byte, headers http.Header, opts ...opt
70
70
return res , nil
71
71
}
72
72
73
- type UploadPostTransformErrorEvent struct {
73
+ type BaseWebhookEvent struct {
74
74
// Unique identifier for the event.
75
75
ID string `json:"id,required"`
76
+ // The type of webhook event.
77
+ Type string `json:"type,required"`
78
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
79
+ JSON struct {
80
+ ID respjson.Field
81
+ Type respjson.Field
82
+ ExtraFields map [string ]respjson.Field
83
+ raw string
84
+ } `json:"-"`
85
+ }
86
+
87
+ // Returns the unmodified JSON received from the API
88
+ func (r BaseWebhookEvent ) RawJSON () string { return r .JSON .raw }
89
+ func (r * BaseWebhookEvent ) UnmarshalJSON (data []byte ) error {
90
+ return apijson .UnmarshalRoot (data , r )
91
+ }
92
+
93
+ // Triggered when a post-transformation fails. The original file remains available,
94
+ // but the requested transformation could not be generated.
95
+ type UploadPostTransformErrorEvent struct {
76
96
// Timestamp of when the event occurred in ISO8601 format.
77
97
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
78
98
Data UploadPostTransformErrorEventData `json:"data,required"`
79
99
Request UploadPostTransformErrorEventRequest `json:"request,required"`
80
100
Type constant.UploadPostTransformError `json:"type,required"`
81
101
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
82
102
JSON struct {
83
- ID respjson.Field
84
103
CreatedAt respjson.Field
85
104
Data respjson.Field
86
105
Request respjson.Field
87
106
Type respjson.Field
88
107
ExtraFields map [string ]respjson.Field
89
108
raw string
90
109
} `json:"-"`
110
+ BaseWebhookEvent
91
111
}
92
112
93
113
// Returns the unmodified JSON received from the API
@@ -203,24 +223,25 @@ func (r *UploadPostTransformErrorEventRequestTransformation) UnmarshalJSON(data
203
223
return apijson .UnmarshalRoot (data , r )
204
224
}
205
225
226
+ // Triggered when a post-transformation completes successfully. The transformed
227
+ // version of the file is now ready and can be accessed via the provided URL. Note
228
+ // that each post-transformation generates a separate webhook event.
206
229
type UploadPostTransformSuccessEvent struct {
207
- // Unique identifier for the event.
208
- ID string `json:"id,required"`
209
230
// Timestamp of when the event occurred in ISO8601 format.
210
231
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
211
232
Data UploadPostTransformSuccessEventData `json:"data,required"`
212
233
Request UploadPostTransformSuccessEventRequest `json:"request,required"`
213
234
Type constant.UploadPostTransformSuccess `json:"type,required"`
214
235
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
215
236
JSON struct {
216
- ID respjson.Field
217
237
CreatedAt respjson.Field
218
238
Data respjson.Field
219
239
Request respjson.Field
220
240
Type respjson.Field
221
241
ExtraFields map [string ]respjson.Field
222
242
raw string
223
243
} `json:"-"`
244
+ BaseWebhookEvent
224
245
}
225
246
226
247
// Returns the unmodified JSON received from the API
@@ -298,24 +319,24 @@ func (r *UploadPostTransformSuccessEventRequestTransformation) UnmarshalJSON(dat
298
319
return apijson .UnmarshalRoot (data , r )
299
320
}
300
321
322
+ // Triggered when a pre-transformation fails. The file upload may have been
323
+ // accepted, but the requested transformation could not be applied.
301
324
type UploadPreTransformErrorEvent struct {
302
- // Unique identifier for the event.
303
- ID string `json:"id,required"`
304
325
// Timestamp of when the event occurred in ISO8601 format.
305
326
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
306
327
Data UploadPreTransformErrorEventData `json:"data,required"`
307
328
Request UploadPreTransformErrorEventRequest `json:"request,required"`
308
329
Type constant.UploadPreTransformError `json:"type,required"`
309
330
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
310
331
JSON struct {
311
- ID respjson.Field
312
332
CreatedAt respjson.Field
313
333
Data respjson.Field
314
334
Request respjson.Field
315
335
Type respjson.Field
316
336
ExtraFields map [string ]respjson.Field
317
337
raw string
318
338
} `json:"-"`
339
+ BaseWebhookEvent
319
340
}
320
341
321
342
// Returns the unmodified JSON received from the API
@@ -399,9 +420,10 @@ func (r *UploadPreTransformErrorEventRequest) UnmarshalJSON(data []byte) error {
399
420
return apijson .UnmarshalRoot (data , r )
400
421
}
401
422
423
+ // Triggered when a pre-transformation completes successfully. The file has been
424
+ // processed with the requested transformation and is now available in the Media
425
+ // Library.
402
426
type UploadPreTransformSuccessEvent struct {
403
- // Unique identifier for the event.
404
- ID string `json:"id,required"`
405
427
// Timestamp of when the event occurred in ISO8601 format.
406
428
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
407
429
// Object containing details of a successful upload.
@@ -410,14 +432,14 @@ type UploadPreTransformSuccessEvent struct {
410
432
Type constant.UploadPreTransformSuccess `json:"type,required"`
411
433
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
412
434
JSON struct {
413
- ID respjson.Field
414
435
CreatedAt respjson.Field
415
436
Data respjson.Field
416
437
Request respjson.Field
417
438
Type respjson.Field
418
439
ExtraFields map [string ]respjson.Field
419
440
raw string
420
441
} `json:"-"`
442
+ BaseWebhookEvent
421
443
}
422
444
423
445
// Returns the unmodified JSON received from the API
@@ -641,9 +663,10 @@ func (r *UploadPreTransformSuccessEventRequest) UnmarshalJSON(data []byte) error
641
663
return apijson .UnmarshalRoot (data , r )
642
664
}
643
665
666
+ // Triggered when a new video transformation request is accepted for processing.
667
+ // This event confirms that ImageKit has received and queued your transformation
668
+ // request. Use this for debugging and tracking transformation lifecycle.
644
669
type VideoTransformationAcceptedEvent struct {
645
- // Unique identifier for the event.
646
- ID string `json:"id,required"`
647
670
// Timestamp when the event was created in ISO8601 format.
648
671
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
649
672
Data VideoTransformationAcceptedEventData `json:"data,required"`
@@ -652,14 +675,14 @@ type VideoTransformationAcceptedEvent struct {
652
675
Type constant.VideoTransformationAccepted `json:"type,required"`
653
676
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
654
677
JSON struct {
655
- ID respjson.Field
656
678
CreatedAt respjson.Field
657
679
Data respjson.Field
658
680
Request respjson.Field
659
681
Type respjson.Field
660
682
ExtraFields map [string ]respjson.Field
661
683
raw string
662
684
} `json:"-"`
685
+ BaseWebhookEvent
663
686
}
664
687
665
688
// Returns the unmodified JSON received from the API
@@ -804,9 +827,11 @@ func (r *VideoTransformationAcceptedEventRequest) UnmarshalJSON(data []byte) err
804
827
return apijson .UnmarshalRoot (data , r )
805
828
}
806
829
830
+ // Triggered when an error occurs during video encoding. Listen to this webhook to
831
+ // log error reasons and debug issues. Check your origin and URL endpoint settings
832
+ // if the reason is related to download failure. For other errors, contact ImageKit
833
+ // support.
807
834
type VideoTransformationErrorEvent struct {
808
- // Unique identifier for the event.
809
- ID string `json:"id,required"`
810
835
// Timestamp when the event was created in ISO8601 format.
811
836
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
812
837
Data VideoTransformationErrorEventData `json:"data,required"`
@@ -815,14 +840,14 @@ type VideoTransformationErrorEvent struct {
815
840
Type constant.VideoTransformationError `json:"type,required"`
816
841
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
817
842
JSON struct {
818
- ID respjson.Field
819
843
CreatedAt respjson.Field
820
844
Data respjson.Field
821
845
Request respjson.Field
822
846
Type respjson.Field
823
847
ExtraFields map [string ]respjson.Field
824
848
raw string
825
849
} `json:"-"`
850
+ BaseWebhookEvent
826
851
}
827
852
828
853
// Returns the unmodified JSON received from the API
@@ -990,9 +1015,11 @@ func (r *VideoTransformationErrorEventRequest) UnmarshalJSON(data []byte) error
990
1015
return apijson .UnmarshalRoot (data , r )
991
1016
}
992
1017
1018
+ // Triggered when video encoding is finished and the transformed resource is ready
1019
+ // to be served. This is the key event to listen for - update your database or CMS
1020
+ // flags when you receive this so your application can start showing the
1021
+ // transformed video to users.
993
1022
type VideoTransformationReadyEvent struct {
994
- // Unique identifier for the event.
995
- ID string `json:"id,required"`
996
1023
// Timestamp when the event was created in ISO8601 format.
997
1024
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
998
1025
Data VideoTransformationReadyEventData `json:"data,required"`
@@ -1003,7 +1030,6 @@ type VideoTransformationReadyEvent struct {
1003
1030
Timings VideoTransformationReadyEventTimings `json:"timings"`
1004
1031
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1005
1032
JSON struct {
1006
- ID respjson.Field
1007
1033
CreatedAt respjson.Field
1008
1034
Data respjson.Field
1009
1035
Request respjson.Field
@@ -1012,6 +1038,7 @@ type VideoTransformationReadyEvent struct {
1012
1038
ExtraFields map [string ]respjson.Field
1013
1039
raw string
1014
1040
} `json:"-"`
1041
+ BaseWebhookEvent
1015
1042
}
1016
1043
1017
1044
// Returns the unmodified JSON received from the API
@@ -1235,7 +1262,12 @@ func (r *VideoTransformationReadyEventTimings) UnmarshalJSON(data []byte) error
1235
1262
//
1236
1263
// Use the methods beginning with 'As' to cast the union to one of its variants.
1237
1264
type UnsafeUnwrapWebhookEventUnion struct {
1265
+ // This field is from variant [VideoTransformationAcceptedEvent],
1266
+ // [VideoTransformationReadyEvent], [VideoTransformationErrorEvent],
1267
+ // [UploadPreTransformSuccessEvent], [UploadPreTransformErrorEvent],
1268
+ // [UploadPostTransformSuccessEvent], [UploadPostTransformErrorEvent].
1238
1269
ID string `json:"id"`
1270
+ Type string `json:"type"`
1239
1271
CreatedAt time.Time `json:"created_at"`
1240
1272
// This field is a union of [VideoTransformationAcceptedEventData],
1241
1273
// [VideoTransformationReadyEventData], [VideoTransformationErrorEventData],
@@ -1247,15 +1279,14 @@ type UnsafeUnwrapWebhookEventUnion struct {
1247
1279
// [UploadPreTransformSuccessEventRequest], [UploadPreTransformErrorEventRequest],
1248
1280
// [UploadPostTransformSuccessEventRequest], [UploadPostTransformErrorEventRequest]
1249
1281
Request UnsafeUnwrapWebhookEventUnionRequest `json:"request"`
1250
- Type string `json:"type"`
1251
1282
// This field is from variant [VideoTransformationReadyEvent].
1252
1283
Timings VideoTransformationReadyEventTimings `json:"timings"`
1253
1284
JSON struct {
1254
1285
ID respjson.Field
1286
+ Type respjson.Field
1255
1287
CreatedAt respjson.Field
1256
1288
Data respjson.Field
1257
1289
Request respjson.Field
1258
- Type respjson.Field
1259
1290
Timings respjson.Field
1260
1291
raw string
1261
1292
} `json:"-"`
@@ -1566,7 +1597,12 @@ func (r *UnsafeUnwrapWebhookEventUnionRequestTransformation) UnmarshalJSON(data
1566
1597
//
1567
1598
// Use the methods beginning with 'As' to cast the union to one of its variants.
1568
1599
type UnwrapWebhookEventUnion struct {
1600
+ // This field is from variant [VideoTransformationAcceptedEvent],
1601
+ // [VideoTransformationReadyEvent], [VideoTransformationErrorEvent],
1602
+ // [UploadPreTransformSuccessEvent], [UploadPreTransformErrorEvent],
1603
+ // [UploadPostTransformSuccessEvent], [UploadPostTransformErrorEvent].
1569
1604
ID string `json:"id"`
1605
+ Type string `json:"type"`
1570
1606
CreatedAt time.Time `json:"created_at"`
1571
1607
// This field is a union of [VideoTransformationAcceptedEventData],
1572
1608
// [VideoTransformationReadyEventData], [VideoTransformationErrorEventData],
@@ -1578,15 +1614,14 @@ type UnwrapWebhookEventUnion struct {
1578
1614
// [UploadPreTransformSuccessEventRequest], [UploadPreTransformErrorEventRequest],
1579
1615
// [UploadPostTransformSuccessEventRequest], [UploadPostTransformErrorEventRequest]
1580
1616
Request UnwrapWebhookEventUnionRequest `json:"request"`
1581
- Type string `json:"type"`
1582
1617
// This field is from variant [VideoTransformationReadyEvent].
1583
1618
Timings VideoTransformationReadyEventTimings `json:"timings"`
1584
1619
JSON struct {
1585
1620
ID respjson.Field
1621
+ Type respjson.Field
1586
1622
CreatedAt respjson.Field
1587
1623
Data respjson.Field
1588
1624
Request respjson.Field
1589
- Type respjson.Field
1590
1625
Timings respjson.Field
1591
1626
raw string
1592
1627
} `json:"-"`
0 commit comments