RISPOSTA Data API Documentation

Base URL

Base URL: https://api.risposta.app/api

1. Authentication Endpoints

1.1 Login (User Authentication)

Endpoint: /login

Method: POST

Description: Authenticates the user with their email and password, returning an access token and refresh token.

Request Example:

{
    "email": "user@example.com",
    "password": "password"
}

Response Example (200 OK):

{
    "access_token": "your-access-token",
    "refresh_token": "your-refresh-token",
    "token_type": "Bearer",
    "expires_at": "2024-10-16T17:00:00.000000Z"
}

Failure Response (401 Unauthorized): Incorrect email or password.

1.2 Refresh Token

Endpoint: /refresh-token

Method: POST

Description: Refreshes the access token using a valid refresh token.

Request Example:

{
    "refresh_token": "your-refresh-token"
}

Response Example (200 OK):

{
    "access_token": "new-access-token",
    "refresh_token": "new-refresh-token",
    "token_type": "Bearer",
    "expires_at": "2024-10-16T17:00:00.000000Z"
}

Failure Response (401 Unauthorized): Invalid or expired refresh token.

1.3 Logout

Endpoint: /logout

Method: POST

Description: Revokes the access token and logs the user out.

Authorization: Requires Bearer token in the header.

Request Header:
Authorization: Bearer your-access-token

Response Example (200 OK):

{
    "message": "Logged out successfully"
}

2. Customer Data Endpoint

2.1 Retrieve Customer Data

Endpoint: /customers

Method: POST

Description: Retrieves customer data within a specified date range.

Authorization: Requires Bearer token in the header.

Request Header:
Authorization: Bearer your-access-token

Request Example:

{
    "start_date": "2024-01-01",
    "end_date": "2024-10-01"
}

Response Example (200 OK):

{
    "total_customer": 5,
    "customers": [
        {
            "email_id": "customer@example.com",
            "business_name": "Example Business",
            "branch_name": "Main Branch",
            "timestamp": "2024-09-15T12:00:00Z",
            "name": "John Doe",
            "phone_no": "123-456-7890",
            "birthday": "1990-01-01",
            "postcode": "12345"
        }
    ]
}

Failure Response (422 Validation Error): Missing or invalid start_date or end_date.

Authentication

The API uses Bearer Token Authentication. Include the Authorization header with your token in the following format:

Authorization: Bearer your-access-token

Postman Collection

For easy testing, you can use the provided Postman collection: Download Postman Collection.