Skip to content

Commit fe4b33b

Browse files
author
Jared Hendrickson
committed
Updated documentation to include user requirements and content type options, fixed HTTP response code for unknown content type
1 parent 29ac837 commit fe4b33b

4 files changed

Lines changed: 280 additions & 90 deletions

File tree

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ After installation, you will be able to access the API user interface pages with
5353
By default, pfSense API uses the same credentials as the webConfigurator. This behavior allows you to configure pfSense
5454
from the API out of the box, and user passwords may be changed from the API to immediately add additional security if
5555
needed. After installation, you can navigate to System > API in the pfSense webConfigurator to configure API
56-
authentication.
56+
authentication. Please note that external authentication servers like LDAP or RADIUS are not supported with any
57+
API authentication method at this time.
5758

5859
To authenticate your API call, follow the instructions for your configured authentication mode:
5960

@@ -80,6 +81,81 @@ Uses standalone tokens generated via the UI. These are better suited to distribu
8081
pfSense API uses the same privileges as the pfSense webConfigurator. The required privileges for each endpoint are stated within the API documentation.
8182

8283

84+
# Content Types
85+
pfSense API can handle a few different content types. Please note, if a `Content-Type` header is not specified in your request pfSense API will attempt to determine the
86+
content type which may have undesired results. It is recommended you specify your preferred `Content-Type` on each request. While several content types may be enabled,
87+
`application/json` is the recommended content type. Supported content types are:
88+
89+
<details>
90+
<summary>application/json</summary>
91+
92+
Parses the request body as a JSON formatted string. This is the recommended content type.
93+
94+
Example:
95+
96+
```
97+
curl -s -H "Content-Type: application/json" -d '{"client-id": "admin", "client-token": "pfsense"}' -X GET https://pfsense.example.com/api/v1/firewall/rule
98+
{
99+
"status": "ok",
100+
"code": 200,
101+
"return": 0,
102+
"message": "Success",
103+
"data": [
104+
{
105+
"ip": "192.168.1.1",
106+
"mac": "00:0c:29:f6:be:d9",
107+
"interface": "em1",
108+
"status": "permanent",
109+
"linktype": "ethernet"
110+
},
111+
{
112+
"ip": "172.16.209.139",
113+
"mac": "00:0c:29:f6:be:cf",
114+
"interface": "em0",
115+
"status": "permanent",
116+
"linktype": "ethernet"
117+
}
118+
]
119+
}
120+
```
121+
122+
</details>
123+
124+
<details>
125+
<summary>application/x-www-form-urlencoded</summary>
126+
127+
Parses the request body as URL encoded parameters.
128+
129+
Example:
130+
131+
```
132+
curl -s -H "Content-Type: application/x-www-form-urlencoded" -X GET "https://pfsense.example.com/api/v1/firewall/rule?client-id=admin&client-token=pfsense"
133+
{
134+
"status": "ok",
135+
"code": 200,
136+
"return": 0,
137+
"message": "Success",
138+
"data": [
139+
{
140+
"ip": "192.168.1.1",
141+
"mac": "00:0c:29:f6:be:d9",
142+
"interface": "em1",
143+
"status": "permanent",
144+
"linktype": "ethernet"
145+
},
146+
{
147+
"ip": "172.16.209.139",
148+
"mac": "00:0c:29:f6:be:cf",
149+
"interface": "em0",
150+
"status": "permanent",
151+
"linktype": "ethernet"
152+
}
153+
]
154+
}
155+
```
156+
157+
</details>
158+
83159
# Response Codes
84160
`200 (OK)` : API call succeeded<br>
85161
`400 (Bad Request)` : An error was found within your requested parameters<br>

0 commit comments

Comments
 (0)