> For the complete documentation index, see [llms.txt](https://bharath-ramachandran.gitbook.io/br-writing-samples/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bharath-ramachandran.gitbook.io/br-writing-samples/technical-api-documentation-samples/user-management-api.md).

# User Management API

## Overview

The User Management API allows developers to create, read, update, and delete user accounts within an application.

## Base URL

```
https://api.usermanagement.com/v1
```

## Authentication

This API uses OAuth 2.0 for authentication. Include your bearer token in the Authorization header for each request.

## Endpoints

### POST /users

**Description**: Creates a new user.

**Request Headers**:

```
Content-Type: application/json
Authorization: Bearer <your_api_key>
```

**Request Body**:

```json
{
  "name": "John Doe",
  "email": "john.doe@example.com",
  "password": "securepassword123"
}
```

**Response**:

* **Success (201 Created)**:

  ```json
  {
    "id": "12345",
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
  ```
* **Error (400 Bad Request)**:

  ```json
  {
    "error": "Email already exists"
  }
  ```

### GET /users/{id}

**Description**: Retrieves the information of a specific user by ID.

**Request Headers**:

```
Authorization: Bearer <your_api_key>
```

**Request Parameters**:

* `id` (path parameter): The unique ID of the user.

**Response**:

* **Success (200 OK)**:

  ```json
  {
    "id": "12345",
    "name": "John Doe",
    "email": "john.doe@example.com",
    "created_at": "2023-01-01T12:00:00Z"
  }
  ```
* **Error (404 Not Found)**:

  ```json
  {
    "error": "User not found"
  }
  ```

## Example Code Snippets

### Creating a New User (Python)

```python
import requests

url = "https://api.usermanagement.com/v1/users"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <your_api_key>"
}
data = {
    "name": "John Doe",
    "email": "john.doe@example.com",
    "password": "securepassword123"
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
```

### Retrieving a User (JavaScript)

```javascript
const fetch = require('node-fetch');

const url = 'https://api.usermanagement.com/v1/users/12345';
const options = {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <your_api_key>'
  }
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
```
