Manage Webshop Partner Discounts through the API

Prev Next

This guide helps external integration developers create, retrieve, update, and delete OrderCentral webshop partner discounts and their volume-discount tiers through the Salesforce REST API. It covers endpoints, JSON payloads, response values, and validation rules; authentication is outside its scope.

API conventions

Discount configuration is stored in Salesforce records:

Object API name Purpose
welisacommerce__Webshop_Partner_Discount__c Fixed-percentage, volume, loyalty, and voucher discounts.
welisacommerce__Webshop_Partner_Discount_Scale__c Quantity tiers belonging to a volume discount.

Use the standard Salesforce REST API, not the OrderCentral cart voucher endpoints. Applying a voucher to a cart does not create or update its discount configuration.

  • Base URL: https://{instanceUrl}/services/data/v61.0
  • All endpoints below are relative to that base URL.
  • Send JSON bodies with Content-Type: application/json.
  • Replace {discountId}, {scaleId}, {accountId}, {productId}, and {recordTypeId} with Salesforce record IDs. These placeholders also appear in example JSON.
  • Dates use YYYY-MM-DD; numbers and booleans are JSON values, not strings.
  • Percentage values use percentage points: 10 means 10%, not 0.10.
  • Successful create requests return an ID. Update and delete requests normally return no body.

Object and field namespaces

Examples use the managed-package namespace welisacommerce. Package custom objects and custom fields include the welisacommerce__ prefix consistently in URLs, JSON keys, response values, and SOQL. Confirm the deployed names with Salesforce Describe.

Standard objects and fields such as Account, Product2, RecordType, Id, Name, and RecordTypeId remain unprefixed. Record type developer names and picklist values also remain unchanged. Repository links at the end of this guide use the unprefixed source folder names.

Endpoint overview

Method Endpoint Success response
GET /sobjects/ 200: available objects and their API names.
GET /sobjects/welisacommerce__Webshop_Partner_Discount__c/describe 200: field definitions and record type information.
GET /query?q={urlEncodedSoql} 200: matching records and pagination information.
POST /sobjects/welisacommerce__Webshop_Partner_Discount__c/ 201: created discount ID.
GET /sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId}?fields={fieldList} 200: requested discount fields.
PATCH /sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId} 204: empty body.
DELETE /sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId} 204: empty body.
GET /sobjects/welisacommerce__Webshop_Partner_Discount_Scale__c/describe 200: tier field definitions.
POST /sobjects/welisacommerce__Webshop_Partner_Discount_Scale__c/ 201: created tier ID.
GET /sobjects/welisacommerce__Webshop_Partner_Discount_Scale__c/{scaleId} 200: tier fields.
PATCH /sobjects/welisacommerce__Webshop_Partner_Discount_Scale__c/{scaleId} 204: empty body.
DELETE /sobjects/welisacommerce__Webshop_Partner_Discount_Scale__c/{scaleId} 204: empty body.

1. Discover fields and record types

Discover the target org's metadata before sending records, so the integration uses the correct field names, writable fields, and record type IDs.

  1. If needed, call GET /sobjects/ to find the deployed object API names.
  2. Call GET /sobjects/welisacommerce__Webshop_Partner_Discount__c/describe.
  3. Inspect fields for name, type, createable, updateable, nillable, defaultedOnCreate, and picklistValues. Formula and auto-number fields are not writable.
  4. Resolve the appropriate record type ID using the query below. Check recordTypeInfos in Describe for availability to the integration user.
GET /query?q={urlEncodedSoql}

URL-encode this SOQL as the q parameter, using the deployed object name:

SELECT Id, DeveloperName, Name
FROM RecordType
WHERE SobjectType = 'welisacommerce__Webshop_Partner_Discount__c'
AND IsActive = true

The package defines these record type developer names:

Developer name Purpose Configuration
Fixed_Percentage Percentage discount for an account and/or product selection. Set welisacommerce__Discount__c.
Volume Quantity-based discount. Create child tier records with quantity boundaries and percentages.
Loyalty Loyalty balance or points configuration. Use welisacommerce__Remaining_Balance__c and, where applicable, welisacommerce__Sub_Type__c; redemption behavior depends on the configured loyalty integration.
Voucher Code-based discount applied to a cart. Set welisacommerce__Voucher_Code__c, welisacommerce__Scope__c, and the percentage or fixed-amount value.

