Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions docs/api/v1/users/create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Create User

Create a new user.

**URL** : `/api/v1/users/create`

**Method** : `POST`

**Auth required** : YES

**Request Body constraints**

```json
{
"name": "[string: username, alphanumeric, spaces, underscores and hyphens, max 64 chars]",
"display_name": "[string: max 255 chars]",
"email": "[string: valid email, max 255 chars]",
"password": "[string: max 255 chars]",
"is_admin": "[string or boolean: 'true', 'false', true, false, default false]"
}
```

**Body example**

```json
{
"name": "user",
"display_name": "New User",
"email": "user@user.user",
"password": "password",
"is_admin": "false"
}
```

## Success Response

**Code** : `200 OK`

**Content examples**

```json
{
"status": "success",
"data": {
"user_id": 5,
"user_name": "user"
},
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

## Error Response

**Condition** : If 'X-Davis-API-Token' is not present or mismatched in headers.

**Code** : `401 UNAUTHORIZED`

**Content** :

```json
{
"message": "No API token provided",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

or

```json
{
"message": "Invalid API token",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If request body contains invalid JSON.

**Code** : `400 BAD REQUEST`

**Content** :

```json
{
"status": "error",
"message": "Invalid JSON",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If 'name' parameter is invalid (not matching the regex or exceeds length).

**Code** : `400 BAD REQUEST`

**Content** :

```json
{
"status": "error",
"message": "Invalid Userame",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If 'display_name' parameter is invalid (null or empty string).

**Code** : `400 BAD REQUEST`

**Content** :

```json
{
"status": "error",
"message": "Invalid Display Name",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If 'email' parameter is invalid (null, empty string or invalid email).

**Code** : `400 BAD REQUEST`

**Content** :

```json
{
"status": "error",
"message": "Invalid Email",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If 'password' parameter is invalid (null or empty string).

**Code** : `400 BAD REQUEST`

**Content** :

```json
{
"status": "error",
"message": "Invalid Password",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If 'is_admin' parameter is invalid (not in [true, false, 'true', 'false']).

**Code** : `400 BAD REQUEST`

**Content** :

```json
{
"status": "error",
"message": "Invalid Is Admin",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If user with specified username already exists.

**Code** : `400 BAD REQUEST`

**Content** :

```json
{
"status": "error",
"message": "Usrname Already Exists",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```
86 changes: 86 additions & 0 deletions docs/api/v1/users/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Delete User

Deletes a specific user.

**URL** : `/api/v1/users/:user_id`

**Method** : `DELETE`

**Auth required** : YES

**Params constraints**

```
:user_id -> "[user id as an int]",
```

**URL example**

```
/api/v1/users/1
```

## Success Response

**Code** : `200 OK`

**Content examples**

```json
{
"status": "success",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

## Error Response

**Condition** : If 'X-Davis-API-Token' is not present or mismatched in headers.

**Code** : `401 UNAUTHORIZED`

**Content** :

```json
{
"message": "No API token provided",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

or

```json
{
"message": "Invalid API token",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If user is not found.

**Code** : `404 NOT FOUND`

**Content** :

```json
{
"status": "error",
"message": "User Not Found",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```

**Condition** : If any error arises while deleting, like if a principal was deleted without removing the corresponding user.

**Code** : `500 INTERNAL SERVER ERROR`

**Content** :

```json
{
"status": "error",
"message": "Failed to Delete User",
"timestamp": "2026-09-23T15:01:33+01:00"
}
```
Loading