# REST API

# REST API Guide

<p class="callout warning">This API is currently in beta. New API methods will be added soon.</p>

**Version 0.1 beta.** If you are viewing the REST API guide as a PDF file, you can always check for the latest version here:

---

#### Introduction

The SafeDNS REST API allows you to automate interactions with your SafeDNS account. It provides methods for retrieving filtering policy information, creating and managing Encrypted DNS devices, and more.

<div dir="auto" id="bkmrk--0"><div dir="auto">---

</div></div>#### Description

<p class="callout warning">API address: **https://www.safedns.com/auth/rest\_api/v1/**</p>

<div dir="auto" id="bkmrk--1"><div dir="auto">---

</div></div><div class="pointer-container" id="bkmrk-%C2%A0"><div class="pointer anim is-page-editable"><svg class="svg-icon" data-icon="link" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg><div class="input-group inline block"> <button class="button outline icon" data-clipboard-target="#pointer-url" title="Copy Link" type="button"><svg class="svg-icon" data-icon="copy" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></button></div><svg class="svg-icon" data-icon="edit" role="presentation" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"></svg></div></div>##### Table of available methods

<table border="1" id="bkmrk-%23-type-method-descri" style="border-collapse: collapse; width: 100%; height: 238.375px;"><tbody><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">**\#**</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">**Type**</td><td class="align-center" style="width: 36.5876%; height: 29.7969px;">**Method**</td><td class="align-center" style="width: 51.6695%; height: 29.7969px;">**Description**</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">1</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">POST</td><td style="width: 36.5876%; height: 29.7969px;">**User authorization**</td><td style="width: 51.6695%; height: 29.7969px;">Authorization of the user. Returns user\_id.</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">2</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">GET</td><td style="width: 36.5876%; height: 29.7969px;">**Retrieving a list of filtering policies**</td><td style="width: 51.6695%; height: 29.7969px;">Returns a list of all policies created by the user.</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">3</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">POST</td><td style="width: 36.5876%; height: 29.7969px;">**Creating an Encrypted DNS record**</td><td style="width: 51.6695%; height: 29.7969px;">Creates an Encrypted DNS device record.</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">4</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">PATCH</td><td style="width: 36.5876%; height: 29.7969px;">**Editing an Encrypted DNS record name**</td><td style="width: 51.6695%; height: 29.7969px;">Changes the Encrypted DNS record name.</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">5</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">DELETE</td><td style="width: 36.5876%; height: 29.7969px;">**Deleting an Encrypted DNS record**</td><td style="width: 51.6695%; height: 29.7969px;">Deletes the Encrypted DNS record.</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">6</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">POST</td><td style="width: 36.5876%; height: 29.7969px;">**Creating several Encrypted DNS records**</td><td style="width: 51.6695%; height: 29.7969px;">Creates several Encrypted DNS records at once.</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 3.58467%; height: 29.7969px;">7</td><td class="align-center" style="width: 8.15822%; height: 29.7969px;">GET</td><td style="width: 36.5876%; height: 29.7969px;">**Retrieving a list of Encrypted DNS records**</td><td style="width: 51.6695%; height: 29.7969px;">Returns a list of all Encrypted DNS records.</td></tr></tbody></table>

---

#### Methods

##### 1. User authorization

Authorization of the user.

**Request type:** POST  
**URL:** https://www.safedns.com/auth/rest\_api/v1/login/session/  
**Request body:**

```JSON
{
  "username": "your_login",
  "password": "your_password"
}
```

The reply contains the **user\_id**.

---

##### 2. Retrieving a list of filtering policies

Returns a list of all policies created by the user.

**Request type:** GET  
**URL:** https://safedns.com/dashboard/rest\_api/v1/users/{{user\_id}}/profiles/  
Where {{user\_id}} is the entry retrieved from the Method 1 - User authorization.

The reply contains a list of all policies with their respective IDs (**profile\_id**).

---

##### 3. Creating an Encrypted DNS record

Creates an Encrypted DNS device record.

Mandatory parameters:

- user\_id - from Method 1 - User authorization.
- profile\_id - from Method 2 - Retrieving a list of filtering policies.

**Request type:** POST  
**URL:** https://safedns.com/dashboard/rest\_api/v1/users/{{user\_id}}/doh\_device/  
**Request body:**

```JSON
{
  "name": "ANY_ENCRYPTED_DNS_RECORD_NAME",
  "profile_id": FILTERING_POLICY_ID
}
```

This method creates **a single** Encrypted DNS device at a time.

---

##### 4. Editing an Encrypted DNS record name

Changes the Encrypted DNS record name.

**Request type:** PATCH  
**URL:** https://safedns.com/dashboard/rest\_api/v1/users/{{user\_id}}/doh\_device/{{id\_encrypted\_dns}}/  
**Request body:**

```JSON
{
  "name": "_ENCRYPTED_DNS_RECORD_NAME",
  "profile_id": FILTERING_POLICY_ID
}
```

---

##### 5. Deleting an Encrypted DNS record

Deletes the Encrypted DNS record.

**Request type:** DELETE  
**URL:** https://safedns.com/dashboard/rest\_api/v1/users/{{user\_id}}/doh\_device/{{id\_encrypted\_dns}}/

---

##### 6. Creating several Encrypted DNS records

Creates several Encrypted DNS records at once.

Mandatory parameters:

- user\_id - from Method 1 - User authorization.
- profile\_id for each filtering policy you wish to create the record for - from Method 2 - Retrieving a list of filtering policies.

**Request type:** POST  
**URL:** https://safedns.com/dashboard/rest\_api/v1/users/{{user\_id}}/doh\_device/mass\_create/  
**Request body:**

```JSON
[
  {
    "name": "ANY_ENCRYPTED_DNS_RECORD_NAME_1",
    "profile_id": FILTERING_POLICY_ID
  },
  {
    "name": "ANY_ENCRYPTED_DNS_RECORD_NAME_2",
    "profile_id": FILTERING_POLICY_ID
  },
  {
    "name": "ANY_ENCRYPTED_DNS_RECORD_NAME_3",
    "profile_id": FILTERING_POLICY_ID
  }
]
```

This method creates **multiple** Encrypted DNS records in a single request.  
Each record can be assigned the same or a different filtering policy.

---

##### 7. Retrieving a list of Encrypted DNS devices

Returns a list of all Encrypted DNS records.

**Request type:** GET  
**URL:** https://safedns.com/dashboard/rest\_api/v1/users/{{user\_id}}/doh\_device/csv/