Install the Companies Backend API
Edit on GitHubThis document describes how to install the Companies Backend API, which exposes company data at /companies through the Glue Backend application. For the endpoint reference, see Backend API: Manage companies.
Prerequisites
Install the required features:
| NAME | VERSION | INSTALLATION GUIDE |
|---|---|---|
| Spryker Core | 202608.0 | Install the Spryker Core feature |
| Company Account | 202608.0 | Install the Company Account feature |
| API Platform | — | Enable API Platform |
Step 1 installs the remaining modules the API depends on, so you do not have to install them beforehand.
The /companies 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 feature core
1) Install the required modules
Install the feature using Composer:
composer require spryker-feature/customer-experience-management --update-with-dependencies
2) Check the API Platform configuration
The resource schema ships inside the installed package, at vendor/spryker-feature/customer-experience-management/resources/api/backend/companies.resource.yml. The generator finds it as long as the Glue Backend application serves the backend API type and scans the directory the feature 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.
If your project sets sourceDirectories() explicitly, add the directory the feature 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
docker/sdk console propel:install
Make sure the spy_company table has a uuid column and that existing rows are backfilled. The UUID behavior fills the column when a company is saved; companies created before the module was installed have an empty uuid and cannot be addressed by the API until they are saved again.
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/*
Make sure the generated resource class exists at src/Generated/Api/Backend/CompaniesBackendResource.php. If it does not, the schema was not discovered—check the sourceDirectories setting from step 2.
Verification
Request a Back Office access token as described in Authenticate as a Back Office user, then retrieve a company collection.
Retrieve a company collection
curl "https://glue-backend.mysprykershop.com/companies?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 company to confirm the write path:
curl -X POST "https://glue-backend.mysprykershop.com/companies" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/vnd.api+json" \
-H "Accept: application/vnd.api+json" \
-d '{"data":{"type":"companies","attributes":{"name":"Acme Corporation"}}}'
The request returns 201 with the created company, which is pending and inactive.
Troubleshooting
| SYMPTOM | CAUSE |
|---|---|
404 with error code 007 while src/Generated/Api/Backend/CompaniesBackendResource.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 /companies and no generated resource class |
The schema was not discovered. Confirm that spryker/api-platform is installed, and, if your project overrides sourceDirectories(), that it still covers the directory the feature is installed into. |
| Validation messages come back in English when another language was requested | The feature 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. |
404 with error code 1213 for a company you can see in the Back Office |
That company’s uuid is empty. Save it once in the Back Office to have the UUID behavior fill the column. |
Thank you!
For submitting the form