Working with REST

The Bloodbath API is organized around REST.

Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

Prerequisite

Get the list of events

curl <https://api.bloodbath.io/rest/events/> \\
  -H "Authorization: Bearer <Replace this with your API key>"

# OK Response
{
    "data": [
        {
            "endpoint": "<https://test.com>",
            "enqueued_at": null,
            "headers": "{}",
            "id": "226a9043-120e-49a5-a3ca-e942915020e4",
            "origin": "rest_api",
            "body": "{test: true}",
            "processed_at": null,
            "scheduled_for": "2021-05-09T00:04:34Z"
        },
        {
            "endpoint": "<https://test.com>",
            "enqueued_at": null,
            "headers": "{}",
            "id": "2d8e90be-4e3c-4236-8de9-9473b3143c26",
            "origin": "rest_api",
            "body": "{test: true}",
            "processed_at": null,
            "scheduled_for": "2021-05-09T00:04:36Z"
        },
		]
}

Find a specific event

curl <https://api.bloodbath.io/rest/events/><UUID of the event> \\
  -H "Authorization: Bearer <Replace this with your API key>"

# OK Response
{
    "data": {
        "endpoint": "<https://test.com>",
        "enqueued_at": null,
        "headers": "{}",
        "id": "226a9043-120e-49a5-a3ca-e942915020e4",
        "origin": "rest_api",
        "body": "{test: true}",
        "processed_at": null,
        "scheduled_for": "2021-05-09T00:04:34Z"
    }
}

Schedule a new event

curl <https://api.bloodbath.io/rest/events/> \\
  -H "Authorization: Bearer <Replace this with your API key>" \\
  -d scheduled_for="2021-05-01T00:00:00Z" \\
  -d headers="{}" \\
  -d body="{test: test}" \\
  -d method="post" \\
  -d endpoint="<https://dummy.bloodbath.io>"

# OK Response
{
    "data": {
        "endpoint": "<https://test.com>",
        "enqueued_at": null,
        "headers": "{}",
        "id": "226a9043-120e-49a5-a3ca-e942915020e4",
        "origin": "rest_api",
        "body": "{hello:true}",
        "processed_at": null,
        "scheduled_for": "2021-05-09T00:04:34Z"
    }
}

Cancel an existing event

You can't cancel events that were already enqueued and/or processed

curl <https://api.bloodbath.io/rest/events/><UUID of the event> \\
  -H "Authorization: Bearer <Replace this with your API key>" \\
	-X DELETE

# OK Response
{
  "data": null
}

Last updated