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.

121 lines
3.5 KiB

  1. {% extends "front/base_docs.html" %}
  2. {% load staticfiles %}
  3. {% block title %}REST API - healthchecks.io{% endblock %}
  4. {% block docs_content %}
  5. <h2>REST API</h2>
  6. <p>
  7. This is early days for healtchecks.io REST API. For now, there's just
  8. one API resource for listing and creating checks.
  9. </p>
  10. <h2 class="rule">Authentication</h2>
  11. <p>Your requests to healtchecks.io REST API must authenticate using an
  12. API key. By default, an user account on healthchecks.io doesn't have
  13. an API key. You can create one in the <a href="{% url 'hc-profile' %}">Settings</a> page.
  14. </p>
  15. <p>
  16. The API uses a simple authentication scheme: the API key should be
  17. included in the request body (a JSON document) along other fields.
  18. </p>
  19. <h2 class="rule">API Requests</h2>
  20. <p>
  21. For POST requests, the healthchecks.io API expects request body to be
  22. a JSON document (<em>not</em> a <code>mulitpart/form-data</code> encoded
  23. form data).
  24. </p>
  25. <h2 class="rule">API Responses</h2>
  26. <p>
  27. healthchecks.io uses HTTP status codes wherever possible.
  28. In general, 2xx class indicates success, 4xx indicates an client error,
  29. and 5xx indicates a server error.
  30. </p>
  31. <p>
  32. The response may contain a JSON document with additional data.
  33. </p>
  34. <h2 class="rule">List checks</h2>
  35. <div class="api-path">GET {{ SITE_ROOT }}/api/v1/checks/</div>
  36. <p>
  37. Returns a list of checks. This API call takes no parameters and returns
  38. a JSON document with all checks in user's account.
  39. </p>
  40. <h3 class="api-section">Example Request</h3>
  41. {% include "front/snippets/list_checks_request.html" %}
  42. <h3 class="api-section">Example Response</h3>
  43. {% include "front/snippets/list_checks_response.html" %}
  44. <h2 class="rule">Create a check</h2>
  45. <div class="api-path">POST {{ SITE_ROOT }}/api/v1/checks/</div>
  46. <strong></strong>
  47. <p>
  48. Creates a new check and returns its ping URL.
  49. All request parameters are optional and will use their default
  50. values if omitted.
  51. </p>
  52. <h3 class="api-section">Request Parameters</h3>
  53. <table class="table">
  54. <tr>
  55. <th>name</th>
  56. <td>
  57. <p>string, optional, default value: ""</p>
  58. <p>Name for the new check.</p>
  59. </td>
  60. </tr>
  61. <tr>
  62. <th>tags</th>
  63. <td>
  64. <p>string, optional, default value: ""</p>
  65. <p>A space-delimited list of tags for the new check.</p>
  66. </td>
  67. </tr>
  68. <tr>
  69. <th>timeout</th>
  70. <td>
  71. <p>number, optional, default value: {{ default_timeout }}.</p>
  72. <p>A number of seconds, the expected period of this check.</p>
  73. <p>Minimum: 60 (one minute), maximum: 604800 (one week).</p>
  74. </td>
  75. </tr>
  76. <tr>
  77. <th>grace</th>
  78. <td>
  79. <p>number, optional, default value: {{ default_grace }}.</p>
  80. <p>A number of seconds, the grace period for this check.</p>
  81. <p>Minimum: 60 (one minute), maximum: 604800 (one week).</p>
  82. </td>
  83. </tr>
  84. <tr>
  85. <th>channels</th>
  86. <td>
  87. <p>string, optional, default value: ""</p>
  88. <p>By default, if a check is created through API, no notification
  89. channels are assigned to it. So, when the check goes up or down,
  90. no notifications would be sent. Set this field to a special value "*"
  91. to automatically assign all existing notification channels.</p>
  92. </td>
  93. </tr>
  94. </table>
  95. <h3 class="api-section">Example Request</h3>
  96. {% include "front/snippets/create_check_request.html" %}
  97. <h3 class="api-section">Example Response</h3>
  98. {% include "front/snippets/create_check_response.html" %}
  99. {% endblock %}