# Working with 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

{% content-ref url="/pages/-MkXsUqmKJQVh5Cpqa7b" %}
[Acquire your API key](/getting-started/acquire-your-api-key.md)
{% endcontent-ref %}

## 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

{% hint style="info" %}
You can't cancel events that were already enqueued and/or processed
{% endhint %}

```
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
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bloodbath.io/api/rest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
