Smartico API Documentation

This documentation describes the ThePowerPlugin API, a comprehensive platform for managing casinos and gaming establishments. The API allows you to efficiently manage establishments, players, products, and orders.

Authentication

All API requests require authentication using a Bearer token in the Authorization header.

Authorization: Bearer your_token_here

Base URL

https://stageapi.thepowerplugin.com/

HTTP Status Codes

CodeDescription
200Success - Request processed successfully
201Created - Resource created successfully
400Bad Request - Invalid parameters
401Unauthorized - Invalid authentication token
403Forbidden - No permissions to access resource
404Not Found - Requested resource does not exist
409Conflict - Resource already exists or conflict occurred
500Internal Server Error

Establishments

Establishments represent the casinos or gaming venues that use the Smartico platform.

GET /establishments/{establishmentId}

Gets detailed information about a specific establishment.

Endpoint

GET/establishments/{establishmentId}

Description

This endpoint allows you to retrieve all information associated with an establishment, including basic data, configuration, and current status.

Parameters

AttributeDescriptionTypeLocationRequired
establishmentIdUnique establishment identifierstringpathYes

Request Example

curl -X GET "https://stageapi.thepowerplugin.com//establishments/est_123456" \
  -H "Authorization: Bearer your_token_here"

Responses

200 - Success

Establishment found successfully.

{
  "id": "est_123456",
  "name": "Casino Royal Madrid",
  "address": {
    "street": "Calle Gran Vía 123",
    "city": "Madrid",
    "postalCode": "28013",
    "country": "Spain"
  },
  "contact": {
    "email": "info@casinoroyal.com",
    "phone": "+34 91 123 4567"
  },
  "status": "active",
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-20T14:22:00Z",
  "settings": {
    "currency": "EUR",
    "timezone": "Europe/Madrid",
    "language": "en"
  }
}

400 - Bad Request

Error in request parameters.

{
  "error": "INVALID_PARAMETERS",
  "message": "establishmentId must be a valid string",
  "code": 400
}

404 - Not Found

The establishment does not exist or you don't have permissions to access it.

{
  "error": "ESTABLISHMENT_NOT_FOUND",
  "message": "Establishment with ID est_123456 not found",
  "code": 404
}

500 - Server Error

Internal server error.

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}

Orders

Orders represent product purchase transactions by players in establishments.

POST /orders/request

Requests a product reservation for a specific player.

Endpoint

POST/orders/request

Description

This endpoint allows a player to request a product reservation in an establishment. The system will verify product availability and create a pending transaction.

Request Body

{
  "productId": "prod_789012",     // required
  "playerId": "player_345678",    // required
  "establishmentId": "est_123456" // required
}

Request Body Parameters

AttributeTypeRequiredDescription
productIdstringYesUnique identifier of the product to reserve
playerIdstringYesUnique identifier of the player requesting the reservation
establishmentIdstringYesUnique identifier of the establishment where the reservation is made

Request Example

curl -X POST "https://stageapi.thepowerplugin.com//orders/request" \
  -H "Authorization: Bearer your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "prod_789012",
    "playerId": "player_345678",
    "establishmentId": "est_123456"
  }'

Responses

200 - Product Reserved Successfully

The reservation has been processed successfully.

{
  "message": "Product reserved successfully. Please request end user shipping details.",
  "transactionId": "7c02e8e3-9f29-43c1-9c89-4f7fa5d42c77",
  "digital": false,
  "trackUrl": "https://subdomain.thepowerplugin.com/orders/request-ship/abc123",
  "orderDetails": {
    "product": {
      "id": "prod_789012",
      "name": "iPhone 15 Pro",
      "price": 1199.99,
      "currency": "EUR"
    },
    "player": {
      "id": "player_345678",
      "name": "John Doe"
    },
    "establishment": {
      "id": "est_123456",
      "name": "Casino Royal Madrid"
    },
    "reservedAt": "2024-01-20T15:30:00Z",
    "expiresAt": "2024-01-21T15:30:00Z"
  }
}

400 - Bad Request or Validation Error

Error in sent data or validation failed.

{
  "error": "VALIDATION_ERROR",
  "message": "The provided data is not valid",
  "details": [
    {
      "field": "productId",
      "message": "productId is required"
    }
  ],
  "code": 400
}

404 - Resource Not Found

The product, player, or establishment does not exist.

{
  "error": "RESOURCE_NOT_FOUND",
  "message": "Product with ID prod_789012 not found",
  "code": 404
}

409 - Conflict

The product is not available or already reserved.

{
  "error": "PRODUCT_UNAVAILABLE",
  "message": "The requested product is not available at this time",
  "code": 409
}

