> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# Update low balance settings

PUT https://%7BYour_Space_Name%7D.signalwire.com/api/space/low_balance_setting
Content-Type: application/json

Replaces the low balance notification and auto top-up settings. The update writes the
whole setting, so send every field you want to keep; omitted fields take their
defaults.

When `send_topup` is `true`, `topup_amount_in_microdollars` and
`topup_payment_method_id` are required. The threshold must be a whole number of cents
between 5,000,000 and 1,000,000,000,000 microdollars, and the top-up amount a whole
number of cents of at least 10,000,000 microdollars (10.00 USD). Some spaces are
required to keep auto top-up on; disabling it there is rejected with
`send_topup_cannot_be_disabled`.

#### Permissions

Authenticate with a [Personal access token](/docs/apis/authorization#personal-access-tokens) whose holder is an owner or admin of the space. A project API token is not accepted on this endpoint, and a Personal access token has no scopes: the holder's role in the space is the whole authorization decision.

Reference: https://signalwire.com/docs/apis/rest/space/balance/update-low-balance-setting

## Authentication

- `Authorization` header (basic auth, required) — Personal access token authentication for space-wide administration. Send HTTP Basic auth with an empty username and the Personal access token as the password. A Personal access token carries your own authority rather than a project's: it is created from your user menu in the Dashboard, is prefixed `pat_`, and has no scopes. The holder must be an owner or admin of the space named by the subdomain, and the token acts only on that space. Example: ``` Authorization: Basic base64(:pat_...) ```

## Request

### Body (application/json)

This endpoint expects an object.

- `threshold_in_microdollars` (long, optional) — The balance, in microdollars, below which notifications and auto top-up trigger. A whole number of cents, at least 5,000,000 (5.00 USD) and at most 1,000,000,000,000 (1,000,000 USD). Defaults to the platform default when omitted.
- `send_email` (boolean, optional, default: true) — Whether to send an email when the balance falls below the threshold.
- `send_webhook` (boolean, optional, default: false) — Whether to send a webhook when the balance falls below the threshold.
- `webhook_url` (string, optional) — The URL to send the low balance webhook to. Required when `send_webhook` is `true` (`webhook_url_missing`).
- `webhook_method` (enum, optional, default: POST) — The HTTP method for the low balance webhook: `GET` or `POST`.
  - Allowed values: `GET`, `POST`
- `send_topup` (boolean, optional, default: false) — Whether to top the balance up automatically when it falls below the threshold. Some spaces are required to keep auto top-up on; disabling it there is rejected with `send_topup_cannot_be_disabled`.
- `topup_amount_in_microdollars` (long, optional) — The amount, in microdollars, to deposit on each auto top-up. Required when `send_topup` is `true` (`topup_amount_missing`). A whole number of cents and at least 10,000,000 (10.00 USD).
- `topup_payment_method_id` (string, optional) — The payment method to charge on each auto top-up. Required when `send_topup` is `true` (`topup_payment_method_missing`) and must name a payment method on this space (`topup_payment_method_invalid`).

## Response

### 200

The request has succeeded.

- `type` (enum, required) — The object type. Always `low_balance_setting`.
  - Allowed values: `low_balance_setting`
- `threshold_in_microdollars` (long, required) — The balance, in microdollars, below which notifications and auto top-up trigger. Falls back to the platform default when never configured.
- `threshold` (double, required) — The threshold in US dollars. The same value as `threshold_in_microdollars`.
- `send_email` (boolean, required) — Whether an email is sent when the balance falls below the threshold.
- `send_webhook` (boolean, required) — Whether a webhook is sent when the balance falls below the threshold.
- `webhook_url` (string, required, nullable) — The URL the low balance webhook is sent to, or `null` when none is set.
- `webhook_method` (enum, required, nullable) — The HTTP method used for the low balance webhook, or `null` when none is set.
  - Allowed values: `GET`, `POST`
- `send_topup` (boolean, required) — Whether auto top-up is enabled.
- `topup_amount_in_microdollars` (long, required, nullable) — The amount, in microdollars, deposited by each auto top-up. Can be `null`.
- `topup_amount` (double, required, nullable) — The auto top-up amount in US dollars. The same value as `topup_amount_in_microdollars`.
- `topup_payment_method_id` (string, required, nullable) — The payment method charged by auto top-up, or `null` when none is set.

## Errors

### 400 Bad Request Error

The request body is not valid JSON.

- `errors` (list of object, required) — List of validation errors.
  - `type` (string, required) — The category of error.
  - `code` (string, required) — A specific error code.
  - `message` (string, required) — A description of what caused the error.
  - `url` (string, required) — A link to documentation about this error.
  - `attribute` (string, optional, nullable) — The request parameter that caused the error, if applicable.

### 401 Unauthorized Error

The credential is missing, unknown, or revoked; its holder is not a member of the space in the subdomain; or the member is not an owner or admin. The body is the plain text `Unauthorized`. An unverified space instead receives the JSON body `{"message": "Please validate a phone number to access your account."}` on every endpoint under `/api/space`.

- `message` (string, required) — States that a phone number must be validated for the space before it can use the API.

### 422 Unprocessable Entity Error

The request failed validation. Threshold codes: `threshold_not_whole_cents`, `threshold_below_minimum`, `threshold_above_maximum`. Auto top-up codes: `topup_amount_missing`, `topup_amount_not_whole_cents`, `topup_amount_below_minimum`, `topup_payment_method_missing`, `topup_payment_method_invalid`, `send_topup_cannot_be_disabled`. Webhook codes: `webhook_url_missing`, `webhook_method_invalid`.

- `errors` (list of object, required) — List of validation errors.
  - `type` (string, required) — The category of error.
  - `code` (string, required) — A specific error code.
  - `message` (string, required) — A description of what caused the error.
  - `url` (string, required) — A link to documentation about this error.
  - `attribute` (string, optional, nullable) — The request parameter that caused the error, if applicable.

### 500 Internal Server Error

An internal server error occurred.

- `error` (enum, required)
  - Allowed values: `Internal Server Error`

### 502 Bad Gateway Error

An upstream billing or usage reporting service was unavailable. The body is empty; retry later.

- `any`

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "type": "low_balance_setting",
  "threshold_in_microdollars": 6000000,
  "threshold": 6,
  "send_email": true,
  "send_webhook": false,
  "webhook_url": "https://example.com/hooks/low-balance",
  "webhook_method": "POST",
  "send_topup": true,
  "topup_amount_in_microdollars": 20000000,
  "topup_amount": 20,
  "topup_payment_method_id": "7a8b9c0d-1e2f-4304-8516-27384950a6b7"
}
```

**SDK Code**

```python
import requests

url = "https://{your_space_name}.signalwire.com/api/space/low_balance_setting"

payload = {}
headers = {
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers, auth=("<username>", "<personal_access_token>"))

print(response.json())
```

```javascript
const url = 'https://{your_space_name}.signalwire.com/api/space/low_balance_setting';
const credentials = btoa("<username>:<personal_access_token>");

const options = {
  method: 'PUT',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://{your_space_name}.signalwire.com/api/space/low_balance_setting"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.SetBasicAuth("<username>", "<personal_access_token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://{your_space_name}.signalwire.com/api/space/low_balance_setting")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request.basic_auth("<username>", "<personal_access_token>")
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://{your_space_name}.signalwire.com/api/space/low_balance_setting")
  .basicAuth("<username>", "<personal_access_token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://{your_space_name}.signalwire.com/api/space/low_balance_setting', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<username>', '<personal_access_token>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://{your_space_name}.signalwire.com/api/space/low_balance_setting");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<personal_access_token>");
var request = new RestRequest(Method.PUT);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<personal_access_token>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/space/low_balance_setting")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```