Skip to main content
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

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

limit
integer

Max number of results that should be returned

Required range: 1 <= x <= 100
next_page
string

Cursor that indicates where the next page of results should start.

Body

application/json

Filters specifying which credit grants should be included

credit_type_ids
string<uuid>[]

An array of credit type IDs. This must not be specified if credit_grant_ids is specified.

Example:

"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc, 0e5b8609-d901-4992-b394-c3c2e3f37b1c"

customer_ids
string<uuid>[]

An array of Metronome customer IDs. This must not be specified if credit_grant_ids is specified.

Example:

"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc, 0e5b8609-d901-4992-b394-c3c2e3f37b1c"

credit_grant_ids
string<uuid>[]

An array of credit grant IDs. If this is specified, neither credit_type_ids nor customer_ids may be specified.

Example:

"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc, 0e5b8609-d901-4992-b394-c3c2e3f37b1c"

not_expiring_before
string<date-time>

Only return credit grants that expire at or after this timestamp.

Example:

"2022-02-01T00:00:00Z"

effective_before
string<date-time>

Only return credit grants that are effective before this timestamp (exclusive).

Example:

"2022-02-01T00:00:00Z"

Response

200 - application/json

Success

data
object[]
required
next_page
string | null
required