Prices

SKUs can have a price for each price list. When you create a line item, it gets the price associated with the order's the price list.

The price object

A price object is returned as part of the response body of each successful create, list, retrieve or update API call. The following table contains the list of all its fields along with their type, description and example values.
Object fields:
currency_code
string
The international 3-letter currency code as defined by the ISO 4217 standard, inherited from the associated price list.
Example:
EUR
sku_code
string
The code of the associated sku. When creating a price, either a valid sku_code or a sku relationship must be present.
Example:
TSHIRTMM000000FFFFFFXLXX
amount_cents
integer
The sku price amount for the associated price list, in cents.
Example:
10000
amount_float
float
The sku price amount for the associated price list, float.
Example:
100.0
formatted_amount
string
The sku price amount for the associated price list, formatted.
Example:
€100,00
compare_at_amount_cents
integer
The compared price amount, in cents. Useful to display a percentage discount.
Example:
13000
compare_at_amount_float
float
The compared price amount, float.
Example:
130.00
formatted_compare_at_amount
string
The compared price amount, formatted.
Example:
€130,00
id
integer
Unique identifier for the resource.
Example:
1234
created_at
datetime
Time at which the resource was created.
Example:
2018-01-01T12:00:00.000Z
updated_at
datetime
Time at which the resource was last updated.
Example:
2018-01-01T12:00:00.000Z
reference
string
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
object
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
{"foo":"bar"}
relationship (N:1)
The associated price list.
sku
relationship (N:1)
The associated sku. When creating a price, either a sku relationship or a valid sku_code must be present.

Create a price

To create a new price, send a POST request to the /api/prices endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.
Arguments:
sku_code
optional
The code of the associated sku. When creating a price, either a valid sku_code or a sku relationship must be present.
Example:
TSHIRTMM000000FFFFFFXLXX
amount_cents
required
The sku price amount for the associated price list, in cents.
Example:
10000
compare_at_amount_cents
required
The compared price amount, in cents. Useful to display a percentage discount.
Example:
13000
reference
optional
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
optional
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
#
required
The associated price list.
sku
optional
The associated sku. When creating a price, either a sku relationship or a valid sku_code must be present.
Example request:
POST /api/prices HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "prices",
    "attributes": {
      "amount_cents": "10000",
      "compare_at_amount_cents": "13000"
    },
    "relationships": {
      "price_list": {
        "data": {
          "type": "price_lists",
          "id": "1234"
        }
      }
    }
  }
}
Example response: 201 Created
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "prices",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/prices/1234"
    },
    "attributes": {
      "currency_code": "EUR",
      "sku_code": "TSHIRTMM000000FFFFFFXLXX",
      "amount_cents": "10000",
      "amount_float": "100.0",
      "formatted_amount": "€100,00",
      "compare_at_amount_cents": "13000",
      "compare_at_amount_float": "130.00",
      "formatted_compare_at_amount": "€130,00",
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "price_list": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/price_list",
          "related": "https://your-brand.commercelayer.io/api/prices/1234/price_list"
        }
      },
      "sku": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/sku",
          "related": "https://your-brand.commercelayer.io/api/prices/1234/sku"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

List all prices

To fetch a collection of prices, send a GET request to the /api/prices endpoint.

Example request:
GET /api/prices HTTP/1.1
Accept: application/vnd.api+json
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": [
    {
      "id": "1234",
      "type": "prices",
      "links": {
        "self": "https://your-brand.commercelayer.io/api/prices/1234"
      },
      "attributes": {
        "currency_code": "EUR",
        "sku_code": "TSHIRTMM000000FFFFFFXLXX",
        "amount_cents": "10000",
        "amount_float": "100.0",
        "formatted_amount": "€100,00",
        "compare_at_amount_cents": "13000",
        "compare_at_amount_float": "130.00",
        "formatted_compare_at_amount": "€130,00",
        "id": "1234",
        "created_at": "2018-01-01T12:00:00.000Z",
        "updated_at": "2018-01-01T12:00:00.000Z",
        "reference": "ANYREFEFERNCE",
        "metadata": {
          "foo": "bar"
        }
      },
      "relationships": {
        "price_list": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/price_list",
            "related": "https://your-brand.commercelayer.io/api/prices/1234/price_list"
          }
        },
        "sku": {
          "links": {
            "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/sku",
            "related": "https://your-brand.commercelayer.io/api/prices/1234/sku"
          }
        }
      },
      "meta": {
        "mode": "test"
      }
    },
    {
      "other": "... 24 prices (first page)"
    }
  ],
  "meta": {
    "record_count": 125,
    "page_count": 5
  },
  "links": {
    "first": "/api/prices?page[number]=1&page[size]=25",
    "prev": "/api/prices?page[number]=2&page[size]=25",
    "next": "/api/prices?page[number]=4&page[size]=25",
    "last": "/api/prices?page[number]=5&page[size]=25"
  }
}
Available filters
idamount_centscompare_at_amount_centsreferenceprice_list_idsku_ididscreated_at_fromcreated_at_toupdated_at_fromupdated_at_tosku_codessku_ids
Sortable attributes
amount_centscompare_at_amount_centsidcreated_atupdated_atreference

