0% found this document useful (0 votes)
25 views4 pages

API Documentation

This API documentation outlines three main endpoints: List Users, Delete User, and Create User, each requiring an email and API key for authentication. It provides detailed request parameters, example requests, and success/error responses for each endpoint. Additionally, it includes error handling guidelines and notes on password security and duplicate checks for user creation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views4 pages

API Documentation

This API documentation outlines three main endpoints: List Users, Delete User, and Create User, each requiring an email and API key for authentication. It provides detailed request parameters, example requests, and success/error responses for each endpoint. Additionally, it includes error handling guidelines and notes on password security and duplicate checks for user creation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

API Documentation

This documentation describes how to interact with the following API endpoints:
1. List Users (`api_list_users.php`)
2. Delete User (`api_delete_user.php`)
3. Create User (`api_create_user.php`)

### Authentication
To access these APIs, you need to provide an `email` and an `api_key` as query parameters.
These are used to verify the identity of the user making the request.

1. List Users
**Endpoint:** `GET /api/api_list_users.php`

This endpoint retrieves a list of users under the given parent user.

### Request Parameters:

- `email` (required): The email of the parent user.

- `api_key` (required): The API key associated with the parent user.

### Example Request:

```
GET /api/[email protected]&api_key=your_api_key
```

### Success Response:

```json
{
"status": "success",
"users": [
{
"id": 1,
"username": "user1",
"primary_domain": "example.com",
"name": "Cluster 1",
"package_name": "Basic Package"
},
{
"id": 2,
"username": "user2",
"primary_domain": "example.org",
"name": "Cluster 2",
"package_name": "Premium Package"
}
]
}
```

### Error Response:

```json
{
"error": "Invalid email or API key."
}
```

2. Delete User
**Endpoint:** `GET /api/api_delete_user.php`

This endpoint deletes a user under the given parent user.

### Request Parameters:

- `email` (required): The email of the parent user.

- `api_key` (required): The API key associated with the parent user.

- `user_id` (required): The ID of the user to be deleted.

### Example Request:

```
GET /api/api_delete_user.php?
[email protected]&api_key=your_api_key&user_id=2
```

### Success Response:


```json
{
"status": "success",
"message": "1 user(s) deleted successfully."
}
```

### Error Response:

```json
{
"error": "No users found for deletion."
}
```

3. Create User
**Endpoint:** `GET /api/api_create_user.php`

This endpoint creates a new user under the given parent user.

### Request Parameters:

- `email` (required): The email of the parent user.

- `api_key` (required): The API key associated with the parent user.

- `username` (required): The username for the new user.

- `user_email` (required): The email address of the new user.

- `password` (required): The password for the new user.

- `cluster_id` (required): The ID of the cluster under which the user will be created.

- `package_id` (required): The ID of the package assigned to the user.

- `domain_name` (required): The domain name associated with the new user.

### Example Request:

```
GET /api/api_create_user.php?
[email protected]&api_key=your_api_key&username=newuser&user_email=newus
[email protected]&password=securepassword&cluster_id=1&package_id=2&domain_name
=example.com
```

### Success Response:

```json
{
"status": "success",
"message": "User created successfully.",
"email": "Email send successfully."
}
```

### Error Response:

```json
{
"error": "Missing parameters: username, user_email, password, cluster_id, package_id,
domain_name."
}
```

Error Handling
In case of an error, the API will return a JSON response with an `error` field describing the
issue. Make sure to handle errors accordingly in your application.

Example:
```json
{
"error": "Invalid email or API key."
}
```

Notes
1. Ensure that the `email` and `api_key` provided in the request are valid and associated
with an authorized user.
2. All passwords for created users are hashed using `bcrypt`.
3. When creating a user, the system checks if the `username` or `email` already exists for the
given parent user to avoid duplicates.

You might also like