You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

942 lines
24 KiB

4 years ago
  1. # Management API
  2. With the Management API, you can programmatically manage checks and integrations
  3. in your account.
  4. ## API Endpoints
  5. Endpoint Name | Endpoint Address
  6. ------------------------------------------------------|-------
  7. [Get a list of existing checks](#list-checks) | `GET SITE_ROOT/api/v1/checks/`
  8. [Get a single check](#get-check) | `GET SITE_ROOT/api/v1/checks/<uuid>`<br>`GET SITE_ROOT/api/v1/checks/<unique_key>`
  9. [Create a new check](#create-check) | `POST SITE_ROOT/api/v1/checks/`
  10. [Update an existing check](#update-check) | `POST SITE_ROOT/api/v1/checks/<uuid>`
  11. [Pause monitoring of a check](#pause-check) | `POST SITE_ROOT/api/v1/checks/<uuid>/pause`
  12. [Delete check](#delete-check) | `DELETE SITE_ROOT/api/v1/checks/<uuid>`
  13. [Get a list of check's logged pings](#list-pings) | `GET SITE_ROOT/api/v1/checks/<uuid>/pings/`
  14. [Get a list of check's status changes](#list-flips) | `GET SITE_ROOT/api/v1/checks/<uuid>/flips/`<br>`GET SITE_ROOT/api/v1/checks/<unique_key>/flips/`
  15. [Get a list of existing integrations](#list-channels) | `GET SITE_ROOT/api/v1/channels/`
  16. ## Authentication
  17. Your requests to SITE_NAME Management API must authenticate using an
  18. API key. All API keys are project-specific. There are no account-wide API keys.
  19. By default, a project on SITE_NAME doesn't have an API key. You can create read-write
  20. and read-only API keys on the **Project Settings** page.
  21. read-write key
  22. : Has full access to all documented API endpoints.
  23. read-only key
  24. : Only works with the following API endpoints:
  25. * [Get a list of existing checks](#list-checks)
  26. * [Get a single check](#get-check)
  27. * [Get a list of check's status changes](#list-flips)
  28. Omits sensitive information from the API responses. See the documentation of
  29. individual API endpoints for details.
  30. The client can authenticate itself by including an `X-Api-Key: <your-api-key>`
  31. header in an HTTP request. Alternatively, for POST requests with a JSON request body,
  32. the client can put an `api_key` field in the JSON document.
  33. See the [Create a new check](#create-check) section for an example.
  34. ## API Requests
  35. For POST requests, the SITE_NAME API expects the request body to be
  36. a JSON document (*not* a `multipart/form-data` encoded form data).
  37. ## API Responses
  38. SITE_NAME uses HTTP status codes wherever possible.
  39. In general, 2xx class indicates success, 4xx indicates a client error,
  40. and 5xx indicates a server error.
  41. The response may contain a JSON document with additional data.
  42. ## Get a List of Existing Checks {: #list-checks .rule }
  43. `GET SITE_ROOT/api/v1/checks/`
  44. Returns a list of checks belonging to the user, optionally filtered by
  45. one or more tags.
  46. ### Query String Parameters
  47. tag=&lt;value&gt;
  48. : Filters the checks and returns only the checks that are tagged with the
  49. specified value.
  50. This parameter can be repeated multiple times.
  51. Example:
  52. `SITE_ROOT/api/v1/checks/?tag=foo&tag=bar`
  53. ### Response Codes
  54. 200 OK
  55. : The request succeeded.
  56. 401 Unauthorized
  57. : The API key is either missing or invalid.
  58. ### Example Request
  59. ```bash
  60. curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/
  61. ```
  62. ### Example Response
  63. ```json
  64. {
  65. "checks": [
  66. {
  67. "name": "Filesystem Backup",
  68. "tags": "backup fs",
  69. "desc": "Runs incremental backup every hour",
  70. "grace": 600,
  71. "n_pings": 1,
  72. "status": "up",
  73. "last_ping": "2020-03-24T14:02:03+00:00",
  74. "next_ping": "2020-03-24T15:02:03+00:00",
  75. "manual_resume": false,
  76. "methods": "",
  77. "ping_url": "PING_ENDPOINT31365bce-8da9-4729-8ff3-aaa71d56b712",
  78. "update_url": "SITE_ROOT/api/v1/checks/31365bce-8da9-4729-8ff3-aaa71d56b712",
  79. "pause_url": "SITE_ROOT/api/v1/checks/31365bce-8da9-4729-8ff3-aaa71d56b712/pause",
  80. "channels": "1bdea468-03bf-47b8-ab27-29a9dd0e4b94,51c6eb2b-2ae1-456b-99fe-6f1e0a36cd3c",
  81. "timeout": 3600
  82. },
  83. {
  84. "name": "Database Backup",
  85. "tags": "production db",
  86. "desc": "Runs ~/db-backup.sh",
  87. "grace": 1200,
  88. "n_pings": 7,
  89. "status": "down",
  90. "last_ping": "2020-03-23T10:19:32+00:00",
  91. "next_ping": null,
  92. "manual_resume": false,
  93. "methods": "",
  94. "ping_url": "PING_ENDPOINT803f680d-e89b-492b-82ef-2be7b774a92d",
  95. "update_url": "SITE_ROOT/api/v1/checks/803f680d-e89b-492b-82ef-2be7b774a92d",
  96. "pause_url": "SITE_ROOT/api/v1/checks/803f680d-e89b-492b-82ef-2be7b774a92d/pause",
  97. "channels": "1bdea468-03bf-47b8-ab27-29a9dd0e4b94,51c6eb2b-2ae1-456b-99fe-6f1e0a36cd3c",
  98. "schedule": "15 5 * * *",
  99. "tz": "UTC"
  100. }
  101. ]
  102. }
  103. ```
  104. When using the read-only API key, SITE_NAME omits the following fields from responses:
  105. `ping_url`, `update_url`, `pause_url`, `channels`. It adds an extra
  106. `unique_key` field. The `unique_key` identifier is stable across API calls, and
  107. you can use it in the [Get a single check](#get-check)
  108. and [Get a list of check's status changes](#list-flips) API calls.
  109. Example:
  110. ```json
  111. {
  112. "checks": [
  113. {
  114. "name": "Filesystem Backup",
  115. "tags": "backup fs",
  116. "desc": "Runs incremental backup every hour",
  117. "grace": 600,
  118. "n_pings": 1,
  119. "status": "up",
  120. "last_ping": "2020-03-24T14:02:03+00:00",
  121. "next_ping": "2020-03-24T15:02:03+00:00",
  122. "manual_resume": false,
  123. "methods": "",
  124. "unique_key": "a6c7b0a8a66bed0df66abfdab3c77736861703ee",
  125. "timeout": 3600
  126. },
  127. {
  128. "name": "Database Backup",
  129. "tags": "production db",
  130. "desc": "Runs ~/db-backup.sh",
  131. "grace": 1200,
  132. "n_pings": 7,
  133. "status": "down",
  134. "last_ping": "2020-03-23T10:19:32+00:00",
  135. "next_ping": null,
  136. "manual_resume": false,
  137. "methods": "",
  138. "unique_key": "124f983e0e3dcaeba921cfcef46efd084576e783",
  139. "schedule": "15 5 * * *",
  140. "tz": "UTC"
  141. }
  142. ]
  143. }
  144. ```
  145. ## Get a Single Check {: #get-check .rule }
  146. `GET SITE_ROOT/api/v1/checks/<uuid>`<br>
  147. `GET SITE_ROOT/api/v1/checks/<unique_key>`
  148. Returns a JSON representation of a single check. Accepts either check's UUID or
  149. the `unique_key` (a field derived from UUID and returned by API responses when
  150. using the read-only API key) as an identifier.
  151. ### Response Codes
  152. 200 OK
  153. : The request succeeded.
  154. 401 Unauthorized
  155. : The API key is either missing or invalid.
  156. 403 Forbidden
  157. : Access denied, wrong API key.
  158. 404 Not Found
  159. : The specified check does not exist.
  160. ### Example Request
  161. ```bash
  162. curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/<uuid>
  163. ```
  164. ### Example Response
  165. ```json
  166. {
  167. "name": "Database Backup",
  168. "tags": "production db",
  169. "desc": "Runs ~/db-backup.sh",
  170. "grace": 1200,
  171. "n_pings": 7,
  172. "status": "down",
  173. "last_ping": "2020-03-23T10:19:32+00:00",
  174. "next_ping": null,
  175. "manual_resume": false,
  176. "methods": "",
  177. "ping_url": "PING_ENDPOINT803f680d-e89b-492b-82ef-2be7b774a92d",
  178. "update_url": "SITE_ROOT/api/v1/checks/803f680d-e89b-492b-82ef-2be7b774a92d",
  179. "pause_url": "SITE_ROOT/api/v1/checks/803f680d-e89b-492b-82ef-2be7b774a92d/pause",
  180. "channels": "1bdea468-03bf-47b8-ab27-29a9dd0e4b94,51c6eb2b-2ae1-456b-99fe-6f1e0a36cd3c",
  181. "schedule": "15 5 * * *",
  182. "tz": "UTC"
  183. }
  184. ```
  185. ### Example Read-Only Response
  186. When using the read-only API key, SITE_NAME omits the following fields from responses:
  187. `ping_url`, `update_url`, `pause_url`, `channels`. It adds an extra
  188. `unique_key` field. This identifier is stable across API calls.
  189. Note: although API omits the `ping_url`, `update_url`, and `pause_url` in read-only
  190. API responses, the client can easily construct these URLs themselves *if* they know the
  191. check's unique UUID.
  192. ```json
  193. {
  194. "name": "Database Backup",
  195. "tags": "production db",
  196. "desc": "Runs ~/db-backup.sh",
  197. "grace": 1200,
  198. "n_pings": 7,
  199. "status": "down",
  200. "last_ping": "2020-03-23T10:19:32+00:00",
  201. "next_ping": null,
  202. "manual_resume": false,
  203. "methods": "",
  204. "unique_key": "124f983e0e3dcaeba921cfcef46efd084576e783",
  205. "schedule": "15 5 * * *",
  206. "tz": "UTC"
  207. }
  208. ```
  209. ## Create a Check {: #create-check .rule }
  210. `POST SITE_ROOT/api/v1/checks/`
  211. Creates a new check and returns its ping URL.
  212. All request parameters are optional and will use their default
  213. values if omitted.
  214. With this API call, you can create both Simple and Cron checks:
  215. * To create a Simple check, specify the `timeout` parameter.
  216. * To create a Cron check, specify the `schedule` and `tz` parameters.
  217. ### Request Parameters
  218. name
  219. : string, optional, default value: ""
  220. Name for the new check.
  221. tags
  222. : string, optional, default value: ""
  223. A space-delimited list of tags for the new check.
  224. Example:
  225. <pre>{"tags": "reports staging"}</pre>
  226. desc
  227. : string, optional.
  228. Description of the check.
  229. timeout
  230. : number, optional, default value: {{ default_timeout }}.
  231. A number of seconds, the expected period of this check.
  232. Minimum: 60 (one minute), maximum: 2592000 (30 days).
  233. Example for a 5-minute timeout:
  234. <pre>{"kind": "simple", "timeout": 300}</pre>
  235. grace
  236. : number, optional, default value: {{ default_grace }}.
  237. A number of seconds, the grace period for this check.
  238. Minimum: 60 (one minute), maximum: 2592000 (30 days).
  239. schedule
  240. : string, optional, default value: "`* * * * *`".
  241. A cron expression defining this check's schedule.
  242. If you specify both `timeout` and `schedule` parameters,
  243. SITE_NAME will create a Cron check and ignore
  244. the `timeout` value.
  245. Example for a check running every half-hour:
  246. <pre>{"schedule": "0,30 * * * *"}</pre>
  247. tz
  248. : string, optional, default value: "UTC".
  249. Server's timezone. This setting only has an effect in combination with the
  250. `schedule` parameter.
  251. Example:
  252. <pre>{"tz": "Europe/Riga"}</pre>
  253. manual_resume
  254. : boolean, optional, default value: false.
  255. Controls whether a paused check automatically resumes when pinged (the default)
  256. or not. If set to false, a paused check will leave the paused state when it receives
  257. a ping. If set to true, a paused check will ignore pings and stay paused until
  258. you manually resume it from the web dashboard.
  259. methods
  260. : string, optional, default value: "".
  261. Specifies the allowed HTTP methods for making ping requests.
  262. Must be one of the two values: "" (an empty string) or "POST".
  263. Set this field to "" (an empty string) to allow HEAD, GET,
  264. and POST requests.
  265. Set this field to "POST" to allow only POST requests.
  266. Example:
  267. <pre>{"methods": "POST"}</pre>
  268. channels
  269. : string, optional
  270. By default, this API call assigns no integrations to the newly created
  271. check.
  272. Set this field to a special value "*" to automatically assign all existing
  273. integrations. Example:
  274. <pre>{"channels": "*"}</pre>
  275. To assign specific integrations, use a comma-separated list of integration
  276. UUIDs. You can look up integration UUIDs using the
  277. [Get a List of Existing Integrations](#list-channels) API call.
  278. Example:
  279. <pre>{"channels":
  280. "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"}</pre>
  281. Alternatively, if you have named your integrations in SITE_NAME dashboard,
  282. you can specify integrations by their names. For this to work, your integrations
  283. need non-empty unique names, and they must not contain commas.
  284. The names must match exactly, whitespace is significant.
  285. Example:
  286. <pre>{"channels": "Email to Alice,SMS to Alice"}</pre>
  287. unique
  288. : array of string values, optional, default value: [].
  289. Enables "upsert" functionality. Before creating a check, SITE_NAME looks for
  290. existing checks, filtered by fields listed in `unique`.
  291. If SITE_NAME does not find a matching check, it creates a new check and returns it
  292. with the HTTP status code 201.
  293. If SITE_NAME finds a matching check, it updates the existing check and
  294. returns it with HTTP status code 200.
  295. The accepted values for the `unique` field are
  296. `name`, `tags`, `timeout`, and `grace`.
  297. Example:
  298. <pre>{"name": "Backups", unique: ["name"]}</pre>
  299. In this example, if a check named "Backups" exists, it will be returned.
  300. Otherwise, a new check will be created and returned.
  301. ### Response Codes
  302. 201 Created
  303. : A new check was successfully created.
  304. 200 OK
  305. : An existing check was found and updated.
  306. 400 Bad Request
  307. : The request is not well-formed, violates schema, or uses invalid
  308. field values.
  309. 401 Unauthorized
  310. : The API key is either missing or invalid.
  311. 403 Forbidden
  312. : The account has hit its check limit. For free accounts,
  313. the limit is 20 checks per account.
  314. ### Example Request
  315. ```bash
  316. curl SITE_ROOT/api/v1/checks/ \
  317. --header "X-Api-Key: your-api-key" \
  318. --data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
  319. ```
  320. Or, alternatively:
  321. ```bash
  322. curl SITE_ROOT/api/v1/checks/ \
  323. --data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
  324. ```
  325. ### Example Response
  326. ```json
  327. {
  328. "channels": "",
  329. "desc": "",
  330. "grace": 60,
  331. "last_ping": null,
  332. "n_pings": 0,
  333. "name": "Backups",
  334. "next_ping": null,
  335. "manual_resume": false,
  336. "methods": "",
  337. "pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
  338. "ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
  339. "status": "new",
  340. "tags": "prod www",
  341. "timeout": 3600,
  342. "update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc",
  343. }
  344. ```
  345. ## Update an Existing Check {: #update-check .rule }
  346. `POST SITE_ROOT/api/v1/checks/<uuid>`
  347. Updates an existing check. All request parameters are optional. If you omit any
  348. parameter, SITE_NAME will leave its value unchanged.
  349. ### Request Parameters
  350. name
  351. : string, optional.
  352. Name for the check.
  353. tags
  354. : string, optional.
  355. A space-delimited list of tags for the check.
  356. Example:
  357. <pre>{"tags": "reports staging"}</pre>
  358. desc
  359. : string, optional.
  360. Description of the check.
  361. timeout
  362. : number, optional.
  363. A number of seconds, the expected period of this check.
  364. Minimum: 60 (one minute), maximum: 2592000 (30 days).
  365. Example for a 5-minute timeout:
  366. <pre>{"kind": "simple", "timeout": 300}</pre>
  367. grace
  368. : number, optional.
  369. A number of seconds, the grace period for this check.
  370. Minimum: 60 (one minute), maximum: 2592000 (30 days).
  371. schedule
  372. : string, optional.
  373. A cron expression defining this check's schedule.
  374. If you specify both `timeout` and `schedule` parameters,
  375. SITE_NAME will save the `schedule` parameter and ignore
  376. the `timeout`.
  377. Example for a check running every half-hour:
  378. <pre>{"schedule": "0,30 * * * *"}</pre>
  379. tz
  380. : string, optional.
  381. Server's timezone. This setting only has an effect in combination with the
  382. "schedule" parameter.
  383. Example:
  384. <pre>{"tz": "Europe/Riga"}</pre>
  385. manual_resume
  386. : boolean, optional, default value: false.
  387. Controls whether a paused ping automatically resumes when pinged (the default),
  388. or not. If set to false, a paused check will leave the paused state when it receives
  389. a ping. If set to true, a paused check will ignore pings and stay paused until
  390. you manually resume it from the web dashboard.
  391. methods
  392. : string, optional, default value: "".
  393. Specifies the allowed HTTP methods for making ping requests.
  394. Must be one of the two values: "" (an empty string) or "POST".
  395. Set this field to "" (an empty string) to allow HEAD, GET,
  396. and POST requests.
  397. Set this field to "POST" to allow only POST requests.
  398. Example:
  399. <pre>{"methods": "POST"}</pre>
  400. channels
  401. : string, optional.
  402. Set this field to a special value "*" to automatically assign all existing
  403. integrations. Example:
  404. <pre>{"channels": "*"}</pre>
  405. Set this field to a special value "" (empty string) to automatically *unassign*
  406. all existing integrations. Example:
  407. <pre>{"channels": ""}</pre>
  408. To assign specific integrations, use a comma-separated list of integration
  409. UUIDs. You can look up integration UUIDs using the
  410. [Get a List of Existing Integrations](#list-channels) API call.
  411. Example:
  412. <pre>{"channels":
  413. "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"}</pre>
  414. Alternatively, if you have named your integrations in SITE_NAME dashboard,
  415. you can specify integrations by their names. For this to work, your integrations
  416. need non-empty and unique names, and they must not contain commas. The names
  417. must match exactly, whitespace is significant.
  418. Example:
  419. <pre>{"channels": "Email to Alice,SMS to Alice"}</pre>
  420. ### Response Codes
  421. 200 OK
  422. : The check was successfully updated.
  423. 400 Bad Request
  424. : The request is not well-formed, violates schema, or uses invalid
  425. field values.
  426. 401 Unauthorized
  427. : The API key is either missing or invalid.
  428. 403 Forbidden
  429. : Access denied, wrong API key.
  430. 404 Not Found
  431. : The specified check does not exist.
  432. ### Example Request
  433. ```bash
  434. curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
  435. --header "X-Api-Key: your-api-key" \
  436. --data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
  437. ```
  438. Or, alternatively:
  439. ```bash
  440. curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
  441. --data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
  442. ```
  443. ### Example Response
  444. ```json
  445. {
  446. "channels": "",
  447. "desc": "",
  448. "grace": 60,
  449. "last_ping": null,
  450. "n_pings": 0,
  451. "name": "Backups",
  452. "next_ping": null,
  453. "manual_resume": false,
  454. "methods": "",
  455. "pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
  456. "ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
  457. "status": "new",
  458. "tags": "prod www",
  459. "timeout": 3600,
  460. "update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc",
  461. }
  462. ```
  463. ## Pause Monitoring of a Check {: #pause-check .rule }
  464. `POST SITE_ROOT/api/v1/checks/<uuid>/pause`
  465. Disables monitoring for a check without removing it. The check goes into a "paused"
  466. state. You can resume monitoring of the check by pinging it.
  467. This API call has no request parameters.
  468. ### Response Codes
  469. 200 OK
  470. : The check was successfully paused.
  471. 401 Unauthorized
  472. : The API key is either missing or invalid.
  473. 403 Forbidden
  474. : Access denied, wrong API key.
  475. 404 Not Found
  476. : The specified check does not exist.
  477. ### Example Request
  478. ```bash
  479. curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause \
  480. --request POST --header "X-Api-Key: your-api-key" --data ""
  481. ```
  482. Note: the `--data ""` argument forces curl to send a `Content-Length` request header
  483. even though the request body is empty. For HTTP POST requests, the `Content-Length`
  484. header is sometimes required by some network proxies and web servers.
  485. ### Example Response
  486. ```json
  487. {
  488. "channels": "",
  489. "desc": "",
  490. "grace": 60,
  491. "last_ping": null,
  492. "n_pings": 0,
  493. "name": "Backups",
  494. "next_ping": null,
  495. "manual_resume": false,
  496. "methods": "",
  497. "pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
  498. "ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
  499. "status": "paused",
  500. "tags": "prod www",
  501. "timeout": 3600,
  502. "update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"
  503. }
  504. ```
  505. ## Delete Check {: #delete-check .rule }
  506. `DELETE SITE_ROOT/api/v1/checks/<uuid>`
  507. Permanently deletes the check from the user's account. Returns JSON representation of the
  508. check that was just deleted.
  509. This API call has no request parameters.
  510. ### Response Codes
  511. 200 OK
  512. : The check was successfully deleted.
  513. 401 Unauthorized
  514. : The API key is either missing or invalid.
  515. 403 Forbidden
  516. : Access denied, wrong API key.
  517. 404 Not Found
  518. : The specified check does not exist.
  519. ### Example Request
  520. ```bash
  521. curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
  522. --request DELETE --header "X-Api-Key: your-api-key"
  523. ```
  524. ### Example Response
  525. ```json
  526. {
  527. "channels": "",
  528. "desc": "",
  529. "grace": 60,
  530. "last_ping": null,
  531. "n_pings": 0,
  532. "name": "Backups",
  533. "next_ping": null,
  534. "manual_resume": false,
  535. "methods": "",
  536. "pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
  537. "ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
  538. "status": "new",
  539. "tags": "prod www",
  540. "timeout": 3600,
  541. "update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc",
  542. }
  543. ```
  544. ## Get a list of check's logged pings {: #list-pings .rule }
  545. `GET SITE_ROOT/api/v1/checks/<uuid>/pings/`
  546. Returns a list of pings this check has received.
  547. This endpoint returns pings in reverse order (most recent first), and the total
  548. number of returned pings depends on the account's billing plan: 100 for free accounts,
  549. 1000 for paid accounts.
  550. ### Response Codes
  551. 200 OK
  552. : The request succeeded.
  553. 401 Unauthorized
  554. : The API key is either missing or invalid.
  555. 403 Forbidden
  556. : Access denied, wrong API key.
  557. 404 Not Found
  558. : The specified check does not exist.
  559. ### Example Request
  560. ```bash
  561. curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pings/ \
  562. --header "X-Api-Key: your-api-key"
  563. ```
  564. ### Example Response
  565. ```json
  566. {
  567. "pings": [
  568. {
  569. "type": "success",
  570. "date": "2020-06-09T14:51:06.113073+00:00",
  571. "n": 4,
  572. "scheme": "http",
  573. "remote_addr": "192.0.2.0",
  574. "method": "GET",
  575. "ua": "curl/7.68.0",
  576. "duration": 2.896736
  577. },
  578. {
  579. "type": "start",
  580. "date": "2020-06-09T14:51:03.216337+00:00",
  581. "n": 3,
  582. "scheme": "http",
  583. "remote_addr": "192.0.2.0",
  584. "method": "GET",
  585. "ua": "curl/7.68.0"
  586. },
  587. {
  588. "type": "success",
  589. "date": "2020-06-09T14:50:59.633577+00:00",
  590. "n": 2,
  591. "scheme": "http",
  592. "remote_addr": "192.0.2.0",
  593. "method": "GET",
  594. "ua": "curl/7.68.0",
  595. "duration": 2.997976
  596. },
  597. {
  598. "type": "start",
  599. "date": "2020-06-09T14:50:56.635601+00:00",
  600. "n": 1,
  601. "scheme": "http",
  602. "remote_addr": "192.0.2.0",
  603. "method": "GET",
  604. "ua": "curl/7.68.0"
  605. }
  606. ]
  607. }
  608. ```
  609. ## Get a list of check's status changes {: #list-flips .rule }
  610. `GET SITE_ROOT/api/v1/checks/<uuid>/flips/`<br>
  611. `GET SITE_ROOT/api/v1/checks/<unique_key>/flips/`
  612. Returns a list of "flips" this check has experienced. A flip is a change of status
  613. (from "down" to "up," or from "up" to "down").
  614. ### Query String Parameters
  615. seconds=&lt;value&gt;
  616. : Returns the flips from the last `value` seconds
  617. Example:
  618. `SITE_ROOT/api/v1/checks/<uuid|unique_key>/flips/?seconds=3600`
  619. start=&lt;value&gt;
  620. : Returns flips that are newer than the specified UNIX timestamp.
  621. Example:
  622. `SITE_ROOT/api/v1/checks/<uuid|unique_key>/flips/?start=1592214380`
  623. end=&lt;value&gt;
  624. : Returns flips that are older than the specified UNIX timestamp.
  625. Example:
  626. `SITE_ROOT/api/v1/checks/<uuid|unique_key>/flips/?end=1592217980`
  627. ### Response Codes
  628. 200 OK
  629. : The request succeeded.
  630. 400 Bad Request
  631. : Invalid query parameters.
  632. 401 Unauthorized
  633. : The API key is either missing or invalid.
  634. 403 Forbidden
  635. : Access denied, wrong API key.
  636. 404 Not Found
  637. : The specified check does not exist.
  638. ### Example Request
  639. ```bash
  640. curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/flips/ \
  641. --header "X-Api-Key: your-api-key"
  642. ```
  643. ### Example Response
  644. ```json
  645. [
  646. {
  647. "timestamp": "2020-03-23T10:18:23+00:00",
  648. "up": 1
  649. },
  650. {
  651. "timestamp": "2020-03-23T10:17:15+00:00",
  652. "up": 0
  653. },
  654. {
  655. "timestamp": "2020-03-23T10:16:18+00:00",
  656. "up": 1
  657. }
  658. ]
  659. ```
  660. ## Get a List of Existing Integrations {: #list-channels .rule }
  661. `GET SITE_ROOT/api/v1/channels/`
  662. Returns a list of integrations belonging to the project.
  663. ### Response Codes
  664. 200 OK
  665. : The request succeeded.
  666. 401 Unauthorized
  667. : The API key is either missing or invalid.
  668. ### Example Request
  669. ```bash
  670. curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/channels/
  671. ```
  672. ### Example Response
  673. ```json
  674. {
  675. "channels": [
  676. {
  677. "id": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941",
  678. "name": "My Work Email",
  679. "kind": "email"
  680. },
  681. {
  682. "id": "746a083e-f542-4554-be1a-707ce16d3acc",
  683. "name": "My Phone",
  684. "kind": "sms"
  685. }
  686. ]
  687. }
  688. ```