logo

General Information

Version: 1.0.0

Last Updated: 15th Nov, 2024

This documentation provides details on how to use the Risposta API for accessing various services.

Base URL

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

Authentication

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

Authorization: Bearer your-access-token

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.

3. Customer Data With Reports Endpoint

3.1 Retrieve Customer Data With Reports

Endpoint: /customers/reports

Method: POST

Description: Retrieves customer data reports 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):

{
    "success": true,
    "message": "Customers retrieved successfully",
    "data": {
    "total_customer": 27,
    "customers": [
        {
            "email_id": "test@test.com",
            "buisness_name": "Test Business",
            "branch_name": "Test Branch",
            "timestamp": "2024-10-01 06:25:48",
            "name": "Test",
            "phone_no": "55(22) 12345678",
            "birthday": "1988-06-22",
            "postcode": "1234567",
            "survey": {
                "Sua idade": "46 - 55 anos",
                "Gênero": "Masculino",
                "Com que frequência você visitou nosso restaurante nos últimos 12 meses?": "Primeira visita"
            },
            "categories": {
                "Comida": "10.00",
                "Serviço": "10.00",
                "Ambiente": "10.00",
                "Preço (Nota 10 = Bom preço)": "10.00"
            },
            "subcategories": {
                "Limpeza": "10.00",
                "Sugestões da equipe": "10.00",
                "ATTENTION, THIS IS A TEST!  1": "2.00"
            }
        }
        ]
    }
}

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

Postman Collection

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