Composable Frontend 2.0 Learn more 

  • Commerce Cloud/
    Carts/
    Tax Items/
    Create a Tax Item

    Create a Tax Item

    Please note there is a soft limit of 5 unique tax items per cart item at any one time.

    POST Create a Tax Item

    https://useast.api.elasticpath.com/v2/carts/:cartID/items/:itemId/taxes
    

    Parameters

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Body

    NameRequiredTypeDescription
    typeRequiredstringThis represents the type of object being returned.
    nameOptionalstringThe name of the tax item.
    jurisdictionOptionalstringThe relevant tax jurisdiction.
    codeOptionalstringA unique tax code in this jurisdiction.
    rateRequiredfloatThe tax rate represented as a decimal (12.5% -> 0.125).

    Request Examples

    Curl

    curl -X POST https://useast.api.elasticpath.com/v2/carts/:cartID/items/:itemId/taxes \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer XXXX" \
        -d $ {
            "data": {
                "type": "tax_item",
                "name": "Tax Name",
                "jurisdiction" : "UK",
                "code": "MYTAX01",
                "rate": 0.2
            }
        }
    

    JavaScript SDK

    const itemId = "25617d3e-14a6-434c-bfab-3fda87517aaf";
    const taxData = {
        type: "tax_item",
        name: "Tax Name",
        jurisdiction: "UK",
        code: "MYTAX01",
        rate: 0.2,
    };
    
    
    // Where `EPCC` is an authenticated client
    await EPCC.Cart.AddItemTax(itemId, taxData);
    

    Response Example

    201 Created

    {
        "data": {
            "id": "003e2458-3415-4fd2-a10c-ed422bfac4bb",
            "type": "tax_item",
            "name": "Tax Name",
            "jurisdiction": "UK",
            "code": "MYTAX01",
            "rate": 0.2
        }
    }
    

    422 Unprocessable Entity

    In this example, we skip passing name to fail validation.

    {
        "errors": [
            {
                "title": "Failed Validation",
                "detail": "The data.name field is required."
            }
        ]
    }
    
    Previous
    Tax Items