curl --request PUT \
--url https://app.miget.com/api/v1/workspace/pay_per_use \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"enabled": true
}
'import requests
url = "https://app.miget.com/api/v1/workspace/pay_per_use"
payload = { "enabled": True }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({enabled: true})
};
fetch('https://app.miget.com/api/v1/workspace/pay_per_use', 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://app.miget.com/api/v1/workspace/pay_per_use",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://app.miget.com/api/v1/workspace/pay_per_use"
payload := strings.NewReader("{\n \"enabled\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.put("https://app.miget.com/api/v1/workspace/pay_per_use")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.miget.com/api/v1/workspace/pay_per_use")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"billed_in_cents": 123,
"pending_in_cents": 123,
"total_in_cents": 123,
"minimum_in_cents": 123,
"projected_in_cents": 123,
"limit_reached_on": "2023-12-25",
"spend_limit_in_cents": 123,
"spend_limit_floor_in_cents": 123,
"pay_per_use_enabled": true,
"charge_threshold_in_cents": 123,
"charged_early_in_cents": 123,
"credits_applied_in_cents": 123,
"due_after_first_payment_in_cents": 123,
"cycle_start": "<string>",
"cycle_end": "<string>",
"billed_through": "<string>",
"workloads": [
{
"workload_type": "<string>",
"workload_id": 123,
"name": "<string>",
"amount_in_cents": 123,
"resources": {}
}
],
"adjustments": [
{
"amount_in_cents": 123,
"note": "<string>",
"made_at": "<string>"
}
]
}Turn Usage Billing on or off
Usage Billing is on by default. Turned off, no application, service, bucket or stack can be created with pay_per_use, and the dashboard stops offering it. It can only be turned off once nothing in the workspace is on Usage Billing, and turning it off turns off the preview environments on Usage Billing, telling each application’s admins why. Not available on an enterprise contract.
curl --request PUT \
--url https://app.miget.com/api/v1/workspace/pay_per_use \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"enabled": true
}
'import requests
url = "https://app.miget.com/api/v1/workspace/pay_per_use"
payload = { "enabled": True }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({enabled: true})
};
fetch('https://app.miget.com/api/v1/workspace/pay_per_use', 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://app.miget.com/api/v1/workspace/pay_per_use",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://app.miget.com/api/v1/workspace/pay_per_use"
payload := strings.NewReader("{\n \"enabled\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.put("https://app.miget.com/api/v1/workspace/pay_per_use")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.miget.com/api/v1/workspace/pay_per_use")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"billed_in_cents": 123,
"pending_in_cents": 123,
"total_in_cents": 123,
"minimum_in_cents": 123,
"projected_in_cents": 123,
"limit_reached_on": "2023-12-25",
"spend_limit_in_cents": 123,
"spend_limit_floor_in_cents": 123,
"pay_per_use_enabled": true,
"charge_threshold_in_cents": 123,
"charged_early_in_cents": 123,
"credits_applied_in_cents": 123,
"due_after_first_payment_in_cents": 123,
"cycle_start": "<string>",
"cycle_end": "<string>",
"billed_through": "<string>",
"workloads": [
{
"workload_type": "<string>",
"workload_id": 123,
"name": "<string>",
"amount_in_cents": 123,
"resources": {}
}
],
"adjustments": [
{
"amount_in_cents": 123,
"note": "<string>",
"made_at": "<string>"
}
]
}Authorizations
Body
Response
Turn Usage Billing on or off
Api_V1_Entities_WorkspaceUsage model
Unbilled usage beyond the minimum is charged to the card whenever it reaches this amount, rather than waiting for the renewal. It starts at 2500 and each paid renewal raises it a step (5000, 25000, 100000, 400000); during a free trial, until a charge in it is paid, it is 500. A value Miget set for the workspace, on an approved limit increase or otherwise, replaces the ladder; null once usage is charged with the renewal alone, and before the subscription's first payment, when nothing is charged. A refused charge stops the workspace's workloads on Usage Billing until it is paid
What the workspace's credits pay of this cycle's usage beyond the minimum, before the card: what they paid of the hours already sent to billing, plus what the balance left covers of the rest, the hour in progress included. The renewal and the threshold bill only the usage beyond the minimum and these credits
Usage that ran before the subscription's first payment, as during an onboarding Miget set up, and is not billed yet: all of it, with no monthly minimum taken off, is charged to the card right after that payment, the workspace's credits paying first. 0 once the subscription is paid