Record type IDs differ between Salesforce orgs. Do not copy IDs between environments or send a developer name as RecordTypeId.

Discount fields

The names and values below reflect the package metadata. Additional org-specific fields, automation, and validation can apply.

Field JSON type Meaning / supported values
RecordTypeId string ID resolved for one of the record types above. Explicitly supply it when creating a discount.
welisacommerce__Account__c string or null Lookup to Account. Restricts the discount to that account; null means it is not account-specific, subject to the discount type's targeting rules.
welisacommerce__Product__c string or null Lookup to Product2, not a web-product record. Do not combine with product family, group, or line.
welisacommerce__Product_Family__c string or null Product-family picklist API value. Package values: Product Family 1, Product Family 2, Product Family 3.
welisacommerce__Product_Group__c string or null Product-group picklist API value. Package values: Product Group 1, Product Group 2, Product Group 3.
welisacommerce__Product_Line__c string or null Product-line picklist API value. Package values: Product Line 1, Product Line 2, Product Line 3.
welisacommerce__Discount__c number or null Discount percentage, with two decimal places. For example, 12.5 means 12.5%.
welisacommerce__Start_Date__c string Required date. First eligible day, inclusive.
welisacommerce__End_Date__c string Required date. First ineligible day, exclusive.
welisacommerce__Status__c string Needs Approval, In Approval Process, Approved, Rejected, or Expired. Default: Needs Approval. Only Approved discounts are eligible for application.
welisacommerce__Voucher_Code__c string or null Voucher code, up to 255 characters. Case-insensitive external ID; not unique.
welisacommerce__Scope__c string or null Voucher scope: Cart or Line. Default: Cart.
welisacommerce__Discount_Type__c string or null Voucher value type: Percentage or Fixed_Amount. Default: Percentage.
welisacommerce__Discount_Amount__c number or null Currency amount with two decimal places. Required and greater than zero for a fixed-amount voucher.
welisacommerce__Remaining_Balance__c number or null Balance or points value with two decimal places, used by relevant loyalty/custom integrations. Not the fixed-amount voucher value.
welisacommerce__Sub_Type__c string or null Loyalty subtype. Package values: Anniversary Reward and atlas-points. Use the API value, not its display label.

Read-only fields include Id, the auto-number Name (for example, PD-000123), and the formula welisacommerce__Account_Owner__c. Use Describe to confirm other fields' writability and current picklist values.

Validation and activation

  • Both dates are required on creation. A start date after the end date is rejected.
  • Eligibility uses welisacommerce__Start_Date__c <= today and welisacommerce__End_Date__c > today. For a discount valid through 31 December 2026, send "welisacommerce__End_Date__c": "2027-01-01".
  • Equal start and end dates pass the date validation rule but provide no eligible day.
  • welisacommerce__Product__c cannot be combined with any product family, group, or line value.
  • A Voucher with welisacommerce__Scope__c = "Line" must have welisacommerce__Product__c and must not have product family, group, or line values.
  • A Voucher with welisacommerce__Scope__c = "Cart" must not have any product targeting fields.
  • A Voucher with welisacommerce__Discount_Type__c = "Fixed_Amount" must have a positive welisacommerce__Discount_Amount__c.
  • Use percentages between 0 and 100. Voucher calculation clamps percentages to that range; do not rely on clamping as input validation.
  • Approved is a stored status value, not an API command to submit an approval process. Follow the target org's approval requirements before setting it directly.
  • A successful write confirms persistence, not that the discount has been applied to an existing cart. Activation still depends on dates, status, targeting, and pricing configuration.

2. Create a discount

Create the record for the desired discount type, retain its returned ID, and retrieve it if you need the generated name or saved field values.

Fixed-percentage discount

This example gives one account a 10% discount for one product.

POST /sobjects/welisacommerce__Webshop_Partner_Discount__c/
{
  "RecordTypeId": "{fixedPercentageRecordTypeId}",
  "welisacommerce__Account__c": "{accountId}",
  "welisacommerce__Product__c": "{productId}",
  "welisacommerce__Discount__c": 10,
  "welisacommerce__Start_Date__c": "2026-01-01",
  "welisacommerce__End_Date__c": "2027-01-01",
  "welisacommerce__Status__c": "Approved"
}

