SyliusCon 2025
Early Bird Deal
LogoLogo
🛣️ Roadmap💻 Sylius Demo💬 Community Slack
  • Sylius Documentation
  • Sylius Plugins
  • Sylius Stack
  • đź“–Sylius 2.0 Documentation
    • Organization
      • Release Cycle
      • Backwards Compatibility Promise
      • Sylius Team
      • Sylius Roadmap
  • Getting Started with Sylius
    • Installation
    • Basic Configuration
    • Shipping & Payment
    • First Product
    • Customizing the Shop
    • Customizing Business Logic
    • Using API
    • Installing Plugins
    • Deployment
    • Summary
  • The Book
    • Introduction to Sylius
    • Installation
      • System Requirements
      • Sylius CE Installation
        • Sylius CE Installation with Docker
      • âž•Sylius Plus Installation
      • Upgrading Sylius CE
      • Upgrading Sylius Plus
    • Architecture
      • Architecture Overview
      • Architectural Drivers
      • Resource Layer
      • State Machine
      • Translations
      • E-Mails
      • Contact
      • Fixtures
      • Events
    • Configuration
      • Channels
      • Locales
      • Currencies
    • Customers
      • Customer & ShopUser
      • âž•Customer Pools
      • AdminUser
      • Addresses
        • Countries
        • Zones
        • Addresses
        • Address Book
    • Products
      • Products
      • Product Reviews
      • Product Associations
      • Attributes
      • Pricing
      • Catalog Promotions
      • Taxons
      • Inventory
      • âž•Multi-Source Inventory
      • Search
    • Carts & Orders
      • Orders
      • Cart flow
      • Taxation
      • Adjustments
      • Cart Promotions
      • Coupons
      • Payments
      • đź§©Invoices
      • Shipments
    • Support
    • Contributing
      • Contributing Code
        • Submitting a Patch
        • ⚠️Security Issues
        • Coding Standards
        • Conventions
        • Sylius License and Trademark
      • Contributing Translations
      • Key Contributors
  • The Customization Guide
    • Customizing Models
      • How to add a custom model?
      • How to add a custom translatable model?
    • Customizing Forms
      • How to add a live form for a custom model?
    • Customizing Styles
    • Customizing Validation
    • Customizing Menus
    • Customizing Templates
    • Customizing Translations
    • Customizing Flashes
    • Customizing State Machines
    • Customizing Grids
    • Customizing Fixtures
    • Customizing API
    • Customizing Serialization of API
    • Customizing Payments
      • How to integrate a Payment Gateway as a Plugin?
  • 🧑‍🍳The Cookbook
  • How to resize images?
  • How to add one image to an entity?
  • How to add multiple images to an entity?
  • Sylius 1.X Documentation
    • đź““Sylius 1.x Documentation
Powered by GitBook
LogoLogo

Developer

  • Community
  • Online Course

About

  • Team

© 2025 Sylius. All Rights Reserved

On this page
  • How to add an endpoint to the Sylius API?
  • How to remove an endpoint from the Sylius API?
  • How to rename an endpoint’s path?

Was this helpful?

Edit on GitHub
  1. The Customization Guide

Customizing API

Sylius uses API Platform to manage all API endpoints. This lets you configure endpoints using YAML or XML files or PHP class attributes. Here’s how to add, remove, and modify Sylius API endpoints.

How to add an endpoint to the Sylius API?

To add a custom endpoint for the Order resource, create a configuration file in the config/api_platform/ directory.

<?xml version="1.0" encoding="UTF-8" ?>
<!-- config/api_platform/Order.xml -->

<resources
    xmlns="https://api-platform.com/schema/metadata/resources-3.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0 https://api-platform.com/schema/metadata/resources-3.0.xsd"
>
    <resource class="%sylius.model.order.class%">
        <operations>
            <operation
                name="custom_operation"
                class="ApiPlatform\Metadata\Post"
                uriTemplate="/shop/orders/custom-operation"
                messenger="input"
                input="App\Command\CustomCommand"
            />
        </operations>
    </resource>
</resources>
# config/api_platform/Order.yaml

resources:
    '%sylius.model.order.class%':
        operations:
            ApiPlatform\Metadata\Post:
                name: custom_operation
                uriTemplate: '/shop/orders/custom-operation'
                messenger: input
                input: App\Command\CustomCommand

This configuration defines a new endpoint at /shop/orders/custom-operation that runs CustomCommand when accessed.

Order Modification Restrictions By default, Sylius API restricts order modifications to the "cart" state. If you need to perform actions on orders outside the cart state, add your custom endpoint to the sylius.api.doctrine_extension.order_shop_user_item.filter_cart.allowed_non_get_operations parameter. This will enable modifications for other order states.

How to remove an endpoint from the Sylius API?

If you don’t need certain endpoints (e.g., for shipping if you only sell digital products), you can disable them.

# config/packages/sylius_api.yaml

sylius_api:
    operations_to_remove:
        - 'sylius_api_shop_order_shipment_patch'

This configuration removes the specified endpoint from your API.

How to rename an endpoint’s path?

To change the path of an existing endpoint, redefine it in your configuration with the new path.

<?xml version="1.0" encoding="UTF-8" ?>
<!-- config/api_platform/Order.xml -->

<resources
    xmlns="https://api-platform.com/schema/metadata/resources-3.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0 https://api-platform.com/schema/metadata/resources-3.0.xsd"
>
    <resource class="%sylius.model.order.class%">
        <operations>
            <operation
                name="sylius_api_shop_order_post"
                class="ApiPlatform\Metadata\Post"
                uriTemplate="/shop/orders/custom-create"
                itemUriTemplate="/shop/orders/{tokenValue}"
                messenger="input"
                input="Sylius\Bundle\ApiBundle\Command\Cart\PickupCart"
            >
                <denormalizationContext>
                    <values>
                        <value name="groups">
                            <values>
                                <value>sylius:shop:order:create</value>
                            </values>
                        </value>
                    </values>
                </denormalizationContext>
                <normalizationContext>
                    <values>
                        <value name="groups">
                            <values>
                                <value>sylius:shop:cart:show</value>
                            </values>
                        </value>
                    </values>
                </normalizationContext>
            </operation>
        </operations>
    </resource>
</resources>
# config/api_platform/Order.yaml

resources:
    '%sylius.model.order.class%':
        operations:
            ApiPlatform\Metadata\Post:
                name: sylius_api_shop_order_post
                uriTemplate: '/shop/orders/custom-create'
                itemUriTemplate: '/shop/orders/{tokenValue}'
                messenger: input
                input: Sylius\Bundle\ApiBundle\Command\Cart\PickupCart
                denormalizationContext:
                    groups: ['sylius:shop:order:create']
                normalizationContext:
                    groups: ['sylius:shop:cart:show']
PreviousCustomizing FixturesNextCustomizing Serialization of API

Last updated 3 months ago

Was this helpful?

Learn more about endpoint operations in the API Platform Documentation .

here