Create CounterPricing - m3ter Documentation

Create CounterPricing

cURL

curl --request POST \
  --url https://api.m3ter.com/organizations/{orgId}/counterpricings \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "startDate": "2023-11-07T05:31:56Z",
  "pricingBands": [
    {
      "lowerLimit": 1,
      "fixedPrice": 123,
      "unitPrice": 123,
      "id": "<string>",
      "creditTypeId": "<string>"
    }
  ],
  "counterId": "<string>",
  "version": 123,
  "code": "<string>",
  "planId": "<string>",
  "planTemplateId": "<string>",
  "cumulative": true,
  "endDate": "2023-11-07T05:31:56Z",
  "description": "<string>",
  "accountingProductId": "<string>",
  "runningTotalBillInAdvance": true,
  "proRateRunningTotal": true,
  "proRateAdjustmentDebit": true,
  "proRateAdjustmentCredit": true
}
'

Python

import requests

url = "https://api.m3ter.com/organizations/{orgId}/counterpricings"

payload = {
    "startDate": "2023-11-07T05:31:56Z",
    "pricingBands": [
        {
            "lowerLimit": 1,
            "fixedPrice": 123,
            "unitPrice": 123,
            "id": "<string>",
            "creditTypeId": "<string>"
        }
    ],
    "counterId": "<string>",
    "version": 123,
    "code": "<string>",
    "planId": "<string>",
    "planTemplateId": "<string>",
    "cumulative": True,
    "endDate": "2023-11-07T05:31:56Z",
    "description": "<string>",
    "accountingProductId": "<string>",
    "runningTotalBillInAdvance": True,
    "proRateRunningTotal": True,
    "proRateAdjustmentDebit": True,
    "proRateAdjustmentCredit": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

JavaScript

const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    startDate: '2023-11-07T05:31:56Z',
    pricingBands: [
      {
        lowerLimit: 1,
        fixedPrice: 123,
        unitPrice: 123,
        id: '<string>',
        creditTypeId: '<string>'
      }
    ],
    counterId: '<string>',
    version: 123,
    code: '<string>',
    planId: '<string>',
    planTemplateId: '<string>',
    cumulative: true,
    endDate: '2023-11-07T05:31:56Z',
    description: '<string>',
    accountingProductId: '<string>',
    runningTotalBillInAdvance: true,
    proRateRunningTotal: true,
    proRateAdjustmentDebit: true,
    proRateAdjustmentCredit: true
  })
};

fetch('https://api.m3ter.com/organizations/{orgId}/counterpricings', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.m3ter.com/organizations/{orgId}/counterpricings",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'startDate' => '2023-11-07T05:31:56Z',
    'pricingBands' => [
        [
                'lowerLimit' => 1,
                'fixedPrice' => 123,
                'unitPrice' => 123,
                'id' => '<string>',
                'creditTypeId' => '<string>'
        ]
    ],
    'counterId' => '<string>',
    'version' => 123,
    'code' => '<string>',
    'planId' => '<string>',
    'planTemplateId' => '<string>',
    'cumulative' => true,
    'endDate' => '2023-11-07T05:31:56Z',
    'description' => '<string>',
    'accountingProductId' => '<string>',
    'runningTotalBillInAdvance' => true,
    'proRateRunningTotal' => true,
    'proRateAdjustmentDebit' => true,
    'proRateAdjustmentCredit' => true
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

Response Example

{
  "id": "<string>",
  "version": 123,
  "dtCreated": "2023-11-07T05:31:56Z",
  "dtLastModified": "2023-11-07T05:31:56Z",
  "createdBy": "<string>",
  "lastModifiedBy": "<string>",
  "planId": "<string>",
  "planTemplateId": "<string>",
  "cumulative": true,
  "startDate": "2023-11-07T05:31:56Z",
  "endDate": "2023-11-07T05:31:56Z",
  "code": "<string>",
  "description": "<string>",
  "accountingProductId": "<string>",
  "pricingBands": [
    {
      "lowerLimit": 1,
      "fixedPrice": 123,
      "unitPrice": 123,
      "id": "<string>",
      "creditTypeId": "<string>"
    }
  ],
  "counterId": "<string>",
  "runningTotalBillInAdvance": true,
  "proRateRunningTotal": true,
  "proRateAdjustmentDebit": true,
  "proRateAdjustmentCredit": true
}

Error Response

{
  "message": "<string>"
}

Authorizations