Download Bills - m3ter Documentation
Download Bills
cURL
curl --request POST \
--url https://api.m3ter.com/organizations/{orgId}/bills/download/csv \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"externalSystem": "STANDARD"
}
'```
### Python
```python
import requests
url = "https://api.m3ter.com/organizations/{orgId}/bills/download/csv"
payload = {
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-24T14:15:22Z",
"externalSystem": "STANDARD"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (fetch)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
startDate: '2019-08-24T14:15:22Z',
endDate: '2019-08-24T14:15:22Z',
externalSystem: 'STANDARD'
})
};
fetch('https://api.m3ter.com/organizations/{orgId}/bills/download/csv', 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}/bills/download/csv",
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' => '2019-08-24T14:15:22Z',
'endDate' => '2019-08-24T14:15:22Z',
'externalSystem' => 'STANDARD'
]),
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
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.m3ter.com/organizations/{orgId}/bills/download/csv"
payload := strings.NewReader("{\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-24T14:15:22Z\",\n \"externalSystem\": \"STANDARD\"\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))
}
Java (Unirest)
HttpResponse<String> response = Unirest.post("https://api.m3ter.com/organizations/{orgId}/bills/download/csv")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-24T14:15:22Z\",\n \"externalSystem\": \"STANDARD\"\n}")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://api.m3ter.com/organizations/{orgId}/bills/download/csv")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-24T14:15:22Z\",\n \"externalSystem\": \"STANDARD\"\n}"
response = http.request(request)
puts response.read_body
Authorization
Authorization
- Type: string
- Required: Yes
m3ter supports machine to machine authentication using the clientCredentials OAuth2 flow.
Path Parameters
- orgId: string, required. The unique identifier (UUID) of your Organization.
Body
- startDate: string
- Specifies the start date of the billing period for downloading Bills. - endDate: string
- Specifies the end date of the billing period for downloading Bills. - externalSystem: enum
- Use this parameter if you have implemented an integration with your Xero system. Available options: STANDARD,XERO.
Response
301: Redirect to a CSV file containing the bill details.