Install the Merchants Backend API

Edit on GitHub

This document describes how to install the Merchants Backend API, which exposes merchant data at /merchants through the Glue Backend application. For the endpoint reference, see Backend API: Manage merchants.

Prerequisites

Install the required features:

NAME VERSION INSTALLATION GUIDE
Spryker Core 202608.0 Install the Spryker Core feature
Merchant 202608.0 Install the Merchant feature
API Platform — Enable API Platform
Minimum spryker/merchant version

The Backend API ships in the spryker/merchant module starting with version 3.22.0. Installing the Merchant feature alone does not guarantee this version—check your installed version and upgrade it if it resolved lower:

composer show spryker/merchant | grep versions
API Platform is required

The /merchants resource is generated by API Platform, which is not enabled in every project. If your project does not serve any API Platform resource on the Glue Backend application yet, complete Enable API Platform first—this guide assumes the Glue Backend application already boots with SprykerApiPlatformBundle registered.

Install the module

1) Install or upgrade the module

Install or upgrade spryker/merchant to at least 3.22.0 using Composer:

composer require spryker/merchant:"^3.22.0" --update-with-dependencies

2) Check the API Platform configuration

The resource schema ships inside the installed package, at vendor/spryker/merchant/resources/api/backend/merchants.resource.yml. The generator finds it as long as the Glue Backend application serves the backend API type and scans the directory the module is installed into.

In config/GlueBackend/packages/spryker_api_platform.php, confirm that apiTypes() includes backend. Leave sourceDirectories() alone unless your project overrides it—the default already covers installed packages. For what both settings do, see Configuration.

Projects that override sourceDirectories

If your project sets sourceDirectories() explicitly, add the directory the module is installed into rather than replacing the list. Dropping the other entries hides every resource your project already serves.

Also confirm that config/GlueBackend/bundles.php registers SprykerApiPlatformBundle and ApiPlatformBundle. If it does not, your project has not enabled API Platform for the Glue Backend yet—see Enable API Platform.

3) Set up the database schema and transfer objects

Apply the database schema changes and generate the transfer objects:

docker/sdk console transfer:generate

4) Generate the API resources

Generate the API resources, then clear the Glue Backend kernel cache:

docker/sdk cli "GLUE_APPLICATION=GLUE_BACKEND vendor/bin/glue api:generate"
rm -rf data/cache/GlueBackend/*
Verification

Make sure the generated resource class exists at src/Generated/Api/Backend/MerchantsBackendResource.php. If it does not, the schema was not discovered—check the sourceDirectories setting from step 2, and confirm spryker/merchant resolved to at least 3.22.0.

Enable isOpenForRelationRequest

The isOpenForRelationRequest attribute is added to the merchants resource by the spryker/merchant-relation-request module, starting with version 1.2.0. It ships its own merchants.resource.yml that extends the resource defined by spryker/merchant. This step is optional—skip it if you do not need the attribute.

1) Install the module

composer require spryker/merchant-relation-request:"^1.2.0" --update-with-dependencies

2) Register the expander plugins

The module contributes the attribute through resource and transfer expander plugins, which are not registered by default. Add them in src/Pyz/Glue/Merchant/MerchantDependencyProvider.php:

<?php

namespace Pyz\Glue\Merchant;

use Spryker\Glue\Merchant\MerchantDependencyProvider as SprykerMerchantDependencyProvider;
use Spryker\Glue\MerchantRelationRequest\Api\Backend\Plugin\MerchantRelationRequestResourceExpanderPlugin;
use Spryker\Glue\MerchantRelationRequest\Api\Backend\Plugin\MerchantRelationRequestTransferExpanderPlugin;

class MerchantDependencyProvider extends SprykerMerchantDependencyProvider
{
    /**
     * @return array<\Spryker\Glue\MerchantExtension\Dependency\Plugin\MerchantBackendResourceExpanderPluginInterface>
     */
    protected function getMerchantBackendResourceExpanderPlugins(): array
    {
        return [
            new MerchantRelationRequestResourceExpanderPlugin(),
        ];
    }

    /**
     * @return array<\Spryker\Glue\MerchantExtension\Dependency\Plugin\MerchantBackendTransferExpanderPluginInterface>
     */
    protected function getMerchantBackendTransferExpanderPlugins(): array
    {
        return [
            new MerchantRelationRequestTransferExpanderPlugin(),
        ];
    }
}
Regenerate after registering the plugins

Re-run step 4 from Install the module—vendor/bin/glue api:generate—and clear the Glue Backend kernel cache, so the generated schema picks up isOpenForRelationRequest.

Verification

Request a Back Office access token as described in Authenticate as a Back Office user, then retrieve a merchant collection.

Retrieve a merchant collection

curl "https://glue-backend.mysprykershop.com/merchants?page[limit]=1" \
  -H "Authorization: Bearer {access_token}" \
  -H "Accept: application/vnd.api+json"

The integration is successful when the request returns 200 with a data array and a meta.pagination object.

Create a merchant to confirm the write path:

curl -X POST "https://glue-backend.mysprykershop.com/merchants" \
  -H "Authorization: Bearer {access_token}" \
  -H "Content-Type: application/vnd.api+json" \
  -H "Accept: application/vnd.api+json" \
  -d '{"data":{"type":"merchants","attributes":{"merchantReference":"MER000001","name":"Spryker Merchant","email":"[email protected]"}}}'

The request returns 201 with the created merchant, which is waiting-for-approval and inactive.

Troubleshooting

SYMPTOM CAUSE
404 with error code 007 while src/Generated/Api/Backend/MerchantsBackendResource.php exists The route is unknown to the API Platform kernel, so the Glue router answered instead. The kernel cache is stale—check that you removed the directory that actually exists under data/cache/GlueBackend/, then re-run step 4 in order. The Glue container’s standard error stream names the real cause: docker logs <glue-backend-container> --since 5m 2>&1 | grep -i exception. See API Platform troubleshooting.
404 on /merchants and no generated resource class The schema was not discovered. Confirm that spryker/api-platform is installed, that spryker/merchant resolved to at least 3.22.0, and, if your project overrides sourceDirectories(), that it still covers the directory the module is installed into.
Validation messages come back in English when another language was requested The module ships its API messages as data/translation/Api/{locale}.csv inside the installed package, keyed by the English message. If they are not loaded, Symfony falls back to the message itself, so the response stays readable and the problem is easy to miss. Send Accept-Language and compare. Loading these files requires a spryker/api-platform version that reads them—update it to the latest version your project supports.