Create Pricing - m3ter Documentation

Create Pricing

cURL

curl --request POST \
  --url https://api.m3ter.com/organizations/{orgId}/pricings \
  --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>"
    }
  ],
  "version": 123,
  "code": "<string>",
  "planId": "<string>",
  "planTemplateId": "<string>",
  "cumulative": true,
  "endDate": "2023-11-07T05:31:56Z",
  "description": "<string>",
  "accountingProductId": "<string>",
  "aggregationId": "<string>",
  "compoundAggregationId": "<string>",
  "segment": {},
  "tiersSpanPlan": true,
  "minimumSpend": 1,
  "minimumSpendDescription": "<string>",
  "minimumSpendBillInAdvance": true,
  "overagePricingBands": [
    {
      "lowerLimit": 1,
      "fixedPrice": 123,
      "unitPrice": 123,
      "id": "<string>",
      "creditTypeId": "<string>"
    }
  ]
}
'

Python Example

import requests

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

payload = {
    "startDate": "2023-11-07T05:31:56Z",
    "pricingBands": [
        {
            "lowerLimit": 1,
            "fixedPrice": 123,
            "unitPrice": 123,
            "id": "<string>",
            "creditTypeId": "<string>"
        }
    ],
    "version": 123,
    "code": "<string>",
    "planId": "<string>",
    "planTemplateId": "<string>",
    "cumulative": True,
    "endDate": "2023-11-07T05:31:56Z",
    "description": "<string>",
    "accountingProductId": "<string>",
    "aggregationId": "<string>",
    "compoundAggregationId": "<string>",
    "segment": {},
    "tiersSpanPlan": True,
    "minimumSpend": 1,
    "minimumSpendDescription": "<string>",
    "minimumSpendBillInAdvance": True,
    "overagePricingBands": [
        {
            "lowerLimit": 1,
            "fixedPrice": 123,
            "unitPrice": 123,
            "id": "<string>",
            "creditTypeId": "<string>"
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)

JavaScript Example

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>'
      }
    ],
    version: 123,
    code: '<string>',
    planId: '<string>',
    planTemplateId: '<string>',
    cumulative: true,
    endDate: '2023-11-07T05:31:56Z',
    description: '<string>',
    accountingProductId: '<string>',
    aggregationId: '<string>',
    compoundAggregationId: '<string>',
    segment: {},
    tiersSpanPlan: true,
    minimumSpend: 1,
    minimumSpendDescription: '<string>',
    minimumSpendBillInAdvance: true,
    overagePricingBands: [
      {
        lowerLimit: 1,
        fixedPrice: 123,
        unitPrice: 123,
        id: '<string>',
        creditTypeId: '<string>'
      }
    ]
  })
};

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

PHP Example

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.m3ter.com/organizations/{orgId}/pricings",
  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>'
        ]
    ],
    'version' => 123,
    'code' => '<string>',
    'planId' => '<string>',
    'planTemplateId' => '<string>',
    'cumulative' => true,
    'endDate' => '2023-11-07T05:31:56Z',
    'description' => '<string>',
    'accountingProductId' => '<string>',
    'aggregationId' => '<string>',
    'compoundAggregationId' => '<string>',
    'segment' => [],
    'tiersSpanPlan' => true,
    'minimumSpend' => 1,
    'minimumSpendDescription' => '<string>',
    'minimumSpendBillInAdvance' => true,
    'overagePricingBands' => [
        [
            'lowerLimit' => 1,
            'fixedPrice' => 123,
            'unitPrice' => 123,
            'id' => '<string>',
            'creditTypeId' => '<string>'
        ]
    ]
  ]),
  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;
}

Go Example

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

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

payload := strings.NewReader("{\n  \"startDate\": \"2023-11-07T05:31:56Z\",\n  \"pricingBands\": [\n    {\n      \"lowerLimit\": 1,\n      \"fixedPrice\": 123,\n      \"unitPrice\": 123,\n      \"id\": \"<string>\",\n      \"creditTypeId\": \"<string>\"\n    }\n  ],\n  \"version\": 123,\n  \"code\": \"<string>\",\n  \"planId\": \"<string>\",\n  \"planTemplateId\": \"<string>\",\n  \"cumulative\": true,\n  \"endDate\": \"2023-11-07T05:31:56Z\",\n  \"description\": \"<string>\",\n  \"accountingProductId\": \"<string>\",\n  \"aggregationId\": \"<string>\",\n  \"compoundAggregationId\": \"<string>\",\n  \"segment\": {},\n  \"tiersSpanPlan\": true,\n  \"minimumSpend\": 1,\n  \"minimumSpendDescription\": \"<string>\",\n  \"minimumSpendBillInAdvance\": true,\n  \"overagePricingBands\": [\n    {\n      \"lowerLimit\": 1,\n      \"fixedPrice\": 123,\n      \"unitPrice\": 123,\n      \"id\": \"<string>\",\n      \"creditTypeId\": \"<string>\"\n    }\n  ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
    req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Response

{
  "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>"
    }
  ],
  "aggregationId": "<string>",
  "compoundAggregationId": "<string>",
  "segment": {},
  "tiersSpanPlan": true,
  "minimumSpend": 123,
  "minimumSpendDescription": "<string>",
  "minimumSpendBillInAdvance": true,
  "segmentString": "<string>",
  "overagePricingBands": [
    {
      "lowerLimit": 1,
      "fixedPrice": 123,
      "unitPrice": 123,
      "id": "<string>",
      "creditTypeId": "<string>"
    }
  ]
}

Error Responses

{
  "message": "<string>"
}