API - Tax rules

Manage the tax rules


Routes

Method name Route Parameters OK return code Return
GET /api/tax-rules 200 Results of the 'tax-rule' loop
GET /api/tax-rules/{entityId} entityId: The tax rule id 200 Results of the 'tax-rule' loop for entityId
POST /api/tax-rules 201 Results of the 'tax-rule' loop for the created tax rule
PUT /api/tax-rules 201 Results of the 'tax-rule' loop for the updated tax rule
DELETE /api/tax-rules/{entityId} entityId: The tax rule id 204 Nothing

Creation

If you want to create a tax rule, you have to send the following fields with the POST method.

  • country : a collection of country id
  • tax : a collection of tax id
  • i18n : a collection of the following fields:
    • locale: The lang locale. Example: en_US
    • title: The tax rule title.
    • description: The tax rule description (optional).
  • default : if true, toggle the tax rule to be the default one (optional)

Example

{
    "default": 1,
    "tax": [1, 2, 3],
    "country": [64],
    "i18n": [
        {
            "locale": "en_US",
            "title": "French 20 VAT"
        },
        {
            "locale": "fr_FR",
            "title": "TVA à 20%",
            "description": "Taxe à appliquer sur tous les produits du magasin"
        }
    ]
}

Update

To update a tax rule, you have to send the same data (only updated ones) as for a create, but with the PUT method.

Moreover, you have to add the “id” field.

Example

{
    "id": 42,
    "i18n": [
        {
            "locale": "en_US",
            "description": "Apply this tax to all the store's products"
        }
    ]
}