Response: 201 Created

{
  "id": "{discountId}",
  "success": true,
  "errors": []
}
Response field Meaning
id New Salesforce record ID. Store it for later reads, updates, or deletes.
success Whether creation succeeded.
errors Empty array on successful creation. Failed requests normally return a non-2xx error response instead.

The same create-response structure applies to the other discount types and to tier records.

Cart-wide percentage voucher

POST /sobjects/welisacommerce__Webshop_Partner_Discount__c/
{
  "RecordTypeId": "{voucherRecordTypeId}",
  "welisacommerce__Voucher_Code__c": "WELCOME10",
  "welisacommerce__Scope__c": "Cart",
  "welisacommerce__Discount_Type__c": "Percentage",
  "welisacommerce__Discount__c": 10,
  "welisacommerce__Start_Date__c": "2026-01-01",
  "welisacommerce__End_Date__c": "2027-01-01",
  "welisacommerce__Status__c": "Approved"
}

Omitting welisacommerce__Account__c makes this voucher non-account-specific. Add an account ID to restrict it. Do not add product targeting to a cart-wide voucher.

Product-specific fixed-amount voucher

POST /sobjects/welisacommerce__Webshop_Partner_Discount__c/
{
  "RecordTypeId": "{voucherRecordTypeId}",
  "welisacommerce__Account__c": "{accountId}",
  "welisacommerce__Voucher_Code__c": "PRODUCT25",
  "welisacommerce__Scope__c": "Line",
  "welisacommerce__Product__c": "{productId}",
  "welisacommerce__Discount_Type__c": "Fixed_Amount",
  "welisacommerce__Discount_Amount__c": 25,
  "welisacommerce__Start_Date__c": "2026-01-01",
  "welisacommerce__End_Date__c": "2027-01-01",
  "welisacommerce__Status__c": "Approved"
}

For line scope, the amount is deducted from each matching product line, not once per unit. For cart scope, the amount is distributed proportionally across product lines. Fixed-amount voucher calculation does not take a line below zero.

Loyalty record

POST /sobjects/welisacommerce__Webshop_Partner_Discount__c/
{
  "RecordTypeId": "{loyaltyRecordTypeId}",
  "welisacommerce__Account__c": "{accountId}",
  "welisacommerce__Sub_Type__c": "atlas-points",
  "welisacommerce__Remaining_Balance__c": 100,
  "welisacommerce__Start_Date__c": "2026-01-01",
  "welisacommerce__End_Date__c": "2027-01-01",
  "welisacommerce__Status__c": "Approved"
}

This stores a loyalty balance; it does not itself execute a redemption or guarantee a particular monetary conversion.

3. Retrieve and find discounts

Retrieve by ID for synchronization, or query by account, record type, or voucher code to find relevant records.

Retrieve one discount

GET /sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId}?fields=Id,Name,RecordTypeId,welisacommerce__Account__c,welisacommerce__Product__c,welisacommerce__Discount__c,welisacommerce__Start_Date__c,welisacommerce__End_Date__c,welisacommerce__Status__c

Response: 200 OK

{
  "attributes": {
    "type": "welisacommerce__Webshop_Partner_Discount__c",
    "url": "/services/data/v61.0/sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId}"
  },
  "Id": "{discountId}",
  "Name": "PD-000123",
  "RecordTypeId": "{fixedPercentageRecordTypeId}",
  "welisacommerce__Account__c": "{accountId}",
  "welisacommerce__Product__c": "{productId}",
  "welisacommerce__Discount__c": 10.0,
  "welisacommerce__Start_Date__c": "2026-01-01",
  "welisacommerce__End_Date__c": "2027-01-01",
  "welisacommerce__Status__c": "Approved"
}

attributes identifies the record's Salesforce type and resource URL. Field names in read responses use their exact API capitalization; the create response uses lowercase id.

List discounts for an account