500 - Internal Server Error

Internal server error.

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}

Players

Players are users who participate in games and can make purchases in establishments.

GET /players

Gets a paginated list of all players.

Endpoint

GET/players

Description

This endpoint allows you to retrieve a list of players with pagination and optional filters.

Query Parameters

AttributeDescriptionTypeLocationRequired
pagePage number (default: 1)integerqueryNo
limitItems per page (default: 20, max: 100)integerqueryNo
establishmentIdFilter by specific establishmentstringqueryNo
statusFilter by player status (active, inactive, suspended)stringqueryNo

Request Example

curl -X GET "https://stageapi.thepowerplugin.com//players?page=1&limit=10&establishmentId=est_123456" \
  -H "Authorization: Bearer your_token_here"

Responses

200 - Players List Retrieved Successfully

{
  "players": [
    {
      "id": "player_345678",
      "name": "John Doe",
      "email": "john.doe@email.com",
      "phone": "+34 600 123 456",
      "status": "active",
      "establishmentId": "est_123456",
      "totalSpent": 2500.50,
      "currency": "EUR",
      "createdAt": "2024-01-10T09:15:00Z",
      "lastActivity": "2024-01-20T14:30:00Z"
    }
  ],
  "pagination": {
    "currentPage": 1,
    "totalPages": 5,
    "totalItems": 47,
    "itemsPerPage": 10
  }
}

400 - Invalid Parameters

{
  "error": "INVALID_PARAMETERS",
  "message": "The 'limit' parameter cannot be greater than 100",
  "code": 400
}

POST /players

Creates a new player in the system.

Endpoint

POST/players

Description

Registers a new player in the Smartico platform.

Request Body

{
  "name": "Jane Smith",
  "email": "jane.smith@email.com",
  "phone": "+34 600 987 654",
  "establishmentId": "est_123456",
  "dateOfBirth": "1990-05-15",
  "address": {
    "street": "Calle Mayor 45",
    "city": "Barcelona",
    "postalCode": "08001",
    "country": "Spain"
  }
}

Request Body Parameters

AttributeTypeRequiredDescription
namestringYesPlayer's full name
emailstringYesPlayer's unique email
phonestringYesPhone number
establishmentIdstringYesID of the establishment where they register
dateOfBirthstringNoDate of birth (YYYY-MM-DD)
addressobjectNoPlayer's address

Responses

201 - Player Created Successfully

{
  "id": "player_789012",
  "name": "Jane Smith",
  "email": "jane.smith@email.com",
  "phone": "+34 600 987 654",
  "status": "active",
  "establishmentId": "est_123456",
  "totalSpent": 0.00,
  "currency": "EUR",
  "createdAt": "2024-01-20T16:45:00Z",
  "message": "Player created successfully"
}

400 - Invalid Data

{
  "error": "VALIDATION_ERROR",
  "message": "The provided data is not valid",
  "details": [
    {
      "field": "email",
      "message": "Email is already registered"
    }
  ],
  "code": 400
}

500 - Internal Server Error

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}

GET /players/{playerId}

Gets detailed information about a specific player.

Endpoint

GET/players/{playerId}

Description

Retrieves all information associated with a player, including their history and statistics.

Parameters

AttributeDescriptionTypeLocationRequired
playerIdUnique player identifierstringpathYes

Responses

200 - Player Found Successfully

{
  "id": "player_345678",
  "name": "John Doe",
  "email": "john.doe@email.com",
  "phone": "+34 600 123 456",
  "status": "active",
  "establishmentId": "est_123456",
  "dateOfBirth": "1985-03-22",
  "address": {
    "street": "Calle Alcalá 123",
    "city": "Madrid",
    "postalCode": "28014",
    "country": "Spain"
  },
  "statistics": {
    "totalSpent": 2500.50,
    "totalOrders": 15,
    "averageOrderValue": 166.70,
    "lastOrderDate": "2024-01-18T10:30:00Z"
  },
  "createdAt": "2024-01-10T09:15:00Z",
  "lastActivity": "2024-01-20T14:30:00Z"
}

404 - Player Not Found

{
  "error": "PLAYER_NOT_FOUND",
  "message": "Player with ID player_345678 not found",
  "code": 404
}

PUT /players/{playerId}

Updates information for an existing player.

Endpoint

PUT/players/{playerId}

Description

Allows you to modify data for a registered player.

Parameters

AttributeDescriptionTypeLocationRequired
playerIdUnique player identifierstringpathYes

Request Body

{
  "name": "John Carlos Doe",
  "phone": "+34 600 123 999",
  "address": {
    "street": "Calle Nueva 456",
    "city": "Madrid",
    "postalCode": "28015",
    "country": "Spain"
  }
}

