# Kinerja REST API Documentation

## Endpoints

### Withdraw Funds
Endpoint: POST /withdraw

#### Request

Headers:
- Authorization: Bearer your_token_here (required)

Body:
json
    {
    "data": [
        {
        "username": "user123",
        "withdraw": 500
        }
    ]
    }

#### Example Request
bash
curl -X POST https://kinerja.io/withdraw \
  -H "Authorization: Bearer your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "data": [
      {
        "username": "user123",
        "withdraw": 500
      }
    ]
  }'

#### Responses

Success (200 OK)
json
    {
    "message": "Data berhasil disimpan",
    "results": [
        {
        "username": "user123",
        "balance": "1500 - 500 = 1000"
        }
    ]
    }

Error Cases:
- 400 Bad Request: Missing or invalid data
  json
  { "message": "Data diperlukan dan harus berupa array" }
  
- 404 Not Found: User not found
  json
  { "message": "User user123 tidak ditemukan" }
  
- 500 Server Error: Processing error
  json
  { "message": "Error processing data", "error": "Database connection failed" }
  

----------------------------------------------------------------------------------------------------

### Update Profit
Endpoint: POST /updateProfit

#### Request

Headers:
- Authorization: Bearer your_token_here (required)

Body:
json
    {
    "data": [
        {
        "username": "user123",
        "updateProfit": 200
        },
        {
        "username": "user345",
        "updateProfit": 200
        },
        {
        "username": "user234",
        "updateProfit": 200
        }
    ],
    "multiple": 0 or 1
    }


| Field | Type | Description |
|-------|------|-------------|
| data | Array | List of profit update requests |
| username | String | User's account name |
| updateProfit | Number | Amount to add to user's ROI |
| multiple | Number | Controls batch processing: 0 = single update only, 1 = multiple updates allowed |

#### Example Request
bash
curl -X POST https://api.example.com/updateProfit \
  -H "Authorization: Bearer your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "data": [
      {
        "username": "user123",
        "updateProfit": 200
      }
    ],
    "multiple": 0
  }'


#### Responses

Success (200 OK)
json
    {
    "message": "Data berhasil disimpan",
    "results": [
        {
        "username": "user123",
        "balance": "1000 + 200 = 1200"
        }
    ]
    }


Error Cases:
- 400 Bad Request: Missing or invalid data
  json
  { "message": "Data diperlukan dan harus berupa array" }
  
- 400 Bad Request: Multiple items not allowed
  json
  { "message": "Multiple data tidak diperbolehkan" }
  
- 404 Not Found: User not found
  json
  { "message": "User user123 tidak ditemukan" }
  
- 500 Server Error: Processing error
  json
  { "message": "Error processing data", "error": "Database connection failed" }