# Customers API Guide

This guide documents the API endpoints for managing your Tips Feed package.

**Base URL:** `https://engage-api.lsports.eu/api/tips`

All endpoints require authentication via the `username` and `password` fields in the request body. Credentials are validated against your stored package credentials.

***

## Endpoints

### 1. Activate Package

Activates a Tips Feed package. Validates credentials and updates the package status to active in the database.

```
POST https://engage-api.lsports.eu/api/tips/package/activate
```

**Request body**

```json
{
  "packageId": 123,
  "username": "user@example.com",
  "password": "password123"
}
```

**Success (200)**

```json
{
  "success": true,
  "message": "Package activation completed successfully",
  "packageId": 123,
  "username": "user@example.com"
}
```

If the package is already active, the API returns success with the message `"Package is already active"`.

**Validation Error (400)**

```json
{
  "error": "Invalid package credentials"
}
```

Possible validation errors:

* `"PackageId must be a positive integer"`
* `"Username is required"`
* `"Password is required"`
* `"Invalid package credentials"`

**Server Error (500)**

```json
{
  "success": false,
  "message": "Failed to activate package",
  "packageId": 123
}
```

**cURL**

```bash
curl -X POST https://engage-api.lsports.eu/api/tips/package/activate \
  -H "Content-Type: application/json" \
  -d '{
    "packageId": 123,
    "username": "user@example.com",
    "password": "password123"
  }'
```

***

### 2. Deactivate Package

Deactivates a Tips Feed package. Validates credentials and updates the package status to inactive in the database.

```
POST https://engage-api.lsports.eu/api/tips/package/deactivate
```

**Request body**

```json
{
  "packageId": 123,
  "username": "user@example.com",
  "password": "password123"
}
```

**Success (200)**

```json
{
  "success": true,
  "message": "Package deactivation completed successfully",
  "packageId": 123,
  "username": "user@example.com"
}
```

If the package is already inactive, the API returns success with the message `"Package is already inactive"`.

**Validation Error (400)**

```json
{
  "error": "Invalid package credentials"
}
```

Possible validation errors:

* `"PackageId must be a positive integer"`
* `"Username is required"`
* `"Password is required"`
* `"Invalid package credentials"`

**Server Error (500)**

```json
{
  "success": false,
  "message": "Failed to deactivate package",
  "packageId": 123
}
```

**cURL**

```bash
curl -X POST https://engage-api.lsports.eu/api/tips/package/deactivate \
  -H "Content-Type: application/json" \
  -d '{
    "packageId": 123,
    "username": "user@example.com",
    "password": "password123"
  }'
```

***

### 3. Get Package Status

Retrieves the current status of a Tips Feed package without modifying it. Returns whether the package is active or inactive.

```
POST https://engage-api.lsports.eu/api/tips/package/status
```

**Request body**

```json
{
  "packageId": 123,
  "username": "user@example.com",
  "password": "password123"
}
```

**Success (200)**

```json
{
  "success": true,
  "status": "active",
  "packageId": 123,
  "username": "user@example.com"
}
```

The `status` field can be either `"active"` or `"inactive"`.

**Validation Error (400)**

```json
{
  "error": "Invalid package credentials"
}
```

Possible validation errors:

* `"PackageId must be a positive integer"`
* `"Username is required"`
* `"Password is required"`
* `"Invalid package credentials"`

**Server Error (500)**

```json
{
  "success": false,
  "message": "Unable to validate package credentials",
  "packageId": 123
}
```

**cURL**

```bash
curl -X POST https://engage-api.lsports.eu/api/tips/package/status \
  -H "Content-Type: application/json" \
  -d '{
    "packageId": 123,
    "username": "user@example.com",
    "password": "password123"
  }'
```

***

## Authentication

All endpoints require authentication via the `username` and `password` fields in the request body. The credentials are validated against the stored package credentials in the database.

***

## Error Handling

**Validation Errors (400)** — Returned when:

* Required fields are missing or invalid
* Package credentials do not match
* Package does not exist

**Server Errors (500)** — Returned when:

* Database connection fails
* External API calls fail
* Unexpected server-side errors occur
