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

# Create an application token

POST https://iot.telia.lt/api/v2/application_token
Content-Type: application/json

Creates an application token for the requesting organisation and returns it.

The token itself is only available from this response and cannot be retrieved later, so store it immediately.
The number of active tokens an organisation may hold is limited.


Reference: https://docs.iot.telia.lt/developers/api/application-tokens/create-application-token

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

### Body (application/json)

This endpoint expects an object.

- `name` (string, required) — Name of the application token. Letters, digits, spaces and - _ . : / ( ) [ ] @ + # are allowed.
- `roles` (list of ApiV2ApplicationTokenPostRequestBodyContentApplicationJsonSchemaRolesItems, required) — The role granted to the token. Exactly one role is assigned, and the Support role can't be assigned to a token.
- `expiry_date` (string, required) — Expiry date in ISO 8601 format, either `2027-08-21T10:00:00.000Z` or `2027-08-21 10:00:00`. A value carrying no time zone is read as UTC. Must be at least one day in the future and at most 10 years in the future.
- `ip_restrictions` (list of string, optional) — IP addresses the token may connect from. Each entry is an IPv4 address, optionally in CIDR notation. Omit to allow any address.

## Response

### 201

Application token created

- `id` (integer, required) — Unique ID of this application token.
- `name` (string, required)
- `status` (ApiV2ApplicationTokenPostResponsesContentApplicationJsonSchemaStatus, required)
- `roles` (list of ApiV2ApplicationTokenPostResponsesContentApplicationJsonSchemaRolesItems, required) — The role granted to the token.
- `created_date` (string, required)
- `ip_restrictions` (list of ApiV2ApplicationTokenPostResponsesContentApplicationJsonSchemaIpRestrictionsItems, optional) — IP addresses the token may connect from. Absent where it may connect from any.
- `expiry_date` (string, optional) — Absent for a token created without one through the v1 API.
- `last_used_date` (string, optional) — Absent until the token has been used.
- `last_used_ip` (string, optional) — IP address the token was last used from.
- `created_by` (ApplicationTokenV2Actor, optional) — A user that acted on the token. Absent where an application token acted instead.
- `last_modified_date` (string, optional) — Absent until the token has been modified.
- `last_modified_by` (ApplicationTokenV2Actor, optional) — A user that acted on the token. Absent where an application token acted instead.
- `deleted_date` (string, optional) — Set only once the token has been deleted.
- `deleted_by` (ApplicationTokenV2Actor, optional) — A user that acted on the token. Absent where an application token acted instead.
- `token` (string, optional) — The application token. Store it immediately after creation, it is not retrievable afterwards.

## Errors

### 400 Bad Request Error

The payload is invalid or names an unknown role. See HTTP response body for details.

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

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

### 422 Unprocessable Entity Error

The organisation has reached its application token limit.

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

## Types

### ApiV2ApplicationTokenPostRequestBodyContentApplicationJsonSchemaRolesItems

- `id` (integer, required)

### ApiV2ApplicationTokenPostResponsesContentApplicationJsonSchemaStatus

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

### ApiV2ApplicationTokenPostResponsesContentApplicationJsonSchemaRolesItems

- `id` (integer, optional)
- `name` (string, optional)

### ApiV2ApplicationTokenPostResponsesContentApplicationJsonSchemaIpRestrictionsItems

- `id` (integer, optional)
- `ip_address` (string, optional) — An IP address in CIDR notation.

### ApplicationTokenV2Actor

A user that acted on the token. Absent where an application token acted instead.

- `id` (integer, required)
- `username` (string, required)
- `type` (ApplicationTokenV2ActorType, required)
- `name` (string, optional)

### ApplicationTokenV2ActorType

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

## Examples

### Application token created

**Response**

```json
{
  "id": 1234,
  "name": "CI pipeline token",
  "status": {
    "id": 1,
    "description": "ACTIVE"
  },
  "roles": [
    {
      "id": 3,
      "name": "Observer"
    }
  ],
  "created_date": "2026-08-21T10:00:00.000Z",
  "ip_restrictions": [
    {
      "id": 42,
      "ip_address": "10.10.1.0/24"
    }
  ],
  "expiry_date": "2027-08-21T10:00:00.000Z",
  "created_by": {
    "id": 10,
    "username": "john.doe@example.com",
    "type": {
      "id": 0,
      "description": "HUMAN"
    },
    "name": "John Doe"
  },
  "token": "eyJhbGciOiJIUzUxMiJ9..."
}
```

**SDK Code**

```python Application token created
import requests

url = "https://iot.telia.lt/api/v2/application_token"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript Application token created
const url = 'https://iot.telia.lt/api/v2/application_token';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

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

```go Application token created
package main

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

