---
title: "Security headers API"
description: "Grade a site's security headers from a script or a pipeline, with the exact lines that fix each failing test, and move from the securityheaders.com API in three changes."
url: https://xovris.ai/docs/manage/security-headers-api/
---

# Security headers API

The security headers API gives a site's grade, every test behind it and the lines that fix each failing test for the
server the site runs on. It grades exactly as the free [security headers checker](/tools/security-headers-checker/)
does, by Mozilla HTTP Observatory's published scoring, because both use the same code.

```sh
curl -s "https://api.xovris.ai/v1/tools/security-headers?host=xovris.ai" \
  -H "authorization: Bearer $XOVRIS_TOKEN"
```

[Create an API token](/docs/manage/api-tokens/)

## Your key and your allowance

Any Xovris API token is the key, including one from a Free workspace. A Free workspace checks 100 sites a day; any paid plan checks 2,000. Every answer carries
`RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`. Past the day's checks the answer is `429` with
`Retry-After` set to the seconds until midnight UTC, and a sentence saying when checks start again.

A check the scanner left unfinished is given back, never counted. A private, local or reserved name is refused with
`400` before anything is counted.

## What comes back

```json
{
  "host": "shop.northmerefreight.com",
  "grade": "B",
  "score": 70,
  "scannedAt": "2026-10-02T09:14:00.000Z",
  "observatoryGrade": "B",
  "tests": [
    {
      "name": "content-security-policy",
      "title": "Content Security Policy (CSP)",
      "pass": false,
      "result": "csp-not-implemented",
      "scoreModifier": -25,
      "link": "https://developer.mozilla.org/en-US/observatory/docs/tests_and_scoring"
    }
  ],
  "fix": {
    "server": "nginx",
    "failing": ["content-security-policy"],
    "lines": "add_header Content-Security-Policy \"default-src 'self'; ...\" always;"
  }
}
```

`grade` and `score` are worked out from the tests; `observatoryGrade` is the grade Observatory itself gave the same
site. `fix.server` is the server the site most likely runs on, read from its `Server` header; `fix.lines` are
the lines for that server.

## Use it from CI

This workflow grades the live site after every successful deploy and every morning, prints the grade, and fails the job with the exact lines to add when the score falls below the floor you set – and where the site runs behind Cloudflare, Xovris sets those headers at the edge itself once your DNS is connected, only where the site sends none of its own. Xovris also makes the token and writes it as the repository secret `XOVRIS_TOKEN` itself through the Xovris GitHub App, sealed and never shown. Do it yourself instead: store your token as the repository secret `XOVRIS_TOKEN` and set `SITE` to your domain.

```yaml
name: Security headers
on:
  deployment_status:
  schedule:
    - cron: '0 6 * * *'
jobs:
  grade:
    if: ${{ github.event_name == 'schedule' || github.event.deployment_status.state == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - name: Grade the live site's headers
        env:
          XOVRIS_TOKEN: ${{ secrets.XOVRIS_TOKEN }}
          SITE: yourdomain.com
          MIN_SCORE: '70'
        run: |
          r=$(curl -sf "https://api.xovris.ai/v1/tools/security-headers?host=$SITE" -H "authorization: Bearer $XOVRIS_TOKEN")
          echo "$r" | jq -r '"Grade \(.grade) (\(.score)) for \(.host)"'
          if [ "$(echo "$r" | jq '.score')" -lt "$MIN_SCORE" ]; then
            echo "$r" | jq -r '"Add these lines for \(.fix.server):\n\(.fix.lines)"'
            exit 1
          fi
```

## Moving from the securityheaders.com API

Three things change: the address, the key's header and where the grade is in the answer. The `q` parameter is accepted
as it is, so a script that builds `?q=` keeps working.

| securityheaders.com API | Xovris |
|---|---|
| `https://api.securityheaders.com/?q=…` | `/v1/tools/security-headers?q=…` (or `?host=…`) |
| `x-api-key: <key>` | `authorization: Bearer <Xovris API token>` |
| `summary.grade` | `grade`, with `score` beside it |
| `hide=on`, `followRedirects=on` | not used: drop them |

Before:

```sh
curl -s "https://api.securityheaders.com/?q=yourdomain.com&hide=on&followRedirects=on" \
  -H "x-api-key: $SECURITYHEADERS_KEY" | jq -r .summary.grade
```

After:

```sh
curl -s "https://api.xovris.ai/v1/tools/security-headers?host=xovris.ai" \
  -H "authorization: Bearer $XOVRIS_TOKEN" | jq -r .grade
```

What you gain: every test with its score and its link, the lines that fix each failing one for your server, and a key
you already hold on every plan.
