Source: https://leadping.ai/docs/api-reference/wallets/set-organization-and-channel-usage-budgets

# Set organization and channel usage budgets

Set organization and channel usage budgets in USD for your Leadping organization. Use `null` to remove a limit or zero to stop new paid usage.

## Endpoint

`PUT https://api.leadping.ai/wallets/me/spend-limits`

## Authorization

The required `Authorization` header uses the Bearer scheme. Accepted credentials are Leadping user JWT access tokens and WorkOS organization API keys beginning with `sk_`.

```http
Authorization: Bearer <token>
```

## Request body

Content types: `application/json` or `application/*+json`

Organization and channel limits. Organization usage budgets are in USD. `null` removes a limit; zero stops new paid usage.

| Field | Type | Description |
|---|---|---|
| `textingLimit` | `null \| number<double>` | Optional texting budget in USD. |
| `textingPeriod` | `enum<string>` | Calendar period for an organization channel budget, in UTC. Available options: `day`, `week`, `month`. |
| `callingLimit` | `null \| number<double>` | Optional calling budget in USD. |
| `callingPeriod` | `enum<string>` | Calendar period for an organization channel budget, in UTC. Available options: `day`, `week`, `month`. |
| `dailyLimit` | `null \| number<double>` | Daily usage budget in USD for the UTC calendar day. `null` removes the limit; zero stops new paid usage. |
| `monthlyLimit` | `null \| number<double>` | Monthly usage budget in USD for the UTC calendar month. `null` removes the limit; zero stops new paid usage. |

### Example request body

```json
{
  "textingLimit": 123,
  "callingLimit": 123,
  "dailyLimit": 123,
  "monthlyLimit": 123
}
```

## Request examples

### cURL

```bash
curl --request PUT \
  --url https://api.leadping.ai/wallets/me/spend-limits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "textingLimit": 123,
  "callingLimit": 123,
  "dailyLimit": 123,
  "monthlyLimit": 123
}
'
```

### Python

```python
import requests

url = "https://api.leadping.ai/wallets/me/spend-limits"

payload = {
    "textingLimit": 123,
    "callingLimit": 123,
    "dailyLimit": 123,
    "monthlyLimit": 123
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.leadping.ai/wallets/me/spend-limits");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n  \"textingLimit\": 123,\n  \"callingLimit\": 123,\n  \"dailyLimit\": 123,\n  \"monthlyLimit\": 123\n}", false);
var response = await client.PutAsync(request);

Console.WriteLine("{0}", response.Content);
```

### Java

```java
HttpResponse<String> response = Unirest.put("https://api.leadping.ai/wallets/me/spend-limits")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"textingLimit\": 123,\n  \"callingLimit\": 123,\n  \"dailyLimit\": 123,\n  \"monthlyLimit\": 123\n}")
  .asString();
```

### JavaScript

```javascript
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({textingLimit: 123, callingLimit: 123, dailyLimit: 123, monthlyLimit: 123})
};

fetch('https://api.leadping.ai/wallets/me/spend-limits', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Go

```go
package main

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

func main() {

	url := "https://api.leadping.ai/wallets/me/spend-limits"

	payload := strings.NewReader("{\n  \"textingLimit\": 123,\n  \"callingLimit\": 123,\n  \"dailyLimit\": 123,\n  \"monthlyLimit\": 123\n}")

	req, _ := http.NewRequest("PUT", 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))

}
```

### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.leadping.ai/wallets/me/spend-limits",
  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([
    'textingLimit' => 123,
    'callingLimit' => 123,
    'dailyLimit' => 123,
    'monthlyLimit' => 123
  ]),
  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;
}
```

## Response

### `200` — Success

Returns the updated usage limits and progress. The response contains UTC calendar usage budgets, settled spend, and pending usage reservations in USD.

