# JSON-RPC API guide

**Version 1.1.**  
The latest JSON-RPC API guide is available here: [https://docs.safedns.com/books/json-rpc-api/page/json-rpc-api-guide](https://docs.safedns.com/books/json-rpc-api/page/json-rpc-api-guide)

---

JSON-RPC API methods are designed for interaction with the service and making changes to the settings.

---

The API was designed using JSON-RPC protocol and is compatible with the following versions: 1.0 and 2.0. More info is available here: [ ](http://www.jsonrpc.org/specification)[http://www.jsonrpc.org/specification](http://www.jsonrpc.org/specification)

An example of a CURL request for JSON-RPC 1.0:

```shell
curl -X POST https://www.safedns.com/api/json/v1-L-d '{"id":0,"method":"methodName","params":{"param1":"param1"}}'
```

An example of a CURL request for JSON-RPC 2.0:

```shell
curl -X POST https://www.safedns.com/api/json/v2-L-d '{"id":0,"jsonrpc":"2.0","method":"methodName","params":{"param1":"para m1"}}'
```

Some API methods require basic authentication. In this case, authentication details must be sent in the request. Example:

```shell
curl -X POST https://www.safedns.com/api/json/v2 -L --user username:password -d '{"id":0,"jsonrpc":"2.0","method":"methodName","params":{"param1":"param1"}}'
```

---

##### Response format: JSON.

A response example of a successful API call:

```JSON
{
"jsonrpc": "2.0",
"id": 0,
"result": "result"
}
```

A method result is included in the “result” key.

In case of an incorrect request the response will be the following:

```JSON
{
"jsonrpc": "2.0",
"id": 0,
"error": {"code": "code", "name": "name", "message": "message", "data": "data"}
}
```

---

<div dir="auto" id="bkmrk-%23-value-description-"><div dir="auto"><span style="color: #222222; font-size: 1.666em; font-weight: 400;">Table of available methods:</span>  
</div></div><table border="1" id="bkmrk-%23-value-description--0" style="border-collapse: collapse; width: 100%; height: 983.298px;"><tbody><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">**\#**</td><td class="align-center" style="width: 21.8789%; height: 29.7969px;">**Value**</td><td class="align-center" style="width: 72.8059%; height: 29.7969px;">**Description**</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">1</td><td style="width: 21.8789%; height: 29.7969px;">**systemInfo**</td><td style="width: 72.8059%; height: 29.7969px;">Gets information about the system configuration</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">2</td><td style="width: 21.8789%; height: 29.7969px;">**myip**</td><td style="width: 72.8059%; height: 29.7969px;">Gets the current client’s IP</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">3</td><td style="width: 21.8789%; height: 29.7969px;">**testAuth**</td><td style="width: 72.8059%; height: 29.7969px;">User’s authentication</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">4</td><td style="width: 21.8789%; height: 29.7969px;">**register**</td><td style="width: 72.8059%; height: 29.7969px;">Registers a new user</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">5</td><td style="width: 21.8789%; height: 29.7969px;">**userInfo**</td><td style="width: 72.8059%; height: 29.7969px;">Gets user information</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">6</td><td style="width: 21.8789%; height: 29.7969px;">**profiles**</td><td style="width: 72.8059%; height: 29.7969px;">Gets a list of available filtering policies</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">7</td><td style="width: 21.8789%; height: 29.7969px;">**addProfile**</td><td style="width: 72.8059%; height: 29.7969px;">Creates a new filtering policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">8</td><td style="width: 21.8789%; height: 29.7969px;">**removeProfile**</td><td style="width: 72.8059%; height: 29.7969px;">Deletes a filtering policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">9</td><td style="width: 21.8789%; height: 29.7969px;">**renameProfile**</td><td style="width: 72.8059%; height: 29.7969px;">Renames a filtering policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">10</td><td style="width: 21.8789%; height: 29.7969px;">**categories**</td><td style="width: 72.8059%; height: 29.7969px;">Gets a list of available filtering categories</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">11</td><td style="width: 21.8789%; height: 29.7969px;">**userFilter**</td><td style="width: 72.8059%; height: 29.7969px;">Gets a list of filtering categories applied for a user</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">12</td><td style="width: 21.8789%; height: 29.7969px;">**setFilterCat**</td><td style="width: 72.8059%; height: 29.7969px;">Changes filtering settings</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">13</td><td style="width: 21.8789%; height: 29.7969px;">**domains**</td><td style="width: 72.8059%; height: 29.7969px;">Gets a list of Allow/Denylisted domains for a certain filtering policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">14</td><td style="width: 21.8789%; height: 29.7969px;">**addDomain**</td><td style="width: 72.8059%; height: 29.7969px;">Adds a domain to the Allow/Denylist for a certain filtering policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">15</td><td style="width: 21.8789%; height: 29.7969px;">**removeDomain**</td><td style="width: 72.8059%; height: 29.7969px;">Deletes a domain from a certain filtering policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">16</td><td style="width: 21.8789%; height: 29.7969px;">**clearDomains**</td><td style="width: 72.8059%; height: 29.7969px;">Clears the list of domains for a certain filtering policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">17</td><td style="width: 21.8789%; height: 29.7969px;">**updateNic**</td><td style="width: 72.8059%; height: 29.7969px;">Updates a dynamic IP</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">18</td><td style="width: 21.8789%; height: 29.7969px;">**setWhiteListOnly**</td><td style="width: 72.8059%; height: 29.7969px;">Enables/disables the "Allow list only" mode</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">19</td><td style="width: 21.8789%; height: 29.7969px;">**setSafeSearchEnabled**</td><td style="width: 72.8059%; height: 29.7969px;">Enables/disables "Safe Search mode" for Google and Bing</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">20</td><td style="width: 21.8789%; height: 29.7969px;">**setSafeYoutubeEnabled**</td><td style="width: 72.8059%; height: 29.7969px;">Enables/disables "Restricted YouTube mode"</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">21</td><td style="width: 21.8789%; height: 29.7969px;">**multiSchedule**</td><td style="width: 72.8059%; height: 29.7969px;">Gets information on the filtering schedule for a certain policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">22</td><td style="width: 21.8789%; height: 29.7969px;">**setSchedule**</td><td style="width: 72.8059%; height: 29.7969px;">Sets filtering schedule for a certain policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">23</td><td style="width: 21.8789%; height: 29.7969px;">**setScheduleEnabled**</td><td style="width: 72.8059%; height: 29.7969px;">Enables/disables filtering schedule for a certain policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">24</td><td style="width: 21.8789%; height: 29.7969px;">**profileScheduleActivity**</td><td style="width: 72.8059%; height: 29.7969px;">Gets the time left before a change of the filtering policy according to the filtering schedule</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">25</td><td style="width: 21.8789%; height: 29.7969px;">**getProfile**</td><td style="width: 72.8059%; height: 29.7969px;">Creates AgentInfo, gets AgentInfo status or updates AgentInfo policy depending on the parameters

</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">26</td><td style="width: 21.8789%; height: 29.7969px;">**setProfile**</td><td style="width: 72.8059%; height: 29.7969px;">Sets a filtering policy for AgentInfo</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">27</td><td style="width: 21.8789%; height: 29.7969px;">**feedback**</td><td style="width: 72.8059%; height: 29.7969px;">Sends user’s feedback</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">28</td><td style="width: 21.8789%; height: 29.7969px;">**getCategoriesDailyStats**</td><td style="width: 72.8059%; height: 29.7969px;">Gets daily categories stats of a policy</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">29</td><td style="width: 21.8789%; height: 29.7969px;">**getAdvertising**</td><td style="width: 72.8059%; height: 29.7969px;">Gets the information on promo</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">30</td><td style="width: 21.8789%; height: 29.7969px;">**getPlans**</td><td style="width: 72.8059%; height: 29.7969px;">Gets the list of available billing plans</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">31</td><td style="width: 21.8789%; height: 29.7969px;">**getPlan**</td><td style="width: 72.8059%; height: 29.7969px;">Gets the user’s billing plan</td></tr><tr style="height: 29.7969px;"><td class="align-center" style="width: 5.3152%; height: 29.7969px;">32</td><td style="width: 21.8789%; height: 29.7969px;">**getAPCVersion**</td><td style="width: 72.8059%; height: 29.7969px;">Gets mobile app’s version: minimal supported and the current one</td></tr></tbody></table>

---

#### Available methods:

##### 1. systemInfo

Gets information on the system settings.

Response:

```JSON
{
"public_dns": <public_dns>,
"nxdomain": <nxdomain>,
"blockpage": <blockpage>,
"blockpage_token": <blockpage_token>,
"blockapi": <blockapi>
}
```

---

##### 2. myip

Gets current client’s IP.

Response:

```JSON
<ip address>
```

---

##### 3. testAuth

User’s authentication.

Mandatory parameters:

- username <span class="s7">- </span><span class="p">client’s username.</span>
- password <span class="p">- client’s password.</span>

Response:

```JSON
<true|false>
```

---

##### 4. register‌

Registers a new user.

Mandatory parameters:

- username <span class="p">- client’s username.</span>
- password - <span class="p">client's password.</span>

Response:

In case of a successful registration:

```JSON
[true]
```

If an error occurred:

```JSON
[false, <error>]
```

---

##### 5. userInfo

Gets user information. Authorization is required.

Response:

```JSON
{
"plan": {
"name": <plan.name>,
"code": <plan.code>,
"features": <features>
},
"tz": <timezone_offset / 3600>,
"tz_minutes": <timezone_offset / 60>
}
```

---

##### 6. profiles

Gets a list of available filtering policies. Authorization is required.

Response:

```JSON
[
{
"name": <name>,
"default": <true|false>,
"white_list_only":<true|false>,
"token": <token>,
"safe_search_enabled": <true|false>,
"is_schedule_enabled": <true|false>,
"id": <id>
}
]
```

---

##### 7. addProfile

Creates a new filtering policy. Authorization is required.

Mandatory parameter:

- name <span class="p">- policy name</span>

Response:

```JSON
{
"name": <name>,
"default": <true|false>,
"white_list_only": <true|false>,
"token": <token>,
"safe_search_enabled": <true|false>,
"is_schedule_enabled": <true|false>,
"id": <id>
}
```

---

##### 8. removeProfile

Deletes a filtering policy. Authorization is required.

Mandatory parameter:

- profile\_id <span class="p">- id of the policy that should be deleted.</span>

Response:

```JSON
null
```

---

##### 9. renameProfile

Renames a filtering policy. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy id.</span>
- name <span class="p">- policy name.</span>

Response:

```JSON
<name>
```

---

##### 10. categories

Gets a list of available filtering categories. Authorization is required.

Response:

```JSON
[
{
"title": <group1>,
"items": [{"title": <item1>, "id": <id>}]
}
]
```

---

##### 11. userFilter

Gets a list of filtering categories applied for a user. Authorization is required.

Mandatory parameter:

- profile\_id <span class="p">- policy id.</span>

Response:

```JSON
[<cat_id1>, <cat_id2>, <cat_id3>]
```

---

##### 12. setFilterCat

Changes filtering settings. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy id.</span>
- cat <span class="p">- category id.</span>
- state <span class="p">- boolean value (add/remove the category from the filtering settings).</span>

Response:

```JSON
null
```

---

##### 13. domains

Gets a list of Allow/Denylisted domains for a certain filtering policy. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy id.</span>
- choice <span class="p">- domain type (available options: “black”, “white”, “alias”).</span>

Response:

If the domain type is “black” or “white”

```JSON
[{"domain":<domain>,"id":<id>}]
```

If the domain type is “alias”:

```JSON
[{"domain":<domain>,"id":<id>,"ip":<ip>}]
```

---

##### 14. addDomain

Adds a domain to the Allow/Denylist for a certain filtering policy. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- choice <span class="p">- domain type (available options: “black”, “white”, “alias”).</span>
- domain <span class="s7">– </span><span class="p">domain.</span>

<span class="p">Optional parameter:</span>

- ip <span class="p">- IP address, the parameter should be used if the “alias” domain is being </span>added.
- comment <span class="p">- adds a comment for a domain.</span>

Response:

```JSON
<id of added domain>
```

---

##### 15. removeDomain

Deletes a domain from the Allow/Denylist for a certain filtering policy. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- choice <span class="p">- domain type (available options: “black”, “white”, “alias”).</span>
- domain <span class="s7">– </span><span class="p">domain.</span>

Response:

```JSON
null
```

---

##### 16. clearDomains

Clears the list of Allow/Denylisted domains for a certain filtering policy. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- choice <span class="p">- domain type (available options: “black”, “white”, “alias”).</span>

Response:

```JSON
null
```

---

##### 17. updateNic

Updates a dynamic IP. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- hostname <span class="p">- hostname.</span>

Response:

```JSON
<IP address>
```

---

##### 18. setWhiteListOnly

Enables/disables the "Allow list only" mode. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- flag <span class="s7">- </span><span class="p">enable/disable option (boolean value).</span>

Response:

```JSON
null
```

---

##### 19. setSafeSearchEnabled

Enables/disables "Safe Search mode" for Google and Bing. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- flag <span class="p">- boolean value (enable/disable option).</span>

Response:

```JSON
null
```

---

##### 20. setSafeYoutubeEnabled

Enables/disables "Safe Search mode" for Google and Bing. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- flag <span class="p">- boolean value (enable/disable option).</span>

Response:

```JSON
null
```

---

##### 21. setBlockUnknownEnabled

Enables/disables “Restricted YouTube mode”. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- flag <span class="p">- boolean value (enable/disable option).</span>

Response:

```JSON
null
```

---

##### 22. multiSchedule

Gets information on the filtering schedule for a certain policy. Authorization is required.

Mandatory parameter:

- profile\_id <span class="p">- policy ID.</span>

Response:

```JSON
[[<offset1>, <true|false>], [<offset2>, <true|false>]]
```

---

##### 23. setSchedule

Sets filtering schedule for a certain policy. Authorization is required.

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- segments <span class="p">- a list of segments for scheduling: \[\[&lt;offset1&gt;, &lt;true|false&gt;\], \[&lt;offset2&gt;, &lt;true|false&gt;\]\].</span>

Response:

```JSON
[true]
```

---

##### 24. setScheduleEnabled

Enables/disables filtering schedule for a certain policy. Authorization is required

Mandatory parameters:

- profile\_id <span class="p">- policy ID.</span>
- flag <span class="p">- boolean value (enable/disable option).</span>

Response:

```JSON
<true|false>
```

---

##### 25. profileScheduleActivity

Gets the time left before a change of the filtering policy according to the filtering schedule. Authorization is required

Mandatory parameter:

- profile\_id <span class="p">- policy ID</span>

Response:

```JSON
[<true|false>, <mins_until_change>]
```

Note:

If the scheduling is turned off or there are no other states: mins\_until\_change = -1.

---

##### 26. getProfile

This method includes 3 functions, depending on the parameters. Authorization is required.:

1. creates AgentInfo;
2. gets AgentInfo status;
3. updates AgentInfo policy

Mandatory parameters for creating Agent info and getting a policy:

- uid <span class="p">- ""</span>
- hostname - <span class="p">hostname.</span>
- version <span class="p">- version.</span>
- os\_info <span class="p">- information on the OS.</span>
- address <span class="p">- IP address.</span>

Mandatory parameters for getting the current policy of AgentInfo:

- uid <span class="p">- uid AgentInfo.</span>
- hostname <span class="p">- "".</span>
- version <span class="p">- "".</span>
- os\_info <span class="p">- "".</span>
- address <span class="p">- "".</span>

Mandatory parameters for updating AgentInfo:

- uid <span class="p">- uid AgentInfo.</span>
- hostname <span class="p">- new hostname.</span>
- version <span class="p">- new version.</span>
- os\_info <span class="p">- new information on the OS.</span>
- address <span class="p">- new IP address.</span>

Response:

```JSON
[<uid>, <token>, <profile_id>]
```

---

##### 27. setProfile

Sets a filtering policy for AgentInfo. Authorization is required

Mandatory parameters:

- uid <span class="p">- uid AgentInfo.</span>
- profile\_id <span class="p">- policy ID.</span>

Response:

```JSON
null
```

---

##### 28. feedback

Sends user’s feedback. Authorization is required.

Mandatory parameters:

- title <span class="p">- the subject line.</span>
- message – <span class="p">user’s message.</span>

Response:

```JSON
null
```

---

##### 29. getCategoriesDailyStats

Gets daily categories stats of a policy. Authorization is required.

Mandatory parameter:

- profile\_id <span class="p">- policy ID.</span>

Optional parameters:

- lang <span class="p">- response language.</span>
- categories\_list <span class="p">- defines a list of categories. if it’s not set - the result will show all the categories.</span>

Response:

```JSON
{<category_name>: <value>}
```

---

##### 30. getAdvertising

Gets the information on promo. Authorization is required

Response:

```JSON
{<strAdvUrl>, <strImageUrl>}
```

---

##### 31. getPlans

Gets the list of available billing plans.

Optional parameter:

- mobile <span class="p">- gets the Plans list, and determines whether to respond with mobile plans only. Boolean value.</span>

Response:

```JSON
{
'name': <plan name>,
'code': <plan code>,
'isMobile': <is mobile plan>,
'period': <period>,
'trialPeriod': <is trial>,
'price': <price>,
'description': <path>,
}
```

---

##### 32. getPlan

Gets user’s billing plan. Authorization is required.

Response:

```JSON
{
'name': <plan name>,
'expired': <expired_days>,
'isMobile': <true|false>,
}
```

---

##### 33. getAPCVersion

Gets mobile app’s version: minimal supported and the current one.

Optional parameter:

- tag <span class="p">- tag for getting the versions (the value “default” is set by default).</span>

Response:

```JSON
{
"minimalSupported": <minimum supported version (integer, non-negative number)>,
"current":<current version of the mobile agent (integer, non-negative number)>
}
```