func main() {

	url := "https://iot.telia.lt/api/v2/application_token"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

```ruby Application token created
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/application_token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

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

```java Application token created
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/application_token")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/application_token', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Application token created
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/application_token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Application token created
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/application_token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### Complete

**Request**

```json
{
  "name": "CI pipeline token",
  "roles": [
    {
      "id": 3
    }
  ],
  "expiry_date": "2027-08-21T10:00:00.000Z",
  "ip_restrictions": [
    "192.168.0.1",
    "10.10.1.0/24"
  ]
}
```

**Response**

```json
{
  "id": 1234,
  "name": "CI pipeline token",
  "status": {
    "id": 1,
    "description": "ACTIVE"
  },
  "roles": [
    {
      "id": 3,
      "name": "Observer"
    }
  ],
  "created_date": "2026-08-21T10:00:00.000Z",
  "ip_restrictions": [
    {
      "id": 42,
      "ip_address": "10.10.1.0/24"
    }
  ],
  "expiry_date": "2027-08-21T10:00:00.000Z",
  "created_by": {
    "id": 10,
    "username": "john.doe@example.com",
    "type": {
      "id": 0,
      "description": "HUMAN"
    },
    "name": "John Doe"
  },
  "token": "eyJhbGciOiJIUzUxMiJ9..."
}
```

**SDK Code**

```python Complete
import requests

url = "https://iot.telia.lt/api/v2/application_token"

payload = {
    "name": "CI pipeline token",
    "roles": [{ "id": 3 }],
    "expiry_date": "2027-08-21T10:00:00.000Z",
    "ip_restrictions": ["192.168.0.1", "10.10.1.0/24"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Complete
const url = 'https://iot.telia.lt/api/v2/application_token';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"CI pipeline token","roles":[{"id":3}],"expiry_date":"2027-08-21T10:00:00.000Z","ip_restrictions":["192.168.0.1","10.10.1.0/24"]}'
};

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

```go Complete
package main

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

func main() {

	url := "https://iot.telia.lt/api/v2/application_token"

	payload := strings.NewReader("{\n  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\",\n  \"ip_restrictions\": [\n    \"192.168.0.1\",\n    \"10.10.1.0/24\"\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 Complete
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/application_token")

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  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\",\n  \"ip_restrictions\": [\n    \"192.168.0.1\",\n    \"10.10.1.0/24\"\n  ]\n}"

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

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

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/application_token")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\",\n  \"ip_restrictions\": [\n    \"192.168.0.1\",\n    \"10.10.1.0/24\"\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/application_token', [
  'body' => '{
  "name": "CI pipeline token",
  "roles": [
    {
      "id": 3
    }
  ],
  "expiry_date": "2027-08-21T10:00:00.000Z",
  "ip_restrictions": [
    "192.168.0.1",
    "10.10.1.0/24"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Complete
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/application_token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\",\n  \"ip_restrictions\": [\n    \"192.168.0.1\",\n    \"10.10.1.0/24\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Complete
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "CI pipeline token",
  "roles": [["id": 3]],
  "expiry_date": "2027-08-21T10:00:00.000Z",
  "ip_restrictions": ["192.168.0.1", "10.10.1.0/24"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/application_token")! 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()
```

### Minimal

**Request**

```json
{
  "name": "CI pipeline token",
  "roles": [
    {
      "id": 3
    }
  ],
  "expiry_date": "2027-08-21T10:00:00.000Z"
}
```

**Response**

```json
{
  "id": 1234,
  "name": "CI pipeline token",
  "status": {
    "id": 1,
    "description": "ACTIVE"
  },
  "roles": [
    {
      "id": 3,
      "name": "Observer"
    }
  ],
  "created_date": "2026-08-21T10:00:00.000Z",
  "ip_restrictions": [
    {
      "id": 42,
      "ip_address": "10.10.1.0/24"
    }
  ],
  "expiry_date": "2027-08-21T10:00:00.000Z",
  "created_by": {
    "id": 10,
    "username": "john.doe@example.com",
    "type": {
      "id": 0,
      "description": "HUMAN"
    },
    "name": "John Doe"
  },
  "token": "eyJhbGciOiJIUzUxMiJ9..."
}
```

**SDK Code**

```python Minimal
import requests

url = "https://iot.telia.lt/api/v2/application_token"

payload = {
    "name": "CI pipeline token",
    "roles": [{ "id": 3 }],
    "expiry_date": "2027-08-21T10:00:00.000Z"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Minimal
const url = 'https://iot.telia.lt/api/v2/application_token';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"CI pipeline token","roles":[{"id":3}],"expiry_date":"2027-08-21T10:00:00.000Z"}'
};

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

```go Minimal
package main

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

func main() {

	url := "https://iot.telia.lt/api/v2/application_token"

	payload := strings.NewReader("{\n  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\"\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 Minimal
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v2/application_token")

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  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v2/application_token")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v2/application_token', [
  'body' => '{
  "name": "CI pipeline token",
  "roles": [
    {
      "id": 3
    }
  ],
  "expiry_date": "2027-08-21T10:00:00.000Z"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Minimal
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v2/application_token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"CI pipeline token\",\n  \"roles\": [\n    {\n      \"id\": 3\n    }\n  ],\n  \"expiry_date\": \"2027-08-21T10:00:00.000Z\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Minimal
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "CI pipeline token",
  "roles": [["id": 3]],
  "expiry_date": "2027-08-21T10:00:00.000Z"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v2/application_token")! 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()
```