> 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 data quota

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

Set a new data quota.
You can set a new data quota for a device at any time.
At an initial state, when no data quota is set, the device is denied from using data services.
To top-up the data volume, you need to retrieve the remaining volume, increase it by the top-up volume, and set it as the new quota volume.

We have deprecated throttling as an action on quota exhaustion and the associated peak throughput parameter.
These were decommissioned as of December 9, 2024.\*\*

The following parameters can be configured:

* `status` (required) - The status of the quota:
  * 1: `ACTIVE`
  * 2: `EXHAUSTED`
  * 3: `EXPIRED`
* `volume` - Remaining quota volume in MB
* `expiry_date` (required) - Timestamp when the quota expires and the device is denied from using further data services
* `auto_refill` (default: `0`) - Whether the quota should be refilled on a daily basis:
  * `0`: Disabled
  * `1`: Enabled
* `threshold_percentage` - The remaining quota percentage when the system generates a "Quota threshold reached" event
* `action_on_exhaustion`: Action executed after the quota is exhausted:
  * `id` (required) - Unique identifer of the action on quota exhaustion
    * `1`: Block
    * **DEPRECATED** `2`: Throttle

**Events**:
The system generates a "Quota used up" event if the data quota is completely depleted.
Then, the device is blocked from further consumption of data.
The quota object is included in the event details.

The device can instantly use data services after successfully making this API call.
You can set any timestamp with a future date.
This allows you to create data packages as required (for example, 1 hour, 24 hours, 7 days, or any other timeframe).

Reference: https://docs.iot.telia.lt/developers/api/endpoint/endpoint-quota-data-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.

- `status` (ApiV1EndpointEndpointIdQuotaDataPostRequestBodyContentApplicationJsonSchemaStatus, required)
- `volume` (float, required)
- `expiry_date` (string, required)
- `action_on_exhaustion` (ApiV1EndpointEndpointIdQuotaDataPostRequestBodyContentApplicationJsonSchemaActionOnExhaustion, required)
- `last_volume_added` (float, optional)
- `last_status_change_date` (string, optional)
- `auto_refill` (integer, optional)
- `threshold_volume` (float, optional)
- `threshold_percentage` (float, 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

### ApiV1EndpointEndpointIdQuotaDataPostRequestBodyContentApplicationJsonSchemaStatus

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

### ApiV1EndpointEndpointIdQuotaDataPostRequestBodyContentApplicationJsonSchemaActionOnExhaustion

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

## Examples

**Request**

```json
{
  "status": {
    "id": 1
  },
  "volume": 100,
  "expiry_date": "2025-01-17T08:47:00.000Z",
  "action_on_exhaustion": {
    "id": 1
  },
  "auto_refill": 1,
  "threshold_percentage": 15
}
```

**Response**

```json
{}
```

**SDK Code**

```python Create a 100 MB Data Quota
import requests

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

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

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

print(response.json())
```

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

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

```go Create a 100 MB Data Quota
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"status\": {\n    \"id\": 1\n  },\n  \"volume\": 100,\n  \"expiry_date\": \"2025-01-17T08:47:00.000Z\",\n  \"action_on_exhaustion\": {\n    \"id\": 1\n  },\n  \"auto_refill\": 1,\n  \"threshold_percentage\": 15\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 MB Data Quota
require 'uri'
require 'net/http'

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

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

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

```java Create a 100 MB Data 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/data")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"status\": {\n    \"id\": 1\n  },\n  \"volume\": 100,\n  \"expiry_date\": \"2025-01-17T08:47:00.000Z\",\n  \"action_on_exhaustion\": {\n    \"id\": 1\n  },\n  \"auto_refill\": 1,\n  \"threshold_percentage\": 15\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Create a 100 MB Data Quota
using RestSharp;

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

```swift Create a 100 MB Data Quota
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "status": ["id": 1],
  "volume": 100,
  "expiry_date": "2025-01-17T08:47:00.000Z",
  "action_on_exhaustion": ["id": 1],
  "auto_refill": 1,
  "threshold_percentage": 15
] 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/data")! 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()
```