Responses

200 - Player Updated Successfully

{
  "id": "player_345678",
  "name": "John Carlos Doe",
  "email": "john.doe@email.com",
  "phone": "+34 600 123 999",
  "status": "active",
  "establishmentId": "est_123456",
  "updatedAt": "2024-01-20T17:00:00Z",
  "message": "Player updated successfully"
}

404 - Player Not Found

{
  "error": "PLAYER_NOT_FOUND",
  "message": "Player with ID player_345678 not found",
  "code": 404
}

DELETE /players/{playerId}

Deletes a player from the system.

Endpoint

DELETE/players/{playerId}

Description

Permanently deletes a player and all associated data.

Parameters

AttributeDescriptionTypeLocationRequired
playerIdUnique player identifierstringpathYes

Responses

200 - Player Deleted Successfully

{
  "message": "Player deleted successfully",
  "deletedPlayerId": "player_345678",
  "deletedAt": "2024-01-20T17:15:00Z"
}

404 - Player Not Found

{
  "error": "PLAYER_NOT_FOUND",
  "message": "Player with ID player_345678 not found",
  "code": 404
}

Products

Products are items that players can purchase with their points or coins in establishments.

POST /exclusive

Creates an exclusive product for a specific establishment.

Endpoint

POST/exclusive

Description

Allows you to create exclusive products that will only be available in specific establishments.

Request Body

{
  "name": "VIP Exclusive Product",
  "description": "Special product only for VIP members",
  "price": 500.00,
  "currency": "EUR",
  "establishmentId": "est_123456",
  "category": "electronics",
  "stock": 10,
  "isDigital": false,
  "imageUrl": "https://example.com/product-image.jpg"
}

Request Body Parameters

AttributeTypeRequiredDescription
namestringYesProduct name
descriptionstringYesDetailed product description
pricenumberYesProduct price
currencystringYesCurrency (EUR, USD, etc.)
establishmentIdstringYesExclusive establishment ID
categorystringYesProduct category
stockintegerNoAvailable quantity (default: 0)
isDigitalbooleanNoIf it's a digital product (default: false)
imageUrlstringNoProduct image URL

Responses

201 - Exclusive Product Created Successfully

{
  "id": "prod_exclusive_001",
  "name": "VIP Exclusive Product",
  "description": "Special product only for VIP members",
  "price": 500.00,
  "currency": "EUR",
  "establishmentId": "est_123456",
  "category": "electronics",
  "stock": 10,
  "isDigital": false,
  "imageUrl": "https://example.com/product-image.jpg",
  "status": "active",
  "createdAt": "2024-01-20T18:00:00Z",
  "message": "Exclusive product created successfully"
}

400 - Invalid Data

{
  "error": "VALIDATION_ERROR",
  "message": "The provided data is not valid",
  "details": [
    {
      "field": "price",
      "message": "Price must be a positive number"
    }
  ],
  "code": 400
}

500 - Internal Server Error

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}

GET /products

Gets a list of available products.

Endpoint

GET/products

Description

Retrieves a paginated list of products with optional filters.

Parameters

AttributeDescriptionTypeLocationRequired
establishment_idEstablishment ID to filter productsstringqueryYes
pagePage number (default: 1)integerqueryNo
limitItems per page (default: 20)integerqueryNo
categoryFilter by categorystringqueryNo
minPriceMinimum pricenumberqueryNo
maxPriceMaximum pricenumberqueryNo
statusProduct status (active, inactive)stringqueryNo

Request Example

curl -X GET "https://stageapi.thepowerplugin.com//products?establishment_id=est_123456&page=1&limit=10&category=electronics" \
  -H "Authorization: Bearer your_token_here"

Responses

200 - Products List Retrieved Successfully

{
  "products": [
    {
      "id": "prod_789012",
      "name": "iPhone 15 Pro",
      "description": "Latest generation smartphone",
      "price": 1199.99,
      "currency": "EUR",
      "category": "electronics",
      "stock": 5,
      "isDigital": false,
      "imageUrl": "https://example.com/iphone15.jpg",
      "status": "active",
      "createdAt": "2024-01-15T10:00:00Z"
    }
  ],
  "pagination": {
    "currentPage": 1,
    "totalPages": 3,
    "totalItems": 25,
    "itemsPerPage": 10
  }
}

400 - Invalid Parameters

{
  "error": "INVALID_PARAMETERS",
  "message": "establishment_id is required",
  "code": 400
}

500 - Internal Server Error

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}

POST /products

Creates a new product in the system.

Endpoint

POST/products

Description

Registers a new product that will be available in establishments.

