> 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.emnify.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.emnify.com/_mcp/server.

# Add a data limit to a service profile

POST https://cdn.emnify.net/api/v1/service_profile/{profile_id}/traffic_limit
Content-Type: application/json

Required permissions Beta [Learn more](/developers/api-guidelines/permissions#how-permissions-work)`ServiceProfile.TrafficLimit` + `Create`Roles: Administrator UserAdds a data limit to a service profile.
A data limit defines how much data each device with this service profile can use in a period.
Use data limits to manage data usage and avoid overage charges.In the request, set the service type, period, volume, and warning percentage.Only users with the **User** or **Administrator** role can use this endpoint.
Adding a data limit that already exists returns a `409` error.To change a data limit, delete it and add a new one.
The exception is a temporary [traffic limit extension](/developers/api/endpoint/create-endpoint-traffic-limit-extension), which you can create without deleting the data limit.

Reference: https://docs.emnify.com/developers/api/service-profiles/add-service-profile-traffic-limit

## 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

- `profile_id` (double, required) — Numeric ID of the service profile.

### Body (application/json)

This endpoint expects an object.

- `service` (ApiV1ServiceProfileProfileIdTrafficLimitPostRequestBodyContentApplicationJsonSchemaService, required) — Service type to which the limit applies. The only supported service type is `Data`, which has an ID of `38`.
- `satellite_only` (boolean, required) — Which data traffic the limit counts. This field is required, even if your devices don't use satellite connectivity. If you're unsure which value to use, set it to `false`. - `false`: the limit counts data over all radio access technology (RAT) types. Use this for most data limits. - `true`: the limit only counts data over satellite RAT types. Satellite data costs more than other data, so use this to set a separate limit for it. A service profile can have one data limit with `false` and one with `true` for each service.
- `period` (ApiV1ServiceProfileProfileIdTrafficLimitPostRequestBodyContentApplicationJsonSchemaPeriod, required) — Period of the limit. The only supported period is `Monthly`, which uses calendar months and has an ID of `2`. The limit resets at 00:00 UTC on the first day of each month.
- `volume` (long, required) — Limit threshold in the atomic units of the service type, which is bytes for data. It's the amount of data each device can use in each period before it reaches the limit.
- `warning_percent` (integer, optional) — Percentage of the limit volume at which the system sends an Endpoint data traffic limit warning event (event type `65`, see [Event type object](/developers/reference/events#event-type-object)). For example, if you set it to `80`, the system sends the event when a device has used 80% of the limit volume.

## Response

### 201

The API created the data limit. The response contains the new data limit.

- `id` (double, required) — ID of the data limit.
- `service` (ServiceProfileTrafficLimitService, required) — Service type to which the limit applies.
- `satellite_only` (boolean, required) — Which data traffic the limit counts. If `false`, the limit counts data over all radio access technology (RAT) types. If `true`, it only counts data over satellite RAT types. Satellite data costs more than other data.
- `period` (ServiceProfileTrafficLimitPeriod, required) — Period of the limit.
- `volume` (long, required) — Limit threshold in the atomic units of the service type, which is bytes for data.
- `warning_percent` (integer, optional) — Percentage of the limit volume at which the system sends an Endpoint data traffic limit warning event (event type `65`, see [Event type object](/developers/reference/events#event-type-object)). Only present if the data limit has a warning percentage.

## Errors

### 400 Bad Request Error

The request body is invalid, for example because a required field is missing or a value isn't supported. `message` lists each invalid field.

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

### 403 Forbidden Error

The service profile doesn't exist or doesn't belong to your organization, or your role doesn't include the permission to manage data limits.

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

### 409 Conflict Error

The service profile already has a data limit for this service with the same `satellite_only` value. To change a data limit, delete it and add a new one.

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

## Types

### ApiV1ServiceProfileProfileIdTrafficLimitPostRequestBodyContentApplicationJsonSchemaService

Service type to which the limit applies. The only supported service type is `Data`, which has an ID of `38`.

- `id` (enum, optional)
  - Allowed values: `38`

### ApiV1ServiceProfileProfileIdTrafficLimitPostRequestBodyContentApplicationJsonSchemaPeriod

Period of the limit. The only supported period is `Monthly`, which uses calendar months and has an ID of `2`. The limit resets at 00:00 UTC on the first day of each month.

- `id` (enum, optional)
  - Allowed values: `2`

### ServiceProfileTrafficLimitService

Service type to which the limit applies.

- `id` (double, optional)
- `description` (string, optional)

### ServiceProfileTrafficLimitPeriod

Period of the limit.

- `id` (double, optional)
- `time_units` (double, optional)
- `unit` (string, optional)

## Examples

**Request**

```json
{
  "service": {
    "id": 38
  },
  "satellite_only": false,
  "period": {
    "id": 2
  },
  "volume": 1000000000,
  "warning_percent": 80
}
```

**Response**

```json
{
  "id": 15109,
  "service": {
    "id": 38,
    "description": "Data"
  },
  "satellite_only": false,
  "period": {
    "id": 2,
    "time_units": 1,
    "unit": "month"
  },
  "volume": 1000000000,
  "warning_percent": 80
}
```

**SDK Code**

```python Monthly Data Limit
import requests

url = "https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit"

payload = {
    "service": { "id": 38 },
    "satellite_only": False,
    "period": { "id": 2 },
    "volume": 1000000000,
    "warning_percent": 80
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Monthly Data Limit
const url = 'https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"service":{"id":38},"satellite_only":false,"period":{"id":2},"volume":1000000000,"warning_percent":80}'
};

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

```go Monthly Data Limit
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit"

	payload := strings.NewReader("{\n  \"service\": {\n    \"id\": 38\n  },\n  \"satellite_only\": false,\n  \"period\": {\n    \"id\": 2\n  },\n  \"volume\": 1000000000,\n  \"warning_percent\": 80\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 Monthly Data Limit
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit")

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  \"service\": {\n    \"id\": 38\n  },\n  \"satellite_only\": false,\n  \"period\": {\n    \"id\": 2\n  },\n  \"volume\": 1000000000,\n  \"warning_percent\": 80\n}"

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

```java Monthly Data Limit
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"service\": {\n    \"id\": 38\n  },\n  \"satellite_only\": false,\n  \"period\": {\n    \"id\": 2\n  },\n  \"volume\": 1000000000,\n  \"warning_percent\": 80\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit', [
  'body' => '{
  "service": {
    "id": 38
  },
  "satellite_only": false,
  "period": {
    "id": 2
  },
  "volume": 1000000000,
  "warning_percent": 80
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Monthly Data Limit
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"service\": {\n    \"id\": 38\n  },\n  \"satellite_only\": false,\n  \"period\": {\n    \"id\": 2\n  },\n  \"volume\": 1000000000,\n  \"warning_percent\": 80\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Monthly Data Limit
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "service": ["id": 38],
  "satellite_only": false,
  "period": ["id": 2],
  "volume": 1000000000,
  "warning_percent": 80
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://cdn.emnify.net/api/v1/service_profile/1.1/traffic_limit")! 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()
```