REST API

The Sublogin API add-on (MageB2B_SubloginApi) exposes Sublogin CRUD endpoints via Magento Web API (REST/SOAP) for integration with ERP, CRM, or automation scripts.

Base URL

https://yourstore.com/rest/V1/sublogin

Endpoints

1. Get Sublogin by ID

GET /V1/sublogin/:id ACL: MageB2B_Sublogin::manage

2. Search Sublogins

GET /V1/sublogin/search ACL: MageB2B_Sublogin::manage Uses standard Magento searchCriteria.

3. Create Sublogin

POST /V1/sublogin ACL: MageB2B_Sublogin::save

4. Update Sublogin

PUT /V1/sublogin/:id ACL: MageB2B_Sublogin::save

5. Delete Sublogin

DELETE /V1/sublogin/:id ACL: MageB2B_Sublogin::delete

Field Reference: Sublogin

Field Type Required Description
id int No (auto) Primary key of the sublogin
entity_id int Yes Magento Customer Entity ID (FK to customer_entity.entity_id)
customer_id string No External customer number (e.g., ERP number)
email string Yes Login email address (must be unique)
optional_email string No Alternative email for notifications
password string Yes (POST) Password (stored hashed)
firstname string Yes First name
lastname string Yes Last name
prefix string No Prefix (e.g., "Mr.", "Ms.", "Dr.")
expire_date string No Account expiration date (YYYY-MM-DD), null = no expiration
active bool No true = active, false = disabled
send_backendmails bool No Receives copies of backend emails (order confirmations, etc.)
store_id int No Store View ID
create_sublogins bool No Permission to create further sublogins
is_subscribed bool No Newsletter subscription
last_login_at string No (auto) Last login timestamp
default_billing int No ID of the default billing address
default_shipping int No ID of the default shipping address
customer_address_ids string[] No IDs of allowed customer addresses (from parent customer)
addresses Address[] No Custom sublogin addresses

Field Reference: Address

Field Type Required Description
id int No (auto) Primary key
prefix string No Prefix
firstname string Yes First name
lastname string Yes Last name
company string No Company name
street string[] Yes Street and house number (Array for multi-line)
city string Yes City
country_id string Yes Country code (ISO 3166-1 alpha-2)
postcode string Yes Postcode
telephone string Yes Telephone number
default_billing bool No Set as default billing address
default_shipping bool No Set as default shipping address

ID Logic

  • id: Primary key of the sublogin record.
  • entity_id: Magento Customer Entity ID (parent customer).
  • customer_id: External ID (e.g., "K-2024-00123" from ERP).

Address Concept

Sublogins can use two types of addresses:

  1. Customer Addresses: Referenced by IDs from the parent customer.
  2. Custom Addresses: Independent addresses specific to the sublogin.

Examples

Create Sublogin with Custom Address

curl -X POST "https://yourstore.com/rest/V1/sublogin" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "sublogin": {
        "entity_id": 123,
        "email": "purchasing@company.com",
        "password": "Secure123!",
        "firstname": "John",
        "lastname": "Doe",
        "active": true,
        "addresses": [
            {
                "firstname": "John",
                "lastname": "Doe",
                "company": "Company Ltd - Purchasing",
                "street": ["Industrial St 10"],
                "city": "Hamburg",
                "country_id": "DE",
                "postcode": "20095",
                "telephone": "+49 40 987654",
                "default_billing": true,
                "default_shipping": true
            }
        ]
    }
}'

Search Sublogins for a Customer

curl -X GET "https://yourstore.com/rest/V1/sublogin/search?searchCriteria[filterGroups][0][filters][0][field]=entity_id&searchCriteria[filterGroups][0][filters][0][value]=123" \
  -H "Authorization: Bearer <token>"

Found an issue with this documentation? Let us know