Update Credit Settings
curl --request POST \
--url https://api.example.com/credits/settingsimport requests
url = "https://api.example.com/credits/settings"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/credits/settings', 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.example.com/credits/settings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/credits/settings"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/credits/settings")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/credits/settings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyCredits
Update Credit Settings
Configure auto top-ups for your organization’s credits.
POST
/
credits
/
settings
Update Credit Settings
curl --request POST \
--url https://api.example.com/credits/settingsimport requests
url = "https://api.example.com/credits/settings"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/credits/settings', 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.example.com/credits/settings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/credits/settings"
req, _ := http.NewRequest("POST", url, nil)
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.example.com/credits/settings")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/credits/settings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyEnable, disable, or update auto top-up settings for your organization. When enabled, credits are automatically purchased at your plan’s top-up rate whenever your balance drops below the threshold.
Requires one of these active plans:
creator, creator_annual, professional, or professional_annual. Returns 403 if no eligible plan is active.
To read current credit and auto top-up state, use GET /credits.
Request
curl -X POST "https://api.mosaic.so/credits/settings" \
-H "Authorization: Bearer mk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"auto_topup": {
"enabled": true,
"threshold": 1000,
"quantity": 5000
}
}'
Body Parameters
| Field | Type | Required | Description |
|---|---|---|---|
auto_topup.enabled | boolean | Yes | Enable or disable auto top-ups. |
auto_topup.threshold | number | Yes | Credit balance threshold that triggers an auto top-up (0 – 1,000,000). |
auto_topup.quantity | number | Yes | Number of credits to purchase per auto top-up (0 – 1,000,000). |
Response
Returns the updated settings.{
"auto_topup": {
"enabled": true,
"threshold": 1000,
"quantity": 5000
}
}
Errors
| Status | Reason |
|---|---|
403 | No active paid plan, or plan is not eligible for auto top-ups (must be creator, creator_annual, professional, or professional_annual). |
Examples
Enable auto top-up
curl -X POST "https://api.mosaic.so/credits/settings" \
-H "Authorization: Bearer mk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"auto_topup": {
"enabled": true,
"threshold": 500,
"quantity": 2000
}
}'
Disable auto top-up
curl -X POST "https://api.mosaic.so/credits/settings" \
-H "Authorization: Bearer mk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"auto_topup": {
"enabled": false,
"threshold": 0,
"quantity": 0
}
}'
Was this page helpful?
⌘I