Repository navigation
Expand file tree
/
Copy pathmonitors.ts
More file actions
4757 lines (3983 loc) · 116 KB
/
Copy pathmonitors.ts
File metadata and controls
4757 lines (3983 loc) · 116 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import * as MonitorsAPI from './monitors';
import * as WebhooksAPI from './webhooks/webhooks';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
/**
* Watch websites for exact or meaningful changes.
*/
export class Monitors extends APIResource {
/**
* Watch a page, URL inventory, or extracted website data on a schedule. A run
* starts immediately to capture the baseline.
*
* @example
* ```ts
* const monitor = await client.monitors.create({
* name: 'Acme pricing page',
* target: { type: 'page', url: 'https://acme.com/pricing' },
* change_detection: { type: 'exact' },
* mode: 'web',
* schedule: {
* type: 'interval',
* frequency: 6,
* unit: 'hours',
* },
* webhook: { url: 'https://example.com/webhook' },
* });
* ```
*/
create(body: MonitorCreateParams, options?: RequestOptions): APIPromise<MonitorCreateResponse> {
return this._client.post('/monitors', { body, ...options });
}
/**
* Retrieve a monitor’s configuration and current state.
*
* @example
* ```ts
* const monitor = await client.monitors.retrieve('mon_123');
* ```
*/
retrieve(monitorID: string, options?: RequestOptions): APIPromise<MonitorRetrieveResponse> {
return this._client.get(path`/monitors/${monitorID}`, options);
}
/**
* Update a monitor. Changing its target or change detection replaces the baseline
* and queues a new baseline run.
*
* @example
* ```ts
* const monitor = await client.monitors.update('mon_123', {
* name: 'Acme pricing monitor',
* schedule: {
* type: 'interval',
* frequency: 1,
* unit: 'hours',
* },
* status: 'active',
* webhook: { url: 'https://example.com/webhook' },
* });
* ```
*/
update(
monitorID: string,
body: MonitorUpdateParams,
options?: RequestOptions,
): APIPromise<MonitorUpdateResponse> {
return this._client.patch(path`/monitors/${monitorID}`, { body, ...options });
}
/**
* List your monitors with optional search and filters.
*
* @example
* ```ts
* const monitors = await client.monitors.list();
* ```
*/
list(
query: MonitorListParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<MonitorListResponse> {
return this._client.get('/monitors', { query, ...options });
}
/**
* Delete a monitor and stop future runs and webhook retries.
*
* @example
* ```ts
* const monitor = await client.monitors.delete('mon_123');
* ```
*/
delete(monitorID: string, options?: RequestOptions): APIPromise<MonitorDeleteResponse> {
return this._client.delete(path`/monitors/${monitorID}`, options);
}
/**
* Return usage per monitor, highest first, for up to the 10,000 most recent runs
* in the requested window.
*
* @example
* ```ts
* const response = await client.monitors.getCreditUsage();
* ```
*/
getCreditUsage(
query: MonitorGetCreditUsageParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<MonitorGetCreditUsageResponse> {
return this._client.get('/monitors/credit-usage', { query, ...options });
}
/**
* Retrieve your organization’s monitor allowance and usage.
*
* @example
* ```ts
* const response = await client.monitors.getLimits();
* ```
*/
getLimits(options?: RequestOptions): APIPromise<MonitorGetLimitsResponse> {
return this._client.get('/monitors/limits', options);
}
/**
* List full change records across your monitors, newest first.
*
* @example
* ```ts
* const response = await client.monitors.listAccountChanges();
* ```
*/
listAccountChanges(
query: MonitorListAccountChangesParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<MonitorListAccountChangesResponse> {
return this._client.get('/monitors/changes', { query, ...options });
}
/**
* List runs across your monitors, newest first.
*
* @example
* ```ts
* const response = await client.monitors.listAccountRuns();
* ```
*/
listAccountRuns(
query: MonitorListAccountRunsParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<MonitorListAccountRunsResponse> {
return this._client.get('/monitors/runs', { query, ...options });
}
/**
* List full change records for a monitor, newest first.
*
* @example
* ```ts
* const response = await client.monitors.listChanges(
* 'mon_123',
* );
* ```
*/
listChanges(
monitorID: string,
query: MonitorListChangesParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<MonitorListChangesResponse> {
return this._client.get(path`/monitors/${monitorID}/changes`, { query, ...options });
}
/**
* List a monitor’s runs, newest first.
*
* @example
* ```ts
* const response = await client.monitors.listRuns('mon_123');
* ```
*/
listRuns(
monitorID: string,
query: MonitorListRunsParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<MonitorListRunsResponse> {
return this._client.get(path`/monitors/${monitorID}/runs`, { query, ...options });
}
/**
* Retrieve a detected change, including its diff and available evidence.
*
* @example
* ```ts
* const response = await client.monitors.retrieveChange(
* 'chg_123',
* );
* ```
*/
retrieveChange(changeID: string, options?: RequestOptions): APIPromise<MonitorRetrieveChangeResponse> {
return this._client.get(path`/monitors/changes/${changeID}`, options);
}
/**
* Retrieve the status, timing, and results of one monitor run.
*
* @example
* ```ts
* const response = await client.monitors.retrieveRun(
* 'run_123',
* { monitor_id: 'mon_123' },
* );
* ```
*/
retrieveRun(
runID: string,
params: MonitorRetrieveRunParams,
options?: RequestOptions,
): APIPromise<MonitorRetrieveRunResponse> {
const { monitor_id } = params;
return this._client.get(path`/monitors/${monitor_id}/runs/${runID}`, options);
}
/**
* Generate and return a new signing secret. It takes effect immediately for all
* subsequent delivery attempts.
*
* @example
* ```ts
* const response = await client.monitors.rotateWebhookSecret(
* 'mon_123',
* );
* ```
*/
rotateWebhookSecret(
monitorID: string,
options?: RequestOptions,
): APIPromise<MonitorRotateWebhookSecretResponse> {
return this._client.post(path`/monitors/${monitorID}/webhook/rotate-secret`, options);
}
/**
* Queue a run without changing the regular schedule. Paused monitors return 409.
*
* @example
* ```ts
* const response = await client.monitors.run('mon_123');
* ```
*/
run(monitorID: string, options?: RequestOptions): APIPromise<MonitorRunResponse> {
return this._client.post(path`/monitors/${monitorID}/run`, options);
}
}
export interface WebhookDelivery {
attempted_at: string;
error: WebhookDelivery.Error | null;
/**
* The event this delivery carried. Deliveries recorded before event selection
* existed report change.detected.
*/
event: 'change.detected' | 'run.completed';
/**
* Identifier sent in the X-Context-Id header.
*/
event_id: string;
/**
* The endpoint's final HTTP response status, or null when no response was
* received.
*/
http_status: number | null;
/**
* Outcome of the delivery attempt. Any 2xx response counts as delivered.
*/
status: 'delivered' | 'rejected' | 'failed' | 'skipped_unsafe_url';
/**
* Delivery ID for status checks and retries, when available.
*/
delivery_id?: string;
}
export namespace WebhookDelivery {
export interface Error {
code: string;
message: string;
}
}
export interface MonitorCreateResponse {
id: string;
/**
* How changes are judged. Defaults to `semantic` for extract and search targets
* and page targets with `instructions`, otherwise `exact`.
*/
change_detection:
| MonitorCreateResponse.MonitorsExactChangeDetection
| MonitorCreateResponse.MonitorsSemanticChangeDetection;
created_at: string;
/**
* ID of the baseline run queued at creation; null if it will start on the next
* scheduled tick.
*/
initial_run_id: string | null;
/**
* Always `web`. Optional.
*/
mode: 'web';
name: string;
/**
* Unique ID of this request, also in `X-Request-Id`. Include it when contacting
* support.
*/
request_id: string;
/**
* Current state. Failed monitors keep running; paused monitors must be resumed
* with `status: "active"`.
*/
status: 'active' | 'paused' | 'failed';
/**
* What to watch: a page, a sitemap, data extracted from a site, or web search
* results.
*/
target:
| MonitorCreateResponse.MonitorsPageTarget
| MonitorCreateResponse.MonitorsSitemapTarget
| MonitorCreateResponse.MonitorsExtractTarget
| MonitorCreateResponse.MonitorsSearchTarget;
updated_at: string;
/**
* Comparison baseline, included on Retrieve. Null until capture completes or after
* target changes.
*/
baseline?:
| MonitorCreateResponse.MonitorsPageBaseline
| MonitorCreateResponse.MonitorsSitemapBaseline
| MonitorCreateResponse.MonitorsExtractBaseline
| MonitorCreateResponse.MonitorsSearchBaseline
| null;
/**
* Credits this request used and your remaining balance.
*/
key_metadata?: MonitorCreateResponse.KeyMetadata;
last_change_at?: string | null;
/**
* Error from the most recent failed run; null when the last run succeeded.
*/
last_error?: MonitorCreateResponse.LastError | null;
last_run_at?: string | null;
/**
* When the next scheduled run is due; null while paused.
*/
next_run_at?: string | null;
/**
* Access policy IDs applied to every run.
*/
policies?: Array<string>;
/**
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
* every 6 hours or every 2 days. The total interval (frequency × unit) must be
* between 10 minutes and 1 year.
*/
schedule?: MonitorCreateResponse.Schedule;
/**
* Labels for filtering monitors, their changes, and their usage.
*/
tags?: Array<string>;
/**
* Webhook destination and delivery settings. Null means no webhook is configured.
*/
webhook?: MonitorCreateResponse.Webhook | null;
/**
* Present while webhook deliveries are failing consecutively; null when deliveries
* are healthy or no webhook is configured. Cleared on the next successful delivery
* and when the webhook URL changes.
*/
webhook_failure?: MonitorCreateResponse.WebhookFailure | null;
}
export namespace MonitorCreateResponse {
/**
* Detect exact changes. For page targets, this means visible text diffs. For
* sitemap targets, this means URL additions and removals. For search targets, this
* means every new result.
*/
export interface MonitorsExactChangeDetection {
/**
* Use `exact` to compare visible text, sitemap URLs, or search results.
*/
type: 'exact';
}
/**
* Detect meaningful content changes using the target’s instructions and optional
* schema.
*/
export interface MonitorsSemanticChangeDetection {
/**
* Use `semantic` to judge changes against the target instructions.
*/
type: 'semantic';
/**
* Minimum confidence required to report a meaningful change, from 0 to 1.
*/
confidence_threshold?: number;
}
/**
* Watch a single web page. Exact detection reports visible-text diffs; semantic
* detection judges confirmed stable diffs against `instructions`.
*/
export interface MonitorsPageTarget {
/**
* Use `page` to watch one web page.
*/
type: 'page';
/**
* Public HTTP(S) page URL to monitor.
*/
url: string;
/**
* Optional browser actions executed in array order after the page loads, before
* content is captured, on every run. Requires a paid plan. Maximum: 5 actions.
* Changes create a new baseline.
*/
actions?: Array<
| MonitorsPageTarget.WebScrapeWaitAction
| MonitorsPageTarget.WebScrapePerformAction
| MonitorsPageTarget.WebScrapeScrollAction
> | null;
/**
* Remove matching regions after inclusions. Changes create a new baseline.
*/
exclude_selectors?: Array<string>;
/**
* Monitor these CSS-selected regions. Empty or omitted uses main content. Changes
* create a new baseline.
*/
include_selectors?: Array<string>;
/**
* Plain-language goal describing which page changes matter. When provided without
* change_detection, semantic detection is inferred.
*/
instructions?: string;
/**
* Normalize whitespace before comparing or analyzing text.
*/
normalize_whitespace?: boolean;
}
export namespace MonitorsPageTarget {
/**
* Pause for a fixed number of milliseconds before continuing to the next action.
*/
export interface WebScrapeWaitAction {
/**
* Use `wait` to pause for a fixed duration.
*/
do: 'wait';
/**
* Time to pause in milliseconds before the next action.
*/
timeMs: number;
}
/**
* Resolve and perform one natural-language browser action.
*/
export interface WebScrapePerformAction {
/**
* One browser instruction, such as clicking a button or entering text.
*/
action: string;
/**
* Use `perform` for a plain-language browser instruction.
*/
do: 'perform';
}
/**
* Scroll the page or a selected scrollable container, waiting adaptively for
* content and dimensions to settle after each iteration.
*/
export interface WebScrapeScrollAction {
/**
* Use `scroll` to move through the page or a container.
*/
do: 'scroll';
/**
* Pixels per scroll, one visible viewport, or the current scroll boundary.
* Defaults to viewport.
*/
amount?: number | 'viewport' | 'max';
/**
* CSS selector for the first matching scroll container. Defaults to the page.
*/
container?: string;
/**
* Direction to scroll. Defaults to down.
*/
direction?: 'up' | 'down' | 'left' | 'right';
/**
* Maximum scroll iterations. Stops early when scrolling and scrollable extent stop
* changing. Defaults to 1.
*/
maxScrolls?: number;
}
}
/**
* Watch a site’s URL inventory for confirmed additions and removals.
*/
export interface MonitorsSitemapTarget {
/**
* Use `sitemap` to watch a site for added or removed URLs.
*/
type: 'sitemap';
/**
* Sitemap URL to monitor.
*/
url: string;
/**
* URL path patterns to exclude (max 50).
*/
exclude?: Array<string>;
/**
* URL path patterns to include (max 50).
*/
include?: Array<string>;
/**
* Maximum number of sitemap URLs to track (capped at 10,000).
*/
max_urls?: number;
}
/**
* Track relevant pages selected by `schema` and `instructions`; refresh the page
* set periodically.
*/
export interface MonitorsExtractTarget {
/**
* Natural-language instructions guiding which pages and facts to track and which
* changes to report.
*/
instructions: string;
/**
* Use `extract` to watch structured data across selected pages.
*/
type: 'extract';
/**
* Root URL to extract structured data from.
*/
url: string;
/**
* Allow page discovery on subdomains of the target site.
*/
follow_subdomains?: boolean;
/**
* Optional maximum link depth from the starting URL (0 = only the starting page).
*/
max_depth?: number;
/**
* Maximum number of pages to track.
*/
max_pages?: number;
/**
* JSON Schema for page selection and the baseline snapshot. Changes return diffs
* and evidence.
*/
schema?: { [key: string]: unknown };
}
/**
* Search the web on every run and report results not seen before, listed in the
* change’s `matched_urls` and `evidence`. Semantic detection reports only results
* describing a new development that matches `instructions`; exact detection
* reports every new result.
*/
export interface MonitorsSearchTarget {
/**
* Web search query to run on every check. Supports operators such as `site:`,
* `-site:`, and quoted phrases.
*/
query: string;
/**
* Use `search` to watch the whole web for new results about a topic.
*/
type: 'search';
/**
* Plain-language description of which new results matter. Defaults to the query.
*/
instructions?: string;
}
/**
* Current baseline of a `page` monitor: the visible page text as last observed.
*/
export interface MonitorsPageBaseline {
/**
* When this baseline was last captured or replaced.
*/
captured_at: string;
/**
* The page's visible text as last observed.
*/
text: string;
}
/**
* Current baseline of a `sitemap` monitor: the normalized URL set as last
* observed.
*/
export interface MonitorsSitemapBaseline {
/**
* When this baseline was last captured or replaced.
*/
captured_at: string;
/**
* Number of URLs in the baseline.
*/
url_count: number;
/**
* The sitemap URLs as last observed (sorted, normalized).
*/
urls: Array<string>;
}
/**
* Current baseline of an `extract` monitor: the pages it tracks and the structured
* data as last extracted.
*/
export interface MonitorsExtractBaseline {
/**
* When this baseline was last captured or replaced.
*/
captured_at: string;
/**
* Latest structured snapshot matching the extraction schema, refreshed at most
* daily; `null` before capture.
*/
data: unknown;
/**
* The page URLs the monitor tracks and analyzes for changes.
*/
urls_analyzed: Array<string>;
}
/**
* Current baseline of a `search` monitor: the search results as last observed.
*/
export interface MonitorsSearchBaseline {
/**
* When this baseline was last captured or replaced.
*/
captured_at: string;
/**
* Search results as last observed.
*/
results: Array<MonitorsSearchBaseline.Result>;
}
export namespace MonitorsSearchBaseline {
export interface Result {
/**
* Result snippet.
*/
description: string;
/**
* When the result was published, when known.
*/
published_at: string | null;
title: string;
url: string;
}
}
/**
* Credits this request used and your remaining balance.
*/
export interface KeyMetadata {
/**
* Credits charged for this request.
*/
credits_consumed: number;
/**
* Credits remaining for your organization.
*/
credits_remaining: number;
}
/**
* Error from the most recent failed run; null when the last run succeeded.
*/
export interface LastError {
code: string;
message: string;
}
/**
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
* every 6 hours or every 2 days. The total interval (frequency × unit) must be
* between 10 minutes and 1 year.
*/
export interface Schedule {
/**
* Number of units between runs. The resulting interval (frequency × unit) must be
* at least 10 minutes and at most 1 year (e.g. minimum 10 when unit is minutes;
* maximum 365 when unit is days).
*/
frequency: number;
/**
* Use `interval` to run on a repeating schedule.
*/
type: 'interval';
/**
* Time unit used with `frequency` to set the run interval.
*/
unit: 'minutes' | 'hours' | 'days';
}
/**
* Webhook destination and delivery settings. Null means no webhook is configured.
*/
export interface Webhook {
/**
* Public HTTP(S) URL that receives events. Slack and GovSlack URLs get formatted
* messages.
*/
url: string;
/**
* Events to deliver. Defaults to `change.detected`; `run.completed` also includes
* unchanged runs.
*/
events?: Array<'change.detected' | 'run.completed'>;
/**
* Webhook retry settings. Use {} for the default schedule.
*/
retry?: WebhooksAPI.RetryConfig;
/**
* API-generated signing secret. Visible only with full access or `monitors:write`
* permission.
*/
secret?: string;
}
/**
* Present while webhook deliveries are failing consecutively; null when deliveries
* are healthy or no webhook is configured. Cleared on the next successful delivery
* and when the webhook URL changes.
*/
export interface WebhookFailure {
/**
* Number of consecutive delivery attempts that did not succeed.
*/
consecutive_failures: number;
last_failed_at: string;
/**
* Human-readable description of the most recent failure.
*/
last_message: string;
/**
* Outcome of the most recent failed delivery. rejected means a non-2xx response;
* failed means no HTTP response was received; skipped_unsafe_url means the URL
* failed the public-endpoint safety check.
*/
last_status: 'rejected' | 'failed' | 'skipped_unsafe_url';
}
}
export interface MonitorRetrieveResponse {
id: string;
/**
* How changes are judged. Defaults to `semantic` for extract and search targets
* and page targets with `instructions`, otherwise `exact`.
*/
change_detection:
| MonitorRetrieveResponse.MonitorsExactChangeDetection
| MonitorRetrieveResponse.MonitorsSemanticChangeDetection;
created_at: string;
/**
* Always `web`. Optional.
*/
mode: 'web';
name: string;
/**
* Unique ID of this request, also in `X-Request-Id`. Include it when contacting
* support.
*/
request_id: string;
/**
* Current state. Failed monitors keep running; paused monitors must be resumed
* with `status: "active"`.
*/
status: 'active' | 'paused' | 'failed';
/**
* What to watch: a page, a sitemap, data extracted from a site, or web search
* results.
*/
target:
| MonitorRetrieveResponse.MonitorsPageTarget
| MonitorRetrieveResponse.MonitorsSitemapTarget
| MonitorRetrieveResponse.MonitorsExtractTarget
| MonitorRetrieveResponse.MonitorsSearchTarget;
updated_at: string;
/**
* Comparison baseline, included on Retrieve. Null until capture completes or after
* target changes.
*/
baseline?:
| MonitorRetrieveResponse.MonitorsPageBaseline
| MonitorRetrieveResponse.MonitorsSitemapBaseline
| MonitorRetrieveResponse.MonitorsExtractBaseline
| MonitorRetrieveResponse.MonitorsSearchBaseline
| null;
/**
* Credits this request used and your remaining balance.
*/
key_metadata?: MonitorRetrieveResponse.KeyMetadata;
last_change_at?: string | null;
/**
* Error from the most recent failed run; null when the last run succeeded.
*/
last_error?: MonitorRetrieveResponse.LastError | null;
last_run_at?: string | null;
/**
* When the next scheduled run is due; null while paused.
*/
next_run_at?: string | null;
/**
* Access policy IDs applied to every run.
*/
policies?: Array<string>;
/**
* Run the monitor on a fixed interval defined by a frequency and a unit, e.g.
* every 6 hours or every 2 days. The total interval (frequency × unit) must be
* between 10 minutes and 1 year.
*/
schedule?: MonitorRetrieveResponse.Schedule;
/**
* Labels for filtering monitors, their changes, and their usage.
*/
tags?: Array<string>;
/**
* Webhook destination and delivery settings. Null means no webhook is configured.
*/
webhook?: MonitorRetrieveResponse.Webhook | null;
/**
* Present while webhook deliveries are failing consecutively; null when deliveries
* are healthy or no webhook is configured. Cleared on the next successful delivery
* and when the webhook URL changes.
*/
webhook_failure?: MonitorRetrieveResponse.WebhookFailure | null;
}
export namespace MonitorRetrieveResponse {
/**
* Detect exact changes. For page targets, this means visible text diffs. For
* sitemap targets, this means URL additions and removals. For search targets, this
* means every new result.
*/
export interface MonitorsExactChangeDetection {
/**
* Use `exact` to compare visible text, sitemap URLs, or search results.
*/
type: 'exact';
}
/**
* Detect meaningful content changes using the target’s instructions and optional
* schema.
*/
export interface MonitorsSemanticChangeDetection {
/**
* Use `semantic` to judge changes against the target instructions.
*/
type: 'semantic';
/**
* Minimum confidence required to report a meaningful change, from 0 to 1.
*/
confidence_threshold?: number;
}
/**
* Watch a single web page. Exact detection reports visible-text diffs; semantic
* detection judges confirmed stable diffs against `instructions`.
*/
export interface MonitorsPageTarget {
/**
* Use `page` to watch one web page.
*/
type: 'page';
/**
* Public HTTP(S) page URL to monitor.
*/
url: string;
/**
* Optional browser actions executed in array order after the page loads, before
* content is captured, on every run. Requires a paid plan. Maximum: 5 actions.
* Changes create a new baseline.
*/
actions?: Array<
| MonitorsPageTarget.WebScrapeWaitAction
| MonitorsPageTarget.WebScrapePerformAction