Skip to main content

Create price book entries

Price book entries contain the custom pricing details that apply when the price book conditions are met. In this example, the entry applies to any companies specified in Create price book conditions.

To use the createPriceBookEntry mutation, you need two unique identifiers:

  • The priceBookId, which is the id value returned when you created the price book (see Create price books).

  • The pricingPlanId, also known as the edition UUID. To retrieve it:

    1. Use the REST API to retrieve the ID of the product whose price you want to customize. For example, use List all products and note the value of the id for the desired product.

    2. Use the product ID to retrieve the product details with the Retrieve a product request. Note the uuid value in the editions array. Enter this value as the pricingPlanId.

In the following example, the product price is reduced by 50 percent.

Mutation

mutation createPriceBookEntry($createPriceBookEntryInput: CreatePriceBookEntryInput!) {
createPriceBookEntry(input: $createPriceBookEntryInput) {
priceBookEntry {
id
priceBookId
pricingPlanId
setupFee {
percentage
prices {
currency
price
}
}
contractFee {
percentage
prices {
currency
price
}
}
units {
unit
priceRanges {
minUnits
maxUnits
percentage
prices {
currency
price
}
}
}
}
userErrors {
... on UserError {
__typename
message
}
}
}
}

Variables

{
"createPriceBookEntryInput": {
"priceBookId": "6beab4df-d944-4e52-8694-8bcf5b514015",
"pricingPlanId": "b4b981e8-2c39-48d8-bc7a-82f5e2b677ab",
"createdBy": "john.smith@example.com",
"units": [
{
"unit": "USER",
"priceRanges": [
{
"minUnits": 1,
"maxUnits": null,
"percentage": true,
"prices": [
{
"currency": "USD",
"price": -50
}
]
}
]
}
]
}
}

Response

{
"data": {
"createPriceBookEntry": {
"priceBookEntry": {
"id": "5a31e443-4b70-45ab-9c97-fb6781d92d81",
"priceBookId": "6beab4df-d944-4e52-8694-8bcf5b514015",
"pricingPlanId": "b4b981e8-2c39-48d8-bc7a-82f5e2b677ab",
"setupFee": null,
"contractFee": null,
"units": [
{
"unit": "USER",
"priceRanges": [
{
"minUnits": 1,
"maxUnits": null,
"percentage": true,
"prices": [
{
"currency": "USD",
"price": 0.500000000000
}
]
}
]
}
]
},
"userErrors": null
}
}
}

Was this page helpful?