Request Body

{
  "name": "Samsung Galaxy S24",
  "description": "High-end Android smartphone",
  "price": 999.99,
  "currency": "EUR",
  "category": "electronics",
  "stock": 20,
  "isDigital": false,
  "imageUrl": "https://example.com/galaxy-s24.jpg",
  "establishmentIds": ["est_123456", "est_789012"]
}

Request Body Parameters

AttributeTypeRequiredDescription
namestringYesProduct name
descriptionstringYesProduct description
pricenumberYesProduct price
currencystringYesProduct currency
categorystringYesProduct category
stockintegerNoStock quantity (default: 0)
isDigitalbooleanNoIf it's digital (default: false)
imageUrlstringNoImage URL
establishmentIdsarrayYesIDs of establishments where it will be available

Responses

201 - Product Created Successfully

{
  "id": "prod_galaxy_s24",
  "name": "Samsung Galaxy S24",
  "description": "High-end Android smartphone",
  "price": 999.99,
  "currency": "EUR",
  "category": "electronics",
  "stock": 20,
  "isDigital": false,
  "imageUrl": "https://example.com/galaxy-s24.jpg",
  "establishmentIds": ["est_123456", "est_789012"],
  "status": "active",
  "createdAt": "2024-01-20T19:00:00Z",
  "message": "Product created successfully"
}

400 - Invalid Data

{
  "error": "VALIDATION_ERROR",
  "message": "The provided data is not valid",
  "details": [
    {
      "field": "price",
      "message": "Price must be a positive number"
    }
  ],
  "code": 400
}

500 - Internal Server Error

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}

GET /products/{productId}

Gets detailed information about a specific product.

Endpoint

GET/products/{productId}

Description

Retrieves all information associated with a product, including availability and details.

Parameters

AttributeDescriptionTypeLocationRequired
productIdUnique product identifierstringpathYes

Responses

200 - Product Found Successfully

{
  "id": "prod_789012",
  "name": "iPhone 15 Pro",
  "description": "Latest generation smartphone with professional camera",
  "price": 1199.99,
  "currency": "EUR",
  "category": "electronics",
  "stock": 5,
  "isDigital": false,
  "imageUrl": "https://example.com/iphone15.jpg",
  "status": "active",
  "establishmentIds": ["est_123456", "est_789012"],
  "specifications": {
    "brand": "Apple",
    "model": "iPhone 15 Pro",
    "color": "Natural Titanium",
    "storage": "256GB"
  },
  "createdAt": "2024-01-15T10:00:00Z",
  "updatedAt": "2024-01-20T14:30:00Z"
}

404 - Product Not Found

{
  "error": "PRODUCT_NOT_FOUND",
  "message": "Product with ID prod_789012 not found",
  "code": 404
}

PUT /products/{productId}

Updates information for an existing product.

Endpoint

PUT/products/{productId}

Description

Allows you to modify data for a registered product.

Parameters

AttributeDescriptionTypeLocationRequired
productIdUnique product identifierstringpathYes

Request Body

{
  "name": "iPhone 15 Pro Max",
  "price": 1299.99,
  "stock": 8,
  "description": "Latest generation smartphone with larger screen"
}

Responses

200 - Product Updated Successfully

{
  "id": "prod_789012",
  "name": "iPhone 15 Pro Max",
  "description": "Latest generation smartphone with larger screen",
  "price": 1299.99,
  "currency": "EUR",
  "category": "electronics",
  "stock": 8,
  "isDigital": false,
  "imageUrl": "https://example.com/iphone15.jpg",
  "status": "active",
  "updatedAt": "2024-01-20T20:00:00Z",
  "message": "Product updated successfully"
}

404 - Product Not Found

{
  "error": "PRODUCT_NOT_FOUND",
  "message": "Product with ID prod_789012 not found",
  "code": 404
}

500 - Internal Server Error

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}

DELETE /products/{productId}

Deletes a product from the system.

Endpoint

DELETE/products/{productId}

Description

Permanently deletes a product and all associated data.

Parameters

AttributeDescriptionTypeLocationRequired
productIdUnique product identifierstringpathYes

Responses

200 - Product Deleted Successfully

{
  "message": "Product deleted successfully",
  "deletedProductId": "prod_789012",
  "deletedAt": "2024-01-20T20:30:00Z"
}

404 - Product Not Found

{
  "error": "PRODUCT_NOT_FOUND",
  "message": "Product with ID prod_789012 not found",
  "code": 404
}

500 - Internal Server Error

{
  "error": "INTERNAL_SERVER_ERROR",
  "message": "An internal error occurred. Please try again later.",
  "code": 500
}