> For the complete documentation index, see [llms.txt](https://docs.bloodbath.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bloodbath.io/api/graphql.md).

# Working with GraphQL

It's the same API we use internally for developing our applications, most notably our own dashboard. We follow a [Relay style](https://relay.dev/) of schema.

If you're new to GraphQL, Apollo has [resources for beginners](https://blog.apollographql.com/the-basics-of-graphql-in-5-links-9e1dc4cac055). [The official documentation](https://graphql.org/) is another good starting point.

## Prerequisite

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

## Endpoint

Bloodbath's GraphQL endpoint is:

```
https://api.bloodbath.io/graphql
```

It supports introspection so you can query the whole schema.

## Authorization

To start querying the endpoint, you must add the API key to your `authorization` headers.

```
{
  "headers": {
    "authorization": "Bearer <Your API key>"
  }
}
```

### Check your access

Once you have the headers in place you can ping the GraphQL API

```
query ping {
  ping {
    receivedAt
  }
}
```

It should respond with something like

```
{
  "data": {
    "ping": {
      "receivedAt": "2021-05-23T20:45:44.409594Z"
    }
  }
}
```

## Examples

### List events

```
query listEvents {
  listEvents(first: 5) {
    pageInfo {
      startCursor
    }
    edges {
      node {
      id
      eventId
      method
      lockedAt
      }
    }
  }
}
```

{% hint style="info" %}
You'll notice that a difference between id and eventId; we have a **Relay style schema.** It means we have to map a node id and the event id has to be put on the side.
{% endhint %}

### Find an event

```
query findEvent{
  findEvent(
    id: "f6596250-044b-4070-a256-31f0977ea4f3"
  ) {
    eventId
    scheduledFor
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.bloodbath.io/api/graphql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
