Preview Bill - m3ter Documentation

Preview Bill

cURL

curl --request POST \
  --url https://api.m3ter.com/organizations/{orgId}/bills/preview \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "version": 123,
  "lastDateInBillingPeriod": "2023-12-25",
  "billFrequencyInterval": 123,
  "billDate": "2023-12-25",
  "externalInvoiceDate": "2023-12-25",
  "dueDate": "2023-12-25",
  "accountIds": [
    "<string>"
  ],
  "targetCurrency": "<string>",
  "currencyConversions": [
    {
      "from": "EUR",
      "to": "USD",
      "multiplier": 1.12
    }
  ],
  "timezone": "UTC",
  "yearEpoch": "2023-12-25",
  "monthEpoch": "2023-12-25",
  "weekEpoch": "2023-12-25",
  "dayEpoch": "2023-12-25"
}
'

Python

import requests

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

payload = {
    "version": 123,
    "lastDateInBillingPeriod": "2023-12-25",
    "billFrequencyInterval": 123,
    "billDate": "2023-12-25",
    "externalInvoiceDate": "2023-12-25",
    "dueDate": "2023-12-25",
    "accountIds": ["<string>"],
    "targetCurrency": "<string>",
    "currencyConversions": [
        {
            "from": "EUR",
            "to": "USD",
            "multiplier": 1.12
        }
    ],
    "timezone": "UTC",
    "yearEpoch": "2023-12-25",
    "monthEpoch": "2023-12-25",
    "weekEpoch": "2023-12-25",
    "dayEpoch": "2023-12-25"
}
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({
    version: 123,
    lastDateInBillingPeriod: '2023-12-25',
    billFrequencyInterval: 123,
    billDate: '2023-12-25',
    externalInvoiceDate: '2023-12-25',
    dueDate: '2023-12-25',
    accountIds: ['<string>'],
    targetCurrency: '<string>',
    currencyConversions: [{from: 'EUR', to: 'USD', multiplier: 1.12}],
    timezone: 'UTC',
    yearEpoch: '2023-12-25',
    monthEpoch: '2023-12-25',
    weekEpoch: '2023-12-25',
    dayEpoch: '2023-12-25'
  })
};

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

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.m3ter.com/organizations/{orgId}/bills/preview",
  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([
    'version' => 123,
    'lastDateInBillingPeriod' => '2023-12-25',
    'billFrequencyInterval' => 123,
    'billDate' => '2023-12-25',
    'externalInvoiceDate' => '2023-12-25',
    'dueDate' => '2023-12-25',
    'accountIds' => [
        '<string>'
    ],
    'targetCurrency' => '<string>',
    'currencyConversions' => [
        [
                'from' => 'EUR',
                'to' => 'USD',
                'multiplier' => 1.12
        ]
    ],
    'timezone' => 'UTC',
    'yearEpoch' => '2023-12-25',
    'monthEpoch' => '2023-12-25',
    'weekEpoch' => '2023-12-25',
    'dayEpoch' => '2023-12-25'
  ]),
  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,
  "accountId": "<string>",
  "accountCode": "<string>",
  "startDate": "2023-12-25",
  "endDate": "2023-12-25",
  "startDateTimeUTC": "2023-11-07T05:31:56Z",
  "endDateTimeUTC": "2023-11-07T05:31:56Z",
  "billDate": "2023-12-25",
  "dueDate": "2023-12-25",
  "billFrequencyInterval": 123,
  "timezone": "UTC",
  "currency": "<string>",
  "locked": true,
  "createdDate": "2023-11-07T05:31:56Z",
  "billJobId": "<string>",
  "currencyConversions": [
    {
      "from": "EUR",
      "to": "USD",
      "multiplier": 1.12
    }
  ],
  "lastCalculatedDate": "2023-11-07T05:31:56Z",
  "lineItems": [
    {
      "description": "<string>",
      "quantity": 123,
      "units": 123,
      "unit": "<string>",
      "subtotal": 123,
      "currency": "<string>",
      "conversionRate": 123,
      "convertedSubtotal": 123,
      "averageUnitPrice": 123,
      "id": "<string>",
      "productId": "<string>",
      "productName": "<string>",
      "productCode": "<string>",
      "accountingProductId": "<string>",
      "accountingProductName": "<string>",
      "accountingProductCode": "<string>",
      "aggregationId": "<string>",
      "compoundAggregationId": "<string>",
      "counterId": "<string>",
      "chargeId": "<string>",
      "segment": {},
      "group": {},
      "meterId": "<string>",
      "planId": "<string>",
      "planGroupId": "<string>",
      "commitmentId": "<string>",
      "balanceId": "<string>",
      "creditTypeId": "<string>",
      "pricingId": "<string>",
      "childAccountId": "<string>",
      "childAccountCode": "<string>",
      "usagePerPricingBand": [
        {
          "pricingBandId": "<string>",
          "lowerLimit": 123,
          "fixedPrice": 123,
          "unitSubtotal": 123,
          "unitPrice": 123,
          "bandUnits": 123,
          "bandQuantity": 123,
          "bandSubtotal": 123,
          "creditTypeId": "<string>",
          "convertedBandSubtotal": 123
        }
      ],
      "servicePeriodStartDate": "2023-11-07T05:31:56Z",
      "servicePeriodEndDate": "2023-11-07T05:31:56Z",
      "referencedBillId": "<string>",
      "referencedLineItemId": "<string>",
      "reasonId": "<string>",
      "contractId": "<string>",
      "sequenceNumber": 123,
      "additional": {},
      "grantDrawdowns": [
        {
          "balanceId": "<string>",
          "quantity": 123,
          "units": 123,
          "currencyAmount": 123
        }
      ],
      "balanceDrawdowns": [
        {
          "balanceId": "<string>",
          "units": 123,
          "balanceAmount": 123,
          "lineItemAmount": 123,
          "billAmount": 123
        }
      ],
      "commitmentDrawdowns": [
        {
          "commitmentId": "<string>",
          "units": 123,
          "commitmentAmount": 123,
          "lineItemAmount": 123,
          "billAmount": 123
        }
      ],
      "creditCoverage": [
        {
          "lineItemId": "<string>",
          "units": 123,
          "lineItemAmount": 123,
          "creditAmount": 123,
          "billAmount": 123
        }
      ]
    }
  ],
  "purchaseOrderNumber": "<string>",
  "externalInvoiceReference": "<string>",
  "externalInvoiceDate": "2023-12-25",
  "jsonStatementGenerated": true,
  "csvStatementGenerated": true,
  "statementStale": true,
  "billTotal": 123,
  "totalDebits": 123,
  "totalCredits": 123,
  "sequentialInvoiceNumber": "<string>",
  "dtCreated": "2023-11-07T05:31:56Z",
  "dtLastModified": "2023-11-07T05:31:56Z",
  "createdBy": "<string>",
  "lastModifiedBy": "<string>",
  "dtApproved": "2023-11-07T05:31:56Z",
  "approvedBy": "<string>",
  "dtLocked": "2023-11-07T05:31:56Z",
  "lockedBy": "<string>"
}

Error Messages

{
  "message": "<string>"
}
{
  "message": "<string>"
}