Skip to content

Commit da91f7f

Browse files
Added the First time setup API documentation
Ticket: ENT-12185 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
1 parent 62fa8d5 commit da91f7f

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
layout: default
3+
title: Fist time setup API
4+
published: true
5+
---
6+
7+
The First time setup API enables creation of the initial administrator user.
8+
This API is only accessible when the system hasn't been previously configured.
9+
Once setup is complete, this API becomes permanently inaccessible.
10+
11+
## Generate setup code
12+
13+
The setup code is generated during hub installation.
14+
If you need a new setup code, execute this command on your hub:
15+
16+
```console
17+
sudo cf-hub --new-setup-code
18+
```
19+
20+
**Note:** The setup code will expire after 1 hour.
21+
When you request a new setup code, it invalidates the previous one.
22+
23+
## Check setup status
24+
25+
First, check if the system has already been set up.
26+
This endpoint returns the current setup status of the system.
27+
28+
**URI:** https://hub.example.com/api/setup/status
29+
30+
**Method:** GET
31+
32+
**Example request (curl):**
33+
34+
```console
35+
curl -X GET \
36+
https://hub.example.com/api/setup/status
37+
```
38+
39+
**Successful response example:**
40+
41+
```
42+
HTTP 200 Ok
43+
{
44+
"is_setup_complete": false
45+
}
46+
```
47+
48+
**Output:**
49+
50+
* **is_setup_complete**
51+
Boolean value indicating whether the system has been set up (true) or not (false)
52+
53+
**Responses:**
54+
55+
| HTTP response code | Description |
56+
|---------------------------|-------------------------------|
57+
| 200 OK | Setup status check successful |
58+
| 500 Internal server error | Internal server error |
59+
60+
## Validate setup code
61+
62+
Before completing setup, you must validate a setup code.
63+
This endpoint returns a session ID required for the setup complete API request.
64+
65+
**URI:** https://hub.example.com/api/setup/code/validate
66+
67+
**Method:** POST
68+
69+
**Parameters:**
70+
71+
* **code** *(string)*
72+
The setup code provided during system initialization
73+
74+
**Example request (curl):**
75+
76+
```console
77+
curl -X POST \
78+
https://hub.example.com/api/setup/code/validate \
79+
--data-raw '{"code": "YOUR_SETUP_CODE"}'
80+
```
81+
82+
**Successful response example:**
83+
84+
```
85+
HTTP 200 Ok
86+
{
87+
"session_id": "abcdef123456789....",
88+
"valid": true
89+
}
90+
```
91+
92+
**Output:**
93+
94+
* **session_id**
95+
The session ID to be used in the setup complete API request
96+
* **valid**
97+
Boolean value indicating whether the provided code is valid
98+
99+
**Responses:**
100+
101+
| HTTP response code | Description |
102+
|---------------------------|-------------------------------|
103+
| 200 OK | Code validation successful |
104+
| 400 Bad request | Invalid or missing code |
105+
| 500 Internal server error | Internal server error |
106+
107+
## Complete setup
108+
109+
This endpoint finalizes the setup process by creating the first administrator user.
110+
It requires a valid session ID obtained from the code validation step.
111+
112+
**URI:** https://hub.example.com/api/setup/complete
113+
114+
**Method:** POST
115+
116+
**Headers:**
117+
118+
* **Cf-Setup-Session-Id** *(string)*
119+
Session ID obtained from the code validation step
120+
121+
**Parameters:**
122+
123+
* **username** *(string)*
124+
Alphanumeric username for the administrator account
125+
* **password** *(string)*
126+
Password for the administrator account
127+
* **email** *(string)*
128+
Email address for the administrator account
129+
130+
**Example request (curl):**
131+
132+
```console
133+
curl -X POST \
134+
https://hub.example.com/api/setup/complete \
135+
--header 'Cf-Setup-Session-Id: abcdef123456789' \
136+
--data-raw '{
137+
"username": "admin",
138+
"password": "SecurePassword123",
139+
"email": "admin@example.loc"
140+
}'
141+
```
142+
143+
**Successful response example:**
144+
145+
```
146+
HTTP 201 Created
147+
```
148+
149+
**Responses:**
150+
151+
| HTTP response code | Description |
152+
|---------------------------|---------------------------------------------------|
153+
| 201 Created | Setup successfully completed |
154+
| 406 Not Acceptable | Invalid session ID |
155+
| 400 Bad request | Missing or invalid parameters |
156+
| 500 Internal server error | Internal server error |

0 commit comments

Comments
 (0)