← Back to EcomCentral
MAGENTO 2 REST API

Magento 2 Setup Guide

Connect your Magento 2 store to EcomCentral using the REST API with an Admin Integration Bearer token.

Prerequisites

ℹ️ EcomCentral uses Admin Integration Tokens — the simplest and most stable authentication method for server-to-server Magento 2 API access. OAuth2 integrations also work if you prefer per-user authorization.

Creating an Integration Token

  1. Log in to your Magento Admin Panel (usually at /admin)
  2. Go to System → Extensions → Integrations
  3. Click Add New Integration
  4. Enter a name (e.g. "EcomCentral") and your admin password to confirm
  5. Click the API tab and select the resource scopes you need:
    • Sales / Orders — for reading and creating shipments
    • Catalog / Products — for reading products and updating stock
    • Stores / Store Configs — for the connection test
  6. Click Save, then click Activate
  7. Magento shows a dialog with four tokens — copy the Access Token
  8. In EcomCentral, add a new Magento 2 connection with:
    base_url = your store URL  ·  access_token = the token you just copied
  9. Click ⚡ Test to verify — it returns your store count and base currency
⚠️ Integration access tokens do not expire by default, but will be invalidated if you deactivate or delete the integration. Keep the token secret — it grants admin-level API access.

Credentials Reference

KeyRequiredDescriptionExample
base_url Required Root URL of your Magento 2 store — no trailing slash https://shop.example.com
access_token Required Admin Integration access token from System → Integrations a1b2c3d4e5f6…
store_code Optional Magento store view code. Defaults to default if omitted default
✅ Alternative key names accepted: baseUrl / url for base URL; accessToken / token for the access token; storeCode for the store view.

API Endpoints Used

OperationMethodEndpoint
Test connectionGET/rest/V1/store/storeConfigs
List ordersGET/rest/V1/orders?searchCriteria[…]
Order detailGET/rest/V1/orders/{id}
Create shipmentPOST/rest/V1/order/{id}/ship
Add order commentPOST/rest/V1/orders/{id}/comments
List productsGET/rest/V1/products?searchCriteria[…]
Product detailGET/rest/V1/products/{sku}
Update stockPUT/rest/V1/products/{sku}

Order Statuses

pending
New order, not yet processed
pending_payment
Waiting for payment confirmation
payment_review
Payment under fraud review
processing
Payment received, order processing
complete
Shipped and invoiced
closed
Refunded and closed
canceled
Order cancelled
holded
Manually placed on hold

Supported Features

FeatureSupportedNotes
View orders (paginated)Sorted by created_at DESC
View order detailBilling + shipping address, line items, totals, order history
Create shipment + trackingPOST /ship — returns new shipment ID
Add status commentChange status + optional customer email notify
View products (paginated)Name, SKU, price, stock qty
Update stock quantityPUT product with stock_item.qty
Multi-store viewsSet store_code per connection
Test connectionReturns store count + base currency

Troubleshooting

✕ 401 Unauthorized

The access token is invalid or expired. Regenerate the integration token in System → Integrations and update the connection credential.

✕ 403 Forbidden on specific endpoints

The integration token lacks permission for the requested resource. Edit the integration, expand the API resource tree, and ensure Sales/Orders and Catalog/Products are checked.

✕ cURL error / SSL certificate

Your Magento store must use a valid HTTPS certificate. Self-signed certs on staging environments will be rejected. Either use a trusted cert or set up a Let's Encrypt certificate. For dev only, you can disable peer verification in Magento2Client.php (CURLOPT_SSL_VERIFYPEER => false).

✕ Stock not updating (MSI stores)

Magento 2.3+ with Multi-Source Inventory (MSI) uses a different stock architecture. The stock update via stock_item.qty targets the legacy CatalogInventory table. For MSI, use the dedicated PUT /rest/V1/inventory/source-items endpoint — you would need to extend Magento2Client.php to support it.

✕ 404 on order_detail

The entity_id (numeric ID) does not exist. Note that the orders list uses entity_id internally — this is different from the visible increment_id (e.g. #000000123). EcomCentral passes the correct entity_id automatically.