# Prufy API

Prove a domain is yours with one DNS record, and keep it proven. Everything the Prufy app does, it does through this API, so anything you can do there you can build yourself.

> **No API keys yet**
>
> Today the only credential is the session cookie that your first claim sets. Keys for server-to-server callers are designed and come next. Addresses are versioned, so they won't change when keys land.

## Your first request

Send a domain. You get back a claim, and inside it the one TXT record that proves the domain is yours. No sign-up comes first: the response sets a session cookie, and that cookie is what makes the claim yours.

**cURL**

```shell
curl -X POST 'https://www.prufy.dev/api/v1/claims' \
  -c cookies.txt -b cookies.txt \
  -H 'content-type: application/json' \
  -d '{
  "input": "yourcompany.com"
}'
```

**Node.js**

```javascript
const response = await fetch("https://www.prufy.dev/api/v1/claims", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ input: "yourcompany.com" }),
})

// The session cookie is what makes this claim yours. Keep it for later requests.
const cookie = response.headers.getSetCookie()[0]?.split(";")[0]
const data = await response.json()
```

**Python**

```python
import requests

# A Session keeps the cookie the response sets, and sends it from then on.
session = requests.Session()

response = session.post(
    "https://www.prufy.dev/api/v1/claims",
    json={"input": "yourcompany.com"},
)
data = response.json()
```

The part to act on is `view.record`: add it at the domain's DNS provider, then [run a check](https://www.prufy.dev/docs/api-reference/run-check.md) or wait for ours. The whole answer is on the [Create a claim](https://www.prufy.dev/docs/api-reference/create-claim.md) page.

The record to add

```json
{
  "record": {
    "type": "TXT",
    "host": "_prufy-challenge",
    "fullName": "_prufy-challenge.yourcompany.com",
    "value": "prufy-domain-verification=xwqyp4hnsmgqxceo2xd6orgeay",
    "ttl": 300
  }
}
```