| Field | Type | Description |
|---|---|---|
| `textingLimit` | `null \| number<double>` | Optional texting budget in USD. |
| `textingPeriod` | `enum<string>` | Calendar period for an organization channel budget, in UTC. Available options: `day`, `week`, `month`. |
| `callingLimit` | `null \| number<double>` | Optional calling budget in USD. |
| `callingPeriod` | `enum<string>` | Calendar period for an organization channel budget, in UTC. Available options: `day`, `week`, `month`. |
| `textingUsed` | `number<double>` | Settled texting charges this period plus pending texting reservations. |
| `callingUsed` | `number<double>` | Settled calling charges this period plus pending calling reservations. |
| `dailyLimit` | `null \| number<double>` | Daily usage budget in USD. `null` means no daily limit; zero stops new paid usage. |
| `monthlyLimit` | `null \| number<double>` | Monthly usage budget in USD. `null` means no monthly limit; zero stops new paid usage. |
| `dailySpent` | `number<double>` | Settled usage spending in USD for the current UTC calendar day. |
| `monthlySpent` | `number<double>` | Settled usage spending in USD for the current UTC calendar month. |
| `reserved` | `number<double>` | Pending usage reservations in USD. |
| `dailyResetsAt` | `string<date-time>` | UTC timestamp when the next calendar day begins and daily spending resets. |
| `monthlyResetsAt` | `string<date-time>` | UTC timestamp when the next calendar month begins and monthly spending resets. |

Example:

```json
{
  "textingLimit": 123,
  "textingPeriod": "day",
  "callingLimit": 123,
  "callingPeriod": "day",
  "textingUsed": 123,
  "callingUsed": 123,
  "dailyLimit": 123,
  "monthlyLimit": 123,
  "dailySpent": 123,
  "monthlySpent": 123,
  "reserved": 123,
  "dailyResetsAt": "2023-11-07T05:31:56Z",
  "monthlyResetsAt": "2023-11-07T05:31:56Z"
}
```

## Error responses

Errors use the `application/problem+json` content type. The standard problem-details object can include:

| Field | Type | Description |
|---|---|---|
| `type` | `null \| string` | URI reference that identifies the problem type. |
| `title` | `null \| string` | Short, human-readable summary of the problem. |
| `status` | `null \| integer<int32>` | HTTP status code returned for the problem. |
| `detail` | `null \| string` | Human-readable explanation specific to this occurrence of the problem. |
| `instance` | `null \| string` | URI reference that identifies this specific occurrence of the problem. |
| `errors` | `object` | Validation errors keyed by the JSON request field name. Present for request validation failures. |
| `traceId` | `string` | Request trace identifier used to correlate this problem with Leadping diagnostics. |

### `400` — Bad Request

The request contains invalid values or fails validation.

```json
{
  "type": "about:blank",
  "title": "Bad Request",
  "status": 400,
  "detail": "The request could not be completed."
}
```

### `401` — Unauthorized

Authentication credentials are missing or invalid. A `WWW-Authenticate` header provides the Bearer authentication challenge.

```json
{
  "type": "about:blank",
  "title": "Unauthorized",
  "status": 401,
  "detail": "The request could not be completed."
}
```

### `403` — Forbidden

The caller does not have permission to perform this operation.

```json
{
  "type": "about:blank",
  "title": "Forbidden",
  "status": 403,
  "detail": "The request could not be completed."
}
```

### `404` — Not Found

The requested resource or required account context was not found.

```json
{
  "type": "about:blank",
  "title": "Not Found",
  "status": 404,
  "detail": "The request could not be completed."
}
```

### `415` — Request Failed

The request content type is not supported; send `application/json`.

```json
{
  "type": "about:blank",
  "title": "Request Failed",
  "status": 415,
  "detail": "The request could not be completed."
}
```

### `429` — Too Many Requests

The client or account rate limit was exceeded. Retry after the interval in the `Retry-After` header, which contains the number of seconds to wait before retrying.

```json
{
  "type": "about:blank",
  "title": "Too Many Requests",
  "status": 429,
  "detail": "The request could not be completed."
}
```

### `500` — Internal Server Error

An unexpected error prevented the server from completing the request.

```json
{
  "type": "about:blank",
  "title": "Internal Server Error",
  "status": 500,
  "detail": "The request could not be completed."
}
```

## Related endpoints

- Previous: [Check usage budgets and UTC progress](https://leadping.ai/docs/api-reference/wallets/check-usage-budgets-and-utc-progress)
- Next: [Get an organization wallet balance by ID](https://leadping.ai/docs/api-reference/wallets/get-an-organization-wallet-balance-by-id)
