List credit grants
curl --request POST \
--url https://api.metronome.com/v1/credits/listGrants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"credit_type_ids": [
"2714e483-4ff1-48e4-9e25-ac732e8f24f2"
],
"customer_ids": [
"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
"0e5b8609-d901-4992-b394-c3c2e3f37b1c"
],
"not_expiring_before": "2022-02-01T00:00:00Z",
"effective_before": "2022-02-01T00:00:00Z"
}
'import requests
url = "https://api.metronome.com/v1/credits/listGrants"
payload = {
"credit_type_ids": ["2714e483-4ff1-48e4-9e25-ac732e8f24f2"],
"customer_ids": ["d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc", "0e5b8609-d901-4992-b394-c3c2e3f37b1c"],
"not_expiring_before": "2022-02-01T00:00:00Z",
"effective_before": "2022-02-01T00:00:00Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
credit_type_ids: ['2714e483-4ff1-48e4-9e25-ac732e8f24f2'],
customer_ids: ['d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', '0e5b8609-d901-4992-b394-c3c2e3f37b1c'],
not_expiring_before: '2022-02-01T00:00:00Z',
effective_before: '2022-02-01T00:00:00Z'
})
};
fetch('https://api.metronome.com/v1/credits/listGrants', 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.metronome.com/v1/credits/listGrants",
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([
'credit_type_ids' => [
'2714e483-4ff1-48e4-9e25-ac732e8f24f2'
],
'customer_ids' => [
'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',
'0e5b8609-d901-4992-b394-c3c2e3f37b1c'
],
'not_expiring_before' => '2022-02-01T00:00:00Z',
'effective_before' => '2022-02-01T00:00:00Z'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.metronome.com/v1/credits/listGrants"
payload := strings.NewReader("{\n \"credit_type_ids\": [\n \"2714e483-4ff1-48e4-9e25-ac732e8f24f2\"\n ],\n \"customer_ids\": [\n \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"0e5b8609-d901-4992-b394-c3c2e3f37b1c\"\n ],\n \"not_expiring_before\": \"2022-02-01T00:00:00Z\",\n \"effective_before\": \"2022-02-01T00:00:00Z\"\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))
}HttpResponse<String> response = Unirest.post("https://api.metronome.com/v1/credits/listGrants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"credit_type_ids\": [\n \"2714e483-4ff1-48e4-9e25-ac732e8f24f2\"\n ],\n \"customer_ids\": [\n \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"0e5b8609-d901-4992-b394-c3c2e3f37b1c\"\n ],\n \"not_expiring_before\": \"2022-02-01T00:00:00Z\",\n \"effective_before\": \"2022-02-01T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.metronome.com/v1/credits/listGrants")
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 \"credit_type_ids\": [\n \"2714e483-4ff1-48e4-9e25-ac732e8f24f2\"\n ],\n \"customer_ids\": [\n \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"0e5b8609-d901-4992-b394-c3c2e3f37b1c\"\n ],\n \"not_expiring_before\": \"2022-02-01T00:00:00Z\",\n \"effective_before\": \"2022-02-01T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "9acbc1d0-2044-44c4-8577-f6078a1d8cd2",
"name": "Initial credit purchase",
"customer_id": "b310b282-d5cf-4e4f-915f-d8c3c4971e45",
"uniqueness_key": "823j7fqzo1",
"reason": "Prepayment",
"effective_at": "2022-01-01T00:00:00.000Z",
"expires_at": "2022-04-01T00:00:00.000Z",
"priority": 0.5,
"grant_amount": {
"amount": 100,
"credit_type": {
"id": "fa2f1b3d-9d52-4951-a099-25991fd394d6",
"name": "cloud consumption units"
}
},
"paid_amount": {
"amount": 10,
"credit_type": {
"id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"name": "USD (cents)"
}
},
"balance": {
"including_pending": 80,
"excluding_pending": 80,
"effective_at": "2022-02-01T00:00:00.000Z"
},
"deductions": [
{
"amount": 20,
"reason": "Automated invoice deduction",
"running_balance": 80,
"effective_at": "2022-02-01T00:00:00.000Z",
"created_by": "Metronome System",
"credit_grant_id": "9acbc1d0-2044-44c4-8577-f6078a1d8cd2",
"invoice_id": "b6a60e95-15f4-403c-be40-f1c1d58cee20"
}
],
"pending_deductions": [],
"custom_fields": {
"x_account_id": "KyVnHhSBWl7eY2bl"
},
"credit_grant_type": "enterprise"
}
],
"next_page": null
}Credits
List credit grants
List credit grants. This list does not included voided grants. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.
POST
/
credits
/
listGrants
List credit grants
curl --request POST \
--url https://api.metronome.com/v1/credits/listGrants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"credit_type_ids": [
"2714e483-4ff1-48e4-9e25-ac732e8f24f2"
],
"customer_ids": [
"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
"0e5b8609-d901-4992-b394-c3c2e3f37b1c"
],
"not_expiring_before": "2022-02-01T00:00:00Z",
"effective_before": "2022-02-01T00:00:00Z"
}
'import requests
url = "https://api.metronome.com/v1/credits/listGrants"
payload = {
"credit_type_ids": ["2714e483-4ff1-48e4-9e25-ac732e8f24f2"],
"customer_ids": ["d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc", "0e5b8609-d901-4992-b394-c3c2e3f37b1c"],
"not_expiring_before": "2022-02-01T00:00:00Z",
"effective_before": "2022-02-01T00:00:00Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
credit_type_ids: ['2714e483-4ff1-48e4-9e25-ac732e8f24f2'],
customer_ids: ['d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', '0e5b8609-d901-4992-b394-c3c2e3f37b1c'],
not_expiring_before: '2022-02-01T00:00:00Z',
effective_before: '2022-02-01T00:00:00Z'
})
};
fetch('https://api.metronome.com/v1/credits/listGrants', 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.metronome.com/v1/credits/listGrants",
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([
'credit_type_ids' => [
'2714e483-4ff1-48e4-9e25-ac732e8f24f2'
],
'customer_ids' => [
'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',
'0e5b8609-d901-4992-b394-c3c2e3f37b1c'
],
'not_expiring_before' => '2022-02-01T00:00:00Z',
'effective_before' => '2022-02-01T00:00:00Z'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.metronome.com/v1/credits/listGrants"
payload := strings.NewReader("{\n \"credit_type_ids\": [\n \"2714e483-4ff1-48e4-9e25-ac732e8f24f2\"\n ],\n \"customer_ids\": [\n \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"0e5b8609-d901-4992-b394-c3c2e3f37b1c\"\n ],\n \"not_expiring_before\": \"2022-02-01T00:00:00Z\",\n \"effective_before\": \"2022-02-01T00:00:00Z\"\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))
}HttpResponse<String> response = Unirest.post("https://api.metronome.com/v1/credits/listGrants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"credit_type_ids\": [\n \"2714e483-4ff1-48e4-9e25-ac732e8f24f2\"\n ],\n \"customer_ids\": [\n \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"0e5b8609-d901-4992-b394-c3c2e3f37b1c\"\n ],\n \"not_expiring_before\": \"2022-02-01T00:00:00Z\",\n \"effective_before\": \"2022-02-01T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.metronome.com/v1/credits/listGrants")
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 \"credit_type_ids\": [\n \"2714e483-4ff1-48e4-9e25-ac732e8f24f2\"\n ],\n \"customer_ids\": [\n \"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc\",\n \"0e5b8609-d901-4992-b394-c3c2e3f37b1c\"\n ],\n \"not_expiring_before\": \"2022-02-01T00:00:00Z\",\n \"effective_before\": \"2022-02-01T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "9acbc1d0-2044-44c4-8577-f6078a1d8cd2",
"name": "Initial credit purchase",
"customer_id": "b310b282-d5cf-4e4f-915f-d8c3c4971e45",
"uniqueness_key": "823j7fqzo1",
"reason": "Prepayment",
"effective_at": "2022-01-01T00:00:00.000Z",
"expires_at": "2022-04-01T00:00:00.000Z",
"priority": 0.5,
"grant_amount": {
"amount": 100,
"credit_type": {
"id": "fa2f1b3d-9d52-4951-a099-25991fd394d6",
"name": "cloud consumption units"
}
},
"paid_amount": {
"amount": 10,
"credit_type": {
"id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"name": "USD (cents)"
}
},
"balance": {
"including_pending": 80,
"excluding_pending": 80,
"effective_at": "2022-02-01T00:00:00.000Z"
},
"deductions": [
{
"amount": 20,
"reason": "Automated invoice deduction",
"running_balance": 80,
"effective_at": "2022-02-01T00:00:00.000Z",
"created_by": "Metronome System",
"credit_grant_id": "9acbc1d0-2044-44c4-8577-f6078a1d8cd2",
"invoice_id": "b6a60e95-15f4-403c-be40-f1c1d58cee20"
}
],
"pending_deductions": [],
"custom_fields": {
"x_account_id": "KyVnHhSBWl7eY2bl"
},
"credit_grant_type": "enterprise"
}
],
"next_page": null
}Authorizations
Query Parameters
Body
application/json
Filters specifying which credit grants should be included