Contract Terms API - NovaGL/coupa-resources GitHub Wiki

Since the bulk uploader does not provide a way to upload contract terms.

I had to find another way to do it. Luckily the API is easy to use.

The first thing to do is export all the contracts making sure you also export the contract id column; this is important as this tells us which url to POST to. With out that we wouldn’t know which contract we are updating.

Then we need to work out which type of pricing term we want for the contract. There are various options but to keep it simple I will focus on two main types of pricing.

Flexible Pricing Tiered Pricing
Unrestricted price entry or limit this to a price range This allows us to set discounts depending on the quantity.

Flexible Pricing

The call for this is simple it’s made up of the following:

Title Input
name Flexible Pricing
contract-term-type PriceRangeContractTerm
tier-1-upper-bound 0 (no restrictions)

If you would like to restrict the upper and lower limits add the following

Title Input
name Flexible Pricing
tier-1-disc-pct set the lower limit e.g 5.0
tier-2-disc-pct set the upper limit e.g 10.0

A full example of this would be:

{

"name": "Flexible Pricing",

"contract-term-type": "PriceRangeContractTerm",

"tier-1-upper-bound": 0,

"tier-1-disc-pct": 5.0,

"tier-2-disc-pct": 10.0
}

Tiered Pricing

This defines the qty breaks per discount. Make sure to enter the pricing information on the item level. It’s made up of the following

Title Input
name Quantity of specific item - per order
contract-term-type PerOrderContractTerm
tier-1-upper-bound set the limit for that price bracket, this means if you enter 1 that items 2 or greater will have the next tier. Increase the number as required

A full example would be


{

"name": "Quantity of specific item - per order",

"contract-term-type": "PerOrderContractTerm",

"tier-1-upper-bound": 4,

"tier-2-upper-bound": 9,

"tier-3-upper-bound": 19

}

Headers

Once you’ve worked out what you want to do we need to bring it all together.

Before we do that we need to choose the authentication method. I’m not going to go to involved in this but you have the following options

API Keys (depreciated)

X-COUPA-API-KEY: Enter your API Key

OAuth2

Make sure the scope contains core.contract.read core.contract.write when generating the token.

Authorization: Bearer Enter Token here

Since the example is JSON we need to make sure that the request is sent as JSON.

Add the following headers in

    Accept: application/json
    Content-Type: application/json

Final result

You’ve made it, now lets bring it all together. I recommend using something like Power Automate Desktop or Node-Red to loop through all the contracts you want to update

URL:

https://myenviroment.coupahost.com/api/contracts/contract_id/contract_terms

METHOD:

POST

HEADERS:

    X-COUPA-API-KEY: MY KEY
    Accept:application/json
    Content-Type:application/json

BODY:

{

"name": "Flexible Pricing",

"contract-term-type": "PriceRangeContractTerm",

"tier-1-upper-bound": 0,

"tier-1-disc-pct": 5.0,

"tier-2-disc-pct": 10.0

}