import { RuntimeCheck, RuntimeCheckProps } from './check'; import { HttpHeader } from './http-header'; import { BasicAuth, Request } from './api-request'; import { QueryParam } from './query-param'; import { Content, Entrypoint } from './construct'; import { Diagnostics } from './diagnostics'; import { ApiCheckBundle } from './api-check-bundle'; import { Assertion } from './api-assertion'; import { Bundler } from '../services/check-parser/bundler'; /** * Default configuration that can be applied to API checks. * Used for setting common defaults across multiple checks. */ export type ApiCheckDefaultConfig = { /** Default URL for API requests */ url?: string; /** Default HTTP headers to include */ headers?: Array; /** Default query parameters to include */ queryParameters?: Array; /** Default basic authentication credentials */ basicAuth?: BasicAuth; /** Default assertions to apply */ assertions?: Array; }; export interface ApiCheckProps extends RuntimeCheckProps { /** * Determines the request that the check is going to run. */ request: Request; /** * A valid piece of Node.js code to run in the setup phase. * @deprecated use the "setupScript" property instead */ localSetupScript?: string; /** * A valid piece of Node.js code to run in the setup phase. */ setupScript?: Content | Entrypoint; /** * A valid piece of Node.js code to run in the teardown phase. * @deprecated use the "tearDownScript" property instead */ localTearDownScript?: string; /** * A valid piece of Node.js code to run in the teardown phase. */ tearDownScript?: Content | Entrypoint; /** * The response time in milliseconds where a check should be considered degraded. * Used for performance monitoring and alerting on slow responses. * * @defaultValue 10000 * @minimum 0 * @maximum 30000 * @example * ```typescript * degradedResponseTime: 2000 // Alert when API responds slower than 2 seconds * ``` */ degradedResponseTime?: number; /** * The response time in milliseconds where a check should be considered failing. * The check fails if the response takes longer than this threshold. * * @defaultValue 20000 * @minimum 0 * @maximum 30000 * @example * ```typescript * maxResponseTime: 5000 // Fail check if API takes longer than 5 seconds * ``` */ maxResponseTime?: number; } /** * Creates an API Check to monitor HTTP endpoints and APIs. * * API checks allow you to monitor REST APIs, GraphQL endpoints, and any HTTP-based service. * You can validate response status codes, response times, headers, and response body content. * * @example * ```typescript * // Basic API check * new ApiCheck('hello-api', { * name: 'Hello API', * request: { * method: 'GET', * url: 'https://api.example.com/hello', * assertions: [ * AssertionBuilder.statusCode().equals(200) * ] * } * }) * * // Advanced API check with POST request * new ApiCheck('user-api', { * name: 'User API Check', * frequency: Frequency.EVERY_5M, * locations: ['us-east-1', 'eu-west-1'], * request: { * method: 'POST', * url: 'https://api.example.com/users', * headers: [{ key: 'Content-Type', value: 'application/json' }], * body: JSON.stringify({ name: 'test-user' }), * bodyType: 'JSON', * assertions: [ * AssertionBuilder.statusCode().equals(201), * AssertionBuilder.jsonBody('$.id').isNotNull(), * AssertionBuilder.responseTime().lessThan(1000) * ] * }, * maxResponseTime: 5000, * degradedResponseTime: 2000 * }) * * // Error validation check (shouldFail required for error status checks) * new ApiCheck('not-found-check', { * name: 'Not Found Check', * shouldFail: true, * request: { * method: 'GET', * url: 'https://api.example.com/nonexistent', * assertions: [ * AssertionBuilder.statusCode().equals(404) * ] * } * }) * ``` * * @see {@link https://www.checklyhq.com/docs/constructs/api-check/ | ApiCheck API Reference} * @see {@link https://www.checklyhq.com/docs/detect/synthetic-monitoring/api-checks/overview/ | API Checks Documentation} */ export declare class ApiCheck extends RuntimeCheck { readonly request: Request; readonly localSetupScript?: string; readonly setupScript?: Content | Entrypoint; readonly localTearDownScript?: string; readonly tearDownScript?: Content | Entrypoint; readonly degradedResponseTime?: number; readonly maxResponseTime?: number; /** * Constructs the API Check instance * * @param logicalId unique project-scoped resource name identification * @param props check configuration properties * * {@link https://www.checklyhq.com/docs/constructs/api-check/ Read more in the docs} */ constructor(logicalId: string, props: ApiCheckProps); describe(): string; protected supportsOnlyOnNetworkErrorRetryStrategy(): boolean; validate(diagnostics: Diagnostics): Promise; bundle(bundler: Bundler): Promise; static bundle(bundler: Bundler, entrypoint: string, runtimeId?: string): Promise<{ script: string; scriptPath: string; dependencies: number[]; }>; synthesize(): { checkType: string; request: Request; localSetupScript: string | undefined; localTearDownScript: string | undefined; degradedResponseTime: number | undefined; maxResponseTime: number | undefined; runtimeId: string | undefined; environmentVariables: import("./key-value-pair").default[] | undefined; activated: boolean | undefined; muted: boolean | undefined; shouldFail: boolean | undefined; locations: (keyof import("..").Region)[] | undefined; privateLocations: undefined; tags: string[] | undefined; frequency: number | undefined; frequencyOffset: number | undefined; groupId: import("./ref").Ref | null; retryStrategy: import("./retry-strategy").LinearRetryStrategy | import("./retry-strategy").ExponentialRetryStrategy | import("./retry-strategy").FixedRetryStrategy | import("./retry-strategy").SingleRetryRetryStrategy | null | undefined; doubleCheck: boolean | undefined; alertSettings: import("./alert-escalation-policy").AlertEscalation | undefined; useGlobalAlertSettings: boolean | undefined; runParallel: boolean | undefined; triggerIncident: { serviceId: import("./ref").Ref; severity: "MINOR" | "MEDIUM" | "MAJOR" | "CRITICAL"; name: string; description: string; notifySubscribers: boolean; } | undefined; description?: string | undefined; name: string; }; }