Retrieve a price

To fetch a single price, send a GET request to the /api/prices/{{id}} endpoint, where {{id}} is the id of the resource that you want to retrieve.
Example request:
GET /api/prices/1234 HTTP/1.1
Accept: application/vnd.api+json
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "prices",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/prices/1234"
    },
    "attributes": {
      "currency_code": "EUR",
      "sku_code": "TSHIRTMM000000FFFFFFXLXX",
      "amount_cents": "10000",
      "amount_float": "100.0",
      "formatted_amount": "€100,00",
      "compare_at_amount_cents": "13000",
      "compare_at_amount_float": "130.00",
      "formatted_compare_at_amount": "€130,00",
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "price_list": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/price_list",
          "related": "https://your-brand.commercelayer.io/api/prices/1234/price_list"
        }
      },
      "sku": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/sku",
          "related": "https://your-brand.commercelayer.io/api/prices/1234/sku"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

Update a price

To update an existing price, send a PATCH request to the /api/prices/{{id}} endpoint, where {{id}} is the id of the resource that you want to update. The following table contains the list of all the possible arguments that you can pass with the request body, along with their type, description and examples values. Please note that all arguments are optional.
Arguments:
sku_code
optional
The code of the associated sku. When creating a price, either a valid sku_code or a sku relationship must be present.
Example:
TSHIRTMM000000FFFFFFXLXX
amount_cents
optional
The sku price amount for the associated price list, in cents.
Example:
10000
compare_at_amount_cents
optional
The compared price amount, in cents. Useful to display a percentage discount.
Example:
13000
reference
optional
A string that you can use to add your own identifier to the resource. This can be useful for intergrating the resource to an external system, like an ERP, a marketing tool or a CRM.
Example:
ANYREFEFERNCE
metadata
optional
Set of key-value pairs that you can attach to the resource. This can be useful for storing additional information about the resource in a structured format.
Example:
#
optional
The associated price list.
sku
optional
The associated sku. When creating a price, either a sku relationship or a valid sku_code must be present.
Example request:
PATCH /api/prices/1234 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "prices",
    "id": 1234,
    "attributes": {
      "sku_code": "TSHIRTMM000000FFFFFFXLXX"
    },
    "relationships": {
    }
  }
}
Example response: 200 OK
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json

{
  "data": {
    "id": "1234",
    "type": "prices",
    "links": {
      "self": "https://your-brand.commercelayer.io/api/prices/1234"
    },
    "attributes": {
      "currency_code": "EUR",
      "sku_code": "TSHIRTMM000000FFFFFFXLXX",
      "amount_cents": "10000",
      "amount_float": "100.0",
      "formatted_amount": "€100,00",
      "compare_at_amount_cents": "13000",
      "compare_at_amount_float": "130.00",
      "formatted_compare_at_amount": "€130,00",
      "id": "1234",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANYREFEFERNCE",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "price_list": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/price_list",
          "related": "https://your-brand.commercelayer.io/api/prices/1234/price_list"
        }
      },
      "sku": {
        "links": {
          "self": "https://your-brand.commercelayer.io/api/prices/1234/relationships/sku",
          "related": "https://your-brand.commercelayer.io/api/prices/1234/sku"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}

Delete a price

To delete a price, send a DELETE request to the /api/prices/{{id}} endpoint, where {{id}} is the id of the resource that you want to delete.
Example request:
DELETE /api/prices/1234 HTTP/1.1
Accept: application/vnd.api+json
Example response: 204 No Content
HTTP/1.1 204 No Content

Get our machine-readable JSON schema that follows the OpenAPI Specification (formerly Swagger).

Get our Postman collection in one click and start making real calls to Commerce Layer API in minutes.

Get in touch with our support team if you have any questions or want to learn more about Commerce Layer.