Generic Webhooks

You can send an alert for every API call you make, or just those that have failed or generated a warning

If you'd like to use a custom integration, you can use our Generic Webhooks to receive alerts on API call results.

To set it up, you just need to provide us with a URL that is publicly accessible. This could be something as simple as a AWS Lambda or a Google Cloud function.

We use a HTTP POST to send you the following data:

{
    "call_id": "agxkZXZ-dmlhdGVzdHNyFwsSClRlc3RTZXR1cDIYgICAgICA0AkM",
    "call_meta": {
      "description": "Auto-generated API Call",
      "name": "Example HTTP POST Call",
      "tags": [
        "api_type:update",
        "sector:telecommunications"
      ]
    },
    "call_url": "https://client.apimetrics.io/tests/test/agxkZXZ-dmlhdGVzdHNyFwsSClRlc3RTZXR1cDIYgICAgICA0AkM/",
    "context": {},
    "http_code": 200,
    "http_reason": "OK",
    "location_id": "public_awsuseast",
    "response_size": 135,
    "response_time": 80,
    "result": "COMPLETE",
    "result_class": "PASS",
    "result_id": "agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgIQJDA",
    "result_url": "https://client.apimetrics.io/tests/result/agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgIQJDA/"
}

Note that the result_class will be one of PASS, SLOW, WARNING, or FAIL.
The result is more granular - those can be:

  • For WARNING class: CONNECTION_WARNING, HTTP_REDIRECT_ERROR, HTTP_CLIENT_ERROR, CONTENT_WARNING, SLA_WARNING.
  • For FAIL class: HTTP_SERVER_ERROR, CONNECTION_ERROR, HEADER_ERROR, CONTENT_ERROR, SLA_ERROR.
  • For PASS class: COMPLETE.
  • For SLOW class: SLOW_COMPLETE.

If you have the Webhooks set for failures or warnings, we also include extra data in there, in context, we have the notification data that is displayed in our UI (under _notification):

{
    "call_id": "agxkZXZ-dmlhdGVzdHNyFwsSClRlc3RTZXR1cDIYgICAgICA0AkM",
    "call_meta": {
      "description": "Auto-generated API Call",
      "name": "Example HTTP POST Call",
      "tags": [
        "api_type:update",
        "sector:telecommunications"
      ]
    },
    "call_url": "https://client.apimetrics.io/tests/test/agxkZXZ-dmlhdGVzdHNyFwsSClRlc3RTZXR1cDIYgICAgICA0AkM/",
    "context": {
      "_notification": {
        "category": "WARNING",
        "created": "2019-06-05T17:11:36.444708Z",
 
        "description": "\n<p>\nAPI Call <a href=\"https://client.apimetrics.io/tests/test/agxkZXZ-dmlhdGVzdHNyFwsSClRlc3RTZXR1cDIYgICAgICA0AkM/\">\"Example HTTP POST Call\"</a> has failed :\n<ul>\n<li><b>Server returned a 4XX status. There may be a problem with the test.</b></li>\n\n<li>Calling POST http://google.apimetrics.xyz/status/418</li>\n<li>Got response HTTP 418 I&#39;M A TEAPOT</li>\n\n</ul>\n</p>\n\n<p>Timing breakdown:\n<ul>\n\n<li>The total latency was 56 ms.</li>\n<li>DNS Lookup: 4 ms</li>\n<li>Connect: 24 ms</li>\n\n<li>Upload: 0 ms</li>\n<li>Processing: 0 ms</li>\n<li>Download: 28 ms</li>\n\n</ul>\n</p>\n\n\n</p>\n\n<p>\nView details here:\n<a href=\"https://client.apimetrics.io/tests/result/agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgPgJDA/\">https://client.apimetrics.io/tests/result/agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgPgJDA/</a>\n</p>\n\n<p>Sincerely,<br>\nAPImetrics Team\n</p>\n",
 
        "description_text": "\nAPI Call \"Example HTTP POST Call\" (http://localhost:8080/tests/test/agxkZXZ-dmlhdGVzdHNyFwsSClRlc3RTZXR1cDIYgICAgICA0AkM/) has failed :\n\nServer returned a 4XX status. There may be a problem with the test.\nCalling POST http://google.apimetrics.xyz/status/418\nGot response HTTP 418 I&#39;M A TEAPOT\nTiming breakdown:\n  The total latency was 56 ms.\n  DNS Lookup: 4 ms\n  Connect: 24 ms\n\n  Upload: 0 ms\n  Processing: 0 ms\n  Download: 28 ms\n\n\nView details here: \nhttp://localhost:8080/tests/result/agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgPgJDA/\n\n\nAPImetrics Team\n",
 
        "last_update": "2019-06-05T17:11:36.588106Z",
        "owners": [
          "agxkZXZ-dmlhdGVzdHNyEQsSBFVzZXIYgICAgICA0AoM",
          "public_settings"
        ],
        "references": [
          "agxkZXZ-dmlhdGVzdHNyFwsSClRlc3RTZXR1cDIYgICAgICA0AkM",
          "agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgPgJDA"
        ],
        "title": "[WARNING]: APImetrics: All Failures: Example HTTP POST Call",
        "viewed_by": []
      },
      "_result_category": "WARNING",
      "_result_streak": 1
    },
    "http_code": 418,
    "http_reason": "I'M A TEAPOT",
    "location_id": "development",
    "response_size": 135,
    "response_time": 56,
    "result": "HTTP_CLIENT_ERROR",
    "result_class": "WARNING",
    "result_id": "agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgPgJDA",
    "result_url": " https://client.apimetrics.io/tests/result/agxkZXZ-dmlhdGVzdHNyGAsSC1Rlc3RSZXN1bHQzGICAgICAgPgJDA/"
}