GET /query?q={urlEncodedSoql}
SELECT Id, Name, RecordType.DeveloperName, welisacommerce__Account__c,
       welisacommerce__Product__c, welisacommerce__Discount__c, welisacommerce__Status__c, welisacommerce__Start_Date__c, welisacommerce__End_Date__c
FROM welisacommerce__Webshop_Partner_Discount__c
WHERE welisacommerce__Account__c = '{accountId}'
ORDER BY Id

Response: 200 OK. This example projects only three fields for brevity; an actual response includes every selected field.

{
  "totalSize": 1,
  "done": true,
  "records": [
    {
      "attributes": {
        "type": "welisacommerce__Webshop_Partner_Discount__c",
        "url": "/services/data/v61.0/sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId}"
      },
      "Id": "{discountId}",
      "Name": "PD-000123",
      "welisacommerce__Discount__c": 10.0
    }
  ]
}
Response field Meaning
totalSize Total matching record count.
done Whether all results have been returned.
records Current page of records. Empty if nothing matches; an empty query is not a 404.
nextRecordsUrl Present when more results are available. GET this URL relative to the instance origin, without adding the base path again, until done is true.

This query lists account-specific records only, not global discounts that might also apply to the account.

Find a voucher by code

Use the query endpoint with:

SELECT Id, welisacommerce__Account__c, welisacommerce__Voucher_Code__c, welisacommerce__Status__c,
       welisacommerce__Start_Date__c, welisacommerce__End_Date__c, welisacommerce__Scope__c, welisacommerce__Discount_Type__c,
       welisacommerce__Discount__c, welisacommerce__Discount_Amount__c
FROM welisacommerce__Webshop_Partner_Discount__c
WHERE RecordType.DeveloperName = 'Voucher'
AND welisacommerce__Voucher_Code__c = 'WELCOME10'
AND (welisacommerce__Account__c = '{accountId}' OR welisacommerce__Account__c = null)

Codes are case-insensitive and not unique. More than one result can be returned, including account-specific and global vouchers. Do not update the first result blindly: identify the intended record and update by Salesforce ID.

Validate IDs and escape SOQL string literals before constructing queries; URL encoding alone does not escape SOQL.

4. Update or deactivate a discount

Use PATCH to change only the supplied fields; omitted fields retain their current values.

PATCH /sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId}
{
  "welisacommerce__Discount__c": 12.5,
  "welisacommerce__End_Date__c": "2027-04-01"
}

Response: 204 No Content, with an empty body. Use GET afterward if you need the resulting record.

To clear an optional field, send null. For example, switching a fixed-percentage discount from one product to a product family:

{
  "welisacommerce__Product__c": null,
  "welisacommerce__Product_Family__c": "Product Family 1"
}

Clear conflicting targeting fields in the same request; validation evaluates the complete resulting record.

To deactivate a discount without deleting its record:

{
  "welisacommerce__Status__c": "Expired"
}

This prevents eligibility on subsequent evaluations; it does not by itself reverse completed orders.

Updates by voucher code / upsert

Salesforce supports external-ID upsert:

PATCH /sobjects/welisacommerce__Webshop_Partner_Discount__c/welisacommerce__Voucher_Code__c/{urlEncodedVoucherCode}

However, welisacommerce__Voucher_Code__c is not a unique key:

  • No match: Salesforce attempts to create a record. Supply all creation fields, including record type and dates. Success returns 201 Created with the create-response structure shown above.
  • One match: Salesforce updates that record. Success returns 204 No Content with an empty body.
  • Multiple matches: Salesforce returns 300 Multiple Choices instead of updating a record.

Matching is not scoped to an account or record type. Prefer create followed by updates using the returned Salesforce ID. Do not assume voucher-code upsert is safe or idempotent when duplicates are possible.

5. Manage volume-discount tiers

