> This page is for Developers.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.iot.telia.lt/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.iot.telia.lt/_mcp/server.

# Set SMS quota

POST https://iot.telia.lt/api/v1/endpoint/{endpoint_id}/quota/sms
Content-Type: application/json

At any time, a new SMS quota can be set for an endpoint.
At an initial state when no SMS quota is set, the endpoint will be denied from using SMS services.
To top-up the SMS volume one need to retrieve the currently left volume, increase it by the top-up volume and set it as the new quota volume.

The following parameters can be configured:

* `status` - The status of the quota (mandatory):
  * 1: `ACTIVE`
  * 2: `EXHAUSTED`
  * 3: `EXPIRED`
* `volume`: The volume left on this quota in MB
* `expiry_date`: Timestamp when this quota will expire and the endpoint will definitely be denied from using further data services (mandatory)
* `auto_refill`: Wether the quota shall be refilled on a daily basis (defaults to disabled):
  * 0: `disabled`
  * 1: `enabled`
* `threshold_percentage`: The percentage of remaining quota at which the system should generate a `threshold reached` event
* `action_on_exhaustion`: The behaviour of the system after the quota is exhausted:
  * id: ID of the action on quota exhaustion (mandatory)
    * 1: `Block`
    * 2: `Throttle` (will not take any effect on SMS quota)
  * `peak_throughput`: The maximum bandwidth in octets per second after the endpoint has been throttled.
    Allowed values are 64000, 128000, 256000, 384000. (will not take any effect on SMS quota)

The endpoint can instantly use the SMS service after the API call is successfully made.
Any timestamp with a future date can be set, this allows to create SMS packages (e.g. for 1 hour, 24 hour, 7 days or any other timeframe) as required.

Reference: https://docs.iot.telia.lt/developers/api/endpoint/endpoint-quota-sms-by-endpoint-id-post

## Authentication

- `Authorization` header (bearer token, required) — An `auth_token` should be provided to authenticate a session. To obtain an `auth_token`, see the [`/api/v1/authenticate` **POST** request](/developers/api/authentication/authenticate).

## Request

### Path parameters

- `endpoint_id` (integer, required) — Numeric ID of an endpoint

### Body (application/json)

This endpoint expects an object.

- `volume` (double, required)
- `expiry_date` (string, required)
- `threshold_percentage` (double, required)
- `status` (ApiV1EndpointEndpointIdQuotaSmsPostRequestBodyContentApplicationJsonSchemaStatus, required)
- `last_volume_added` (double, optional)
- `last_status_change_date` (string, optional, nullable)
- `auto_refill` (boolean, optional)
- `threshold_volume` (double, optional)
- `action_on_exhaustion` (ApiV1EndpointEndpointIdQuotaSmsPostRequestBodyContentApplicationJsonSchemaActionOnExhaustion, optional)

## Response

### 201

Resource Created

## Errors

### 403 Forbidden Error

Your role doesn't include the permission this endpoint requires. Most endpoints return `error_code`, `error_token`, and `message`. Some return only `status_code` and `message`.

- `error_code` (integer, optional)
- `error_token` (string, optional)
- `status_code` (integer, optional)
- `message` (string, optional)

## Types

### ApiV1EndpointEndpointIdQuotaSmsPostRequestBodyContentApplicationJsonSchemaStatus

- `id` (enum, required)
  - Allowed values: `1`, `2`, `3`
- `description` (enum, optional)
  - Allowed values: `EXHAUSTED`, `ACTIVE`, `EXPIRED`

### ApiV1EndpointEndpointIdQuotaSmsPostRequestBodyContentApplicationJsonSchemaActionOnExhaustion

- `id` (enum, required)
  - Allowed values: `1`
- `description` (enum, optional)
  - Allowed values: `Block`

## Examples

**Request**

```json
{
  "volume": 100,
  "expiry_date": "2022-01-17T08:47:00.000Z",
  "threshold_percentage": 20,
  "status": {
    "id": 1,
    "description": "ACTIVE"
  },
  "action_on_exhaustion": {
    "id": 1
  }
}
```

**Response**

```json
{}
```

**SDK Code**

```python Create a 100 SMS Quota
import requests

url = "https://iot.telia.lt/api/v1/endpoint/1/quota/sms"

payload = {
    "volume": 100,
    "expiry_date": "2022-01-17T08:47:00.000Z",
    "threshold_percentage": 20,
    "status": {
        "id": 1,
        "description": "ACTIVE"
    },
    "action_on_exhaustion": { "id": 1 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Create a 100 SMS Quota
const url = 'https://iot.telia.lt/api/v1/endpoint/1/quota/sms';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"volume":100,"expiry_date":"2022-01-17T08:47:00.000Z","threshold_percentage":20,"status":{"id":1,"description":"ACTIVE"},"action_on_exhaustion":{"id":1}}'
};

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

```go Create a 100 SMS Quota
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/endpoint/1/quota/sms"

	payload := strings.NewReader("{\n  \"volume\": 100,\n  \"expiry_date\": \"2022-01-17T08:47:00.000Z\",\n  \"threshold_percentage\": 20,\n  \"status\": {\n    \"id\": 1,\n    \"description\": \"ACTIVE\"\n  },\n  \"action_on_exhaustion\": {\n    \"id\": 1\n  }\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(res)
	fmt.Println(string(body))

}
```

```ruby Create a 100 SMS Quota
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v1/endpoint/1/quota/sms")

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  \"volume\": 100,\n  \"expiry_date\": \"2022-01-17T08:47:00.000Z\",\n  \"threshold_percentage\": 20,\n  \"status\": {\n    \"id\": 1,\n    \"description\": \"ACTIVE\"\n  },\n  \"action_on_exhaustion\": {\n    \"id\": 1\n  }\n}"

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

```java Create a 100 SMS Quota
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v1/endpoint/1/quota/sms")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"volume\": 100,\n  \"expiry_date\": \"2022-01-17T08:47:00.000Z\",\n  \"threshold_percentage\": 20,\n  \"status\": {\n    \"id\": 1,\n    \"description\": \"ACTIVE\"\n  },\n  \"action_on_exhaustion\": {\n    \"id\": 1\n  }\n}")
  .asString();
```

```php Create a 100 SMS Quota
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v1/endpoint/1/quota/sms', [
  'body' => '{
  "volume": 100,
  "expiry_date": "2022-01-17T08:47:00.000Z",
  "threshold_percentage": 20,
  "status": {
    "id": 1,
    "description": "ACTIVE"
  },
  "action_on_exhaustion": {
    "id": 1
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Create a 100 SMS Quota
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v1/endpoint/1/quota/sms");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"volume\": 100,\n  \"expiry_date\": \"2022-01-17T08:47:00.000Z\",\n  \"threshold_percentage\": 20,\n  \"status\": {\n    \"id\": 1,\n    \"description\": \"ACTIVE\"\n  },\n  \"action_on_exhaustion\": {\n    \"id\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Create a 100 SMS Quota
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "volume": 100,
  "expiry_date": "2022-01-17T08:47:00.000Z",
  "threshold_percentage": 20,
  "status": [
    "id": 1,
    "description": "ACTIVE"
  ],
  "action_on_exhaustion": ["id": 1]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v1/endpoint/1/quota/sms")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```