Secure admin API for OpenCart 4 with HMAC authentication, scoped read/write access, and admin dashboard for monitoring API activity.
- HMAC Authentication: Secure API requests with HMAC-SHA256 signatures
- Scoped Access: Fine-grained permissions for API users (read/write per resource)
- Admin Dashboard: Monitor API users, endpoints, scopes, and activity
- Multiple Endpoints: Comprehensive coverage of admin resources:
- Categories
- Coupons
- Customer groups
- Customers
- Manufacturers
- Orders
- Products
- Returns
- Vouchers
- And metadata endpoints
- CORS Support: Configure allowed origins and IP whitelisting
- Language Support: Full English and Spanish UI
- Extract the OCMOD zip file or copy the extension folder to your OpenCart
extension/directory - Navigate to Extensions -> Extensions -> Modules in your OpenCart admin
- Find Ferrez Admin API and click Install
- Access the dashboard via Modules -> Ferrez Admin API or through the main sidebar
- Go to System -> Users -> API
- Click Add New
- Enter username and password
- Configure token generation method
After creating an API user:
- In the Ferrez Admin API dashboard, view Configured Scopes
- Assign read/write permissions for specific resources
- Save permissions JSON configuration
Use your API credentials to sign requests with HMAC-SHA256:
curl -X GET "http://localhost/api/admin/v1/products" \
-H "Authorization: HMAC-SHA256 username=myuser signature=..." \
-H "Content-Type: application/json"GET /api/admin/v1/products- List productsGET /api/admin/v1/products/{product_id}- Get product detailsPOST /api/admin/v1/products- Create productPUT /api/admin/v1/products/{product_id}- Update productDELETE /api/admin/v1/products/{product_id}- Delete product
GET /api/admin/v1/categories- List categoriesGET /api/admin/v1/categories/{category_id}- Get categoryPOST /api/admin/v1/categories- Create categoryPUT /api/admin/v1/categories/{category_id}- Update category
GET /api/admin/v1/orders- List ordersGET /api/admin/v1/orders/{order_id}- Get order detailsPUT /api/admin/v1/orders/{order_id}- Update order status/history
GET /api/admin/v1/customers- List customersGET /api/admin/v1/customers/{customer_id}- Get customerPOST /api/admin/v1/customers- Create customerPUT /api/admin/v1/customers/{customer_id}- Update customer
- Coupons:
GET|POST|PUT /api/admin/v1/coupons - Vouchers:
GET|POST|PUT /api/admin/v1/vouchers - Manufacturers:
GET|POST|PUT /api/admin/v1/manufacturers - Customer Groups:
GET /api/admin/v1/customer_groups - Returns:
GET|PUT /api/admin/v1/returns - Metadata:
GET /api/admin/v1/metadata
-
Create a canonical request string:
METHOD\nPATH\nQUERY_STRING\nBODY_HASH\nTIMESTAMP -
Sign with HMAC-SHA256 using API user's secret key
-
Add
Authorizationheader:Authorization: HMAC-SHA256 username=myuser timestamp=1234567890 signature=...
- Requests must include a
timestampparameter - Server validates timestamp is within acceptable window (default: +/- 5 minutes)
- Prevents replay attacks
Scopes define read/write permissions per resource. Configure via the admin dashboard:
{
"products": {
"read": true,
"write": false
},
"orders": {
"read": true,
"write": true
},
"customers": {
"read": true,
"write": false
}
}- Global scopes: Apply to all API users with matching scopes
- User-specific scopes: Override global scopes for individual users
- Resource-level: Control read/write at granular level
- Go to Ferrez Admin API settings
- Set Allowed Origins (comma-separated)
- Optionally configure IP Whitelist
- Use HTTPS in production
- Rotate API credentials regularly
- Limit API user permissions to necessary resources
- Monitor API activity in the dashboard
- Use IP whitelisting for sensitive environments
- Enable request signing validation
The extension provides a comprehensive dashboard with:
- Extension Status: Enable/disable the API
- API Users: View configured users and their scopes
- Configured Scopes: Edit and manage permissions
- Endpoints: Browse available endpoints
- Route Reference: View API routes and methods
- Last Updated: Track configuration changes
- System -> Modules -> Ferrez Admin API
- Route Reference shows extension route and pretty route base URLs.
- The dashboard now includes a quick reminder for product image upload.
- For product create/update, send images with
multipart/form-dataand file fieldimage_file.
Recommended upload format for product images is multipart/form-data using the file field image_file.
- Endpoint:
POST /api/admin/v1/product(create) - Endpoint:
PUT /api/admin/v1/product/{product_id}(update) - File field:
image_file - Allowed extensions:
jpg,jpeg,png,gif,webp - Default max size: 5 MB (configurable via
module_ferrez_admin_rest_api_max_upload_size)
Example:
curl -X POST "http://localhost:8080/api/admin/v1/product?route=extension/ferrez_admin_rest_api/api/admin&username=...&store_id=0&language=es-es¤cy=MXN&time=...&signature=..." \
-F "name=Demo Product" \
-F "model=DEMO-001" \
-F "price=149.90" \
-F "quantity=5" \
-F "image_file=@C:/tmp/product.jpg"- Check HMAC signature calculation
- Verify timestamp is within acceptable range
- Confirm API user has required scopes
- Check if user is enabled
- Verify API user has read/write permission for resource
- Check scope configuration in dashboard
- Ensure request includes valid authentication
- Verify permissions JSON is valid JSON
- Check that scope is correctly configured in dashboard
- Restart OpenCart or clear cache
- Add origin to Allowed Origins list
- Verify the exact origin URL (including protocol)
- Check IP whitelisting if configured
All responses follow JSON:API standard structure:
{
"data": {
"id": 1,
"type": "product",
"attributes": {
"name": "Product Name",
"price": 99.99,
"status": 1
}
}
}{
"errors": [
{
"status": 400,
"title": "Bad Request",
"detail": "Invalid parameter: category_id"
}
]
}ferrez_admin_rest_api/
|- install.json # Metadata
|- admin/
| |- controller/module/ferrez_admin_rest_api.php # Admin module handler
| |- view/template/module/ferrez_admin_rest_api.twig # Admin UI
| `- language/
| |- en-gb/module/ferrez_admin_rest_api.php
| `- es-es/module/ferrez_admin_rest_api.php
`- catalog/
|- controller/
| |- api/admin.php # Main API controller
| |- api/base.php # Base API class
| `- startup/admin_api.php # Route registration
|- model/api/
| |- category.php
| |- coupon.php
| |- customer_group.php
| |- customer.php
| |- manufacturer.php
| |- metadata.php
| |- order.php
| |- product.php
| |- returns.php
| `- voucher.php
`- language/en-gb/api/admin.php
- Request arrives at
/api/admin/v1/{resource} - HMAC signature validation
- Authentication/Authorization check
- Scope permission verification
- Resource handler execution
- Response serialization (JSON:API format)
- GitHub: aztek-org/ferrez-admin-api-extension
- Issues: Report bugs or feature requests on GitHub Issues
- Bug Fix: Fixed HTML escaping issue in JSON permissions configuration
- Added
htmlspecialchars_decode()to properly handle API permissions - Prevents JSON corruption when saving scopes in admin panel
- Added
- Simplified: Removed extension version tracking from admin controller
- Standardized: Endpoint names now use consistent plural form (
products,orders,categories, etc.) - Cleanup: Removed embedded Postman documentation (moved to separate repository)
- Updated: Install metadata for better extension management
- Added product image upload reminder on the extension admin page
- Updated repository documentation for extension page and multipart upload guidance
- Fixed README character encoding issues
- Added multipart image upload capability for product create/update API
- Renamed to Ferrez Admin API (simplified branding)
- HMAC-SHA256 authentication
- Scoped read/write access control
- Admin dashboard with monitoring
- Multi-language support (EN/ES)
- Comprehensive endpoint coverage
- Initial release as Ferrez Admin API
Proprietary - Ferrez.mx
Ferrez.mx Development Team