Create a volume discount first, then attach quantity tiers to its returned ID.

  1. POST the parent discount:

    POST /sobjects/welisacommerce__Webshop_Partner_Discount__c/
    
    {
      "RecordTypeId": "{volumeRecordTypeId}",
      "welisacommerce__Account__c": "{accountId}",
      "welisacommerce__Product__c": "{productId}",
      "welisacommerce__Start_Date__c": "2026-01-01",
      "welisacommerce__End_Date__c": "2027-01-01",
      "welisacommerce__Status__c": "Needs Approval"
    }
    
  2. For each tier, POST a child record:

    POST /sobjects/welisacommerce__Webshop_Partner_Discount_Scale__c/
    
    {
      "welisacommerce__Webshop_Partner_Discount__c": "{discountId}",
      "welisacommerce__Quantity_From__c": 10,
      "welisacommerce__Quantity_To__c": 20,
      "welisacommerce__Percentage__c": 5
    }
    

    Response: 201 Created, with id, success, and errors. Retain each tier's ID.

  3. Retrieve and check the tiers before activating the parent:

    SELECT Id, welisacommerce__Webshop_Partner_Discount__c,
           welisacommerce__Quantity_From__c, welisacommerce__Quantity_To__c, welisacommerce__Percentage__c
    FROM welisacommerce__Webshop_Partner_Discount_Scale__c
    WHERE welisacommerce__Webshop_Partner_Discount__c = '{discountId}'
    ORDER BY welisacommerce__Quantity_From__c
    
  4. When configuration is complete and approval requirements are satisfied, PATCH the parent's welisacommerce__Status__c to Approved.

Tier field JSON type Meaning
welisacommerce__Webshop_Partner_Discount__c string Required parent discount ID. Master-detail relationship; cannot be reparented.
welisacommerce__Quantity_From__c integer or null Inclusive lower quantity boundary. Null means no lower boundary.
welisacommerce__Quantity_To__c integer or null Exclusive upper quantity boundary. Null means no upper boundary.
welisacommerce__Percentage__c number or null Percentage with two decimal places. A matching tier with no percentage yields 0%.

The example tier applies from quantity 10 up to, but not including, 20. A following tier can start at 20 with welisacommerce__Quantity_To__c: null. Avoid overlapping ranges: calculation uses the first matching tier, and integrations should not depend on unspecified retrieval order. No matching tier yields 0%.

Update a tier using PATCH /sobjects/welisacommerce__Webshop_Partner_Discount_Scale__c/{scaleId} with only changed fields. Delete it using DELETE on the same endpoint. Both return 204 No Content on success.

These are separate requests, not one transaction. If a tier request fails, inspect the error and correct or retry that request; the parent and earlier successful tiers remain saved. Keeping the parent unapproved while configuring tiers avoids activating a partially configured discount.

6. Delete a discount

Delete only when the configuration record should be removed; use a status change when it should remain available for reference.

DELETE /sobjects/welisacommerce__Webshop_Partner_Discount__c/{discountId}

No request body.

Response: 204 No Content, with an empty body.

Child tier records are deleted with their master discount. Salesforce relationship restrictions or target-org automation can block deletion. Do not assume deleting a discount reverses existing cart or order calculations.

Error responses

Standard Salesforce REST errors normally return a non-2xx HTTP status and a JSON array, not the OrderCentral cart API error format.

Example: a fixed-amount voucher is missing its amount.

HTTP/1.1 400 Bad Request
[
  {
    "message": "Line-scope vouchers need a Product and no Product Family, Group or Line; Cart-scope vouchers must not target a product. Fixed Amount vouchers need a Discount Amount greater than zero.",
    "errorCode": "FIELD_CUSTOM_VALIDATION_EXCEPTION",
    "fields": []
  }
]
HTTP status Typical errorCode Meaning / action
400 REQUIRED_FIELD_MISSING Supply required fields, including both dates and the parent lookup for tiers.
400 FIELD_CUSTOM_VALIDATION_EXCEPTION Correct date, targeting, voucher amount, or org-specific validation errors.
400 INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST Use an allowed picklist API value.
400 MALFORMED_ID / INVALID_CROSS_REFERENCE_KEY Check record ID format, referenced record existence, and record type.
400 INVALID_FIELD / INVALID_FIELD_FOR_INSERT_UPDATE Check API names, namespace prefixes, and field writability.
400 MALFORMED_QUERY Correct SOQL and escape literals before URL encoding.
403 INSUFFICIENT_ACCESS or a related access error Check object/field/record access.
404 NOT_FOUND Check the endpoint, object name, record ID, and record visibility.

Inspect the actual HTTP status and errorCode rather than matching message text. Messages and field lists can vary with the org's configuration.

Implementation references