API authentication

Get your API token

Once you are logged navigate to API Access and create your API token.

You can name your token, so you know where this one is going to be used, in case you ever need to revoke it.

Once you create a token, it'll be shown only once to you. Make sure to store it safely, after this it can only be revoked and you can generate a new token for use.

Once you have your token, you can authenticate against the application.

Authenticate against the API

The token you've received can be used as the Bearer authentication header.

Here's a curl example of how you can authenticate against the API. In this example, it'll list all sites in your account.

$ curl https://ohdear.app/api/sites \
    -H 'Authorization: Bearer bgUKSWYL30iHg5w0WTDGHfubt5L1HBTr0atAehCeSqwNTqkU9rOmsNEmWf6Y' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json'

The token bgUKSWYL30iHg5w0WTDGHfubt5L1HBTr0atAehCeSqwNTqkU9rOmsNEmWf6Y is used to authenticate, and the /api/sites endpoint is hit to retrieve all sites. The resulting response payload may look like this.

{
  "data": [
    {
      "id": 1,
      "url": "https://yoursite.tld",
      ...
    },
    {
      "id": 2,
      "url": "https://yourothersite.tld",
      ...
    }
  ]
}

The actual payload is actually much bigger, but that's described in more detail in the sites and checks page.