Requests and responses are JSON. The base address is `https://www.prufy.dev`, and the whole API is described in one [OpenAPI document](https://www.prufy.dev/api/v1/openapi.json), generated from the same schemas the server validates with.

> **Try it without a real domain**
>
> Every example on this site runs against a local server in fixture mode, where a set of demo domains answer with each outcome a check can have. Pick `localhost:5200` in any request example to point them all there. [How to start it](https://www.prufy.dev/docs/guides/verify-a-domain.md).

## The basics

[Verify a domain in five minutes](https://www.prufy.dev/docs/guides/verify-a-domain.md)

Create a claim, add the record, run a check. Start to verified.

[Authentication](https://www.prufy.dev/docs/authentication.md)

Sessions without sign-up, and the tokens that stand in for one.

[Errors](https://www.prufy.dev/docs/errors.md)

One shape for every error, and what each kind means.

[Rate limits](https://www.prufy.dev/docs/rate-limits.md)

How often each thing can be done, and what a limited response says.

## Versioning

Every route lives under `/api/v1`. Within a version, changes only add: a new route, a new optional field in a request, a new field in a response, or a new value in a list that says it can grow. Removing or renaming a field, changing its type, or making something required is a new version.

- Ignore fields you don't know. A response may gain fields at any time.
- Expect new values in open lists. An event's `type`, an error's `kind` and a check's `trigger` can gain values. Skip an event you don't know, and treat an unknown error by its HTTP status.
- Watch for two headers. A deprecated address answers with `Deprecation` and `Sunset`, and a `Link` to its replacement.

The addresses from before versioning, like `/api/claims` for `/api/v1/claims`, still answer the same way, with those headers. They stay until at least 2027-06-01, and until the clients still calling them have moved. The unsubscribe address in alert emails never goes away.

## Foundations

[Claim lifecycle](https://www.prufy.dev/docs/claim-lifecycle.md)

The seven statuses, what moves a claim between them, and when we check.

[What each failure means](https://www.prufy.dev/docs/guides/failures.md)

Every outcome a check can have, and the one thing that fixes it.

[Keep a domain verified](https://www.prufy.dev/docs/guides/keep-a-domain-verified.md)

Re-checks, the grace period, alerts, and getting ownership back.

## API reference

One page per route, each with the request in three languages and a real response.

### Claims

- POST [Create a claim](https://www.prufy.dev/docs/api-reference/create-claim.md) Start proving a domain is yours, and get the one DNS record to add.
- GET [List claims](https://www.prufy.dev/docs/api-reference/list-claims.md) Every domain this session has claimed, with where each one stands.
- GET [Retrieve a claim](https://www.prufy.dev/docs/api-reference/retrieve-claim.md) One claim: its status, the record to add, the last check and its history.
- POST [Run a check](https://www.prufy.dev/docs/api-reference/run-check.md) Look for the record now, without waiting for the next scheduled check.
- POST [Get a new code](https://www.prufy.dev/docs/api-reference/rotate-challenge.md) Replace the claim's code with a fresh one that works for 7 days.
- POST [Abandon a claim](https://www.prufy.dev/docs/api-reference/abandon-claim.md) Stop a claim you no longer want. It can't be undone.
- GET [Get the record as a zone-file line](https://www.prufy.dev/docs/api-reference/zone-file.md) The record in BIND zone-file format, for providers that take an import.

### Setup links

- POST [Create a setup link](https://www.prufy.dev/docs/api-reference/create-setup-link.md) Make a link that lets someone else add the record, and optionally email it.
- GET [Retrieve a claim by setup link](https://www.prufy.dev/docs/api-reference/retrieve-setup.md) What the person helping gets to see: the record, the steps and the status.
- POST [Run a check by setup link](https://www.prufy.dev/docs/api-reference/run-setup-check.md) Look for the record now, on behalf of whoever holds the link.

### Alerts

- GET [Retrieve alert settings](https://www.prufy.dev/docs/api-reference/retrieve-alert-settings.md) Where alerts go for this session, and which channels this server can use.
- PUT [Set the alert email](https://www.prufy.dev/docs/api-reference/set-alert-email.md) Choose the address alerts go to. We send a confirmation link first.
- DEL [Remove the alert email](https://www.prufy.dev/docs/api-reference/remove-alert-email.md) Stop sending alerts by email and forget the address.
- POST [Confirm the alert email](https://www.prufy.dev/docs/api-reference/confirm-alert-email.md) Turn a confirmation token into a confirmed address.
- POST [Unsubscribe from alert emails](https://www.prufy.dev/docs/api-reference/unsubscribe-alert-email.md) Stop alert emails using the token from any alert's footer.
- POST [Subscribe a browser to push](https://www.prufy.dev/docs/api-reference/subscribe-push.md) Register a browser's push subscription, so alerts arrive as notifications.
- DEL [Unsubscribe a browser from push](https://www.prufy.dev/docs/api-reference/unsubscribe-push.md) Remove one browser's push subscription.
- POST [Send a test alert](https://www.prufy.dev/docs/api-reference/send-test-alert.md) Send a sample alert to every channel this account has set up.

### Signing in

- POST [Request a sign-in link](https://www.prufy.dev/docs/api-reference/request-sign-in.md) Email a sign-in link to an account's confirmed alert address.
- POST [Use a sign-in link](https://www.prufy.dev/docs/api-reference/redeem-sign-in.md) Turn the token from a sign-in link into a session on this device.
- POST [Redeem a sign-in code](https://www.prufy.dev/docs/api-reference/redeem-sign-in-code.md) A terminal trades the page's code and its own secret for a session.
- GET [Retrieve this session](https://www.prufy.dev/docs/api-reference/retrieve-session.md) Whether this device is signed in, and how many devices share the account.
- DEL [Sign out](https://www.prufy.dev/docs/api-reference/sign-out.md) End this device's session on the server and clear its cookie.
- DEL [Sign out everywhere else](https://www.prufy.dev/docs/api-reference/sign-out-others.md) End every other session on this account. This one stays signed in.

### Domain Connect

- POST [Get a one-click setup URL](https://www.prufy.dev/docs/api-reference/domain-connect-url.md) A signed link to the DNS provider's own page, where the owner approves the record.

### System

- GET [Check the API is up](https://www.prufy.dev/docs/api-reference/health.md) Answers `{ ok: true }` when the server is running and its database answers.

### Development

- GET [Inspect a name's DNS](https://www.prufy.dev/docs/api-reference/inspect-dns.md) What every resolver answers for any name, without creating a claim.
- POST [Move the clock forward](https://www.prufy.dev/docs/api-reference/advance-clock.md) Advance the server's clock, so time-based states can be reached by hand.
- POST [Run the worker](https://www.prufy.dev/docs/api-reference/run-worker.md) Do everything that's due right now: scheduled checks, expiries and lapses.

---

Every page of these docs, as a list: https://www.prufy.dev/llms.txt
