> 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 MFA key

POST https://iot.telia.lt/api/v1/user/mfa
Content-Type: application/json

Generate and store a MFA key for the requesting user. After this call, the MFA key has the status `activation pending` and must be activated through a separate call (`/api/v1/user/mfa/{id}`).

You must provide following fields with this request:

* `type` (Object required)
  * `id` (Number)
* `password` (String required) - User password

The **MFA key** object returned by the server contains the following properties:

* `id` (Integer) - The unique ID of this MFA key
* `status` (Object) ID (Integer) - Id of status of this MFA key
  * `description` (String) - description of the status
* `type` (Object) ID (Integer) - Id of type of this MFA key
  * `description` (String) - description of the type
* `secret_key` (String) - Secret key (encoded in Base32) for this MFA key, will be displayed only on creation
* `otpauth` (String) - Secret key as a URI encoded for QR codes, will be displayed only on creation
* `creation_date` (Timestamp) - Timestamp when this MFA key was created - type: ISO 8601 timestamp format
* `activation_date` (Timestamp) - Timestamp when this MFA key was activated - type: ISO 8601 timestamp format

Reference: https://docs.iot.telia.lt/developers/api/authentication/post-mfa

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

- `type` (ApiV1UserMfaPostRequestBodyContentApplicationJsonSchemaType, required)
- `password` (string, required)

## Response

### 200

Success

- `id` (double, optional)
- `status` (ApiV1UserMfaPostResponsesContentApplicationJsonSchemaStatus, optional)
- `type` (ApiV1UserMfaPostResponsesContentApplicationJsonSchemaType, optional)
- `secret_key` (string, optional)
- `otpauth` (string, optional)
- `creation_date` (string, optional)

## Errors

### 409 Conflict Error

Unexpected error in API call. See HTTP response body for details.

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

### 422 Unprocessable Entity Error

Unprocessable Entity. See HTTP response body for details.

- `error_code` (integer, optional)
- `error_token` (string, optional)
- `message` (string, optional)
- `errors` (list of ApiV1UserMfaPostResponsesContentApplicationJsonSchemaErrorsItems, optional)

## Types

### ApiV1UserMfaPostRequestBodyContentApplicationJsonSchemaType

### ApiV1UserMfaPostResponsesContentApplicationJsonSchemaStatus

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

### ApiV1UserMfaPostResponsesContentApplicationJsonSchemaType

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

### ApiV1UserMfaPostResponsesContentApplicationJsonSchemaErrorsItems

## Examples

### Authentication_postMfa_example

**Response**

```json
{
  "id": 44,
  "status": {
    "id": 0,
    "description": "Activation Pending"
  },
  "type": {
    "id": 0,
    "description": "Time-Based One-Time Password"
  },
  "secret_key": "YZP7UN4EMN6LK2UYYDCTBNH4ZVXVEJ7C",
  "otpauth": "otpauth://totp/org:user@org.com?secret=YZP7UN4EMN6LK2UYYDCTBNH4ZVXVEJ7C&issuer=myorg&digits=6&period=30",
  "creation_date": "2020-02-03T14:04:03.000Z"
}
```

**SDK Code**

```python Authentication_postMfa_example
import requests

url = "https://iot.telia.lt/api/v1/user/mfa"

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

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

print(response.json())
```

```javascript Authentication_postMfa_example
const url = 'https://iot.telia.lt/api/v1/user/mfa';
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 Authentication_postMfa_example
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/user/mfa"

	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 Authentication_postMfa_example
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v1/user/mfa")

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 Authentication_postMfa_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Authentication_postMfa_example
using RestSharp;

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

```swift Authentication_postMfa_example
import Foundation

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

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

### Created

**Request**

```json
{
  "type": {
    "id": 0
  },
  "password": "2f2f2f2f2f2f2f2f2f2f2f2f"
}
```

**Response**

```json
{
  "id": 44,
  "status": {
    "id": 0,
    "description": "Activation Pending"
  },
  "type": {
    "id": 0,
    "description": "Time-Based One-Time Password"
  },
  "secret_key": "YZP7UN4EMN6LK2UYYDCTBNH4ZVXVEJ7C",
  "otpauth": "otpauth://totp/org:user@org.com?secret=YZP7UN4EMN6LK2UYYDCTBNH4ZVXVEJ7C&issuer=myorg&digits=6&period=30",
  "creation_date": "2020-02-03T14:04:03.000Z"
}
```

**SDK Code**

```python Created
import requests

url = "https://iot.telia.lt/api/v1/user/mfa"

payload = {
    "type": { "id": 0 },
    "password": "2f2f2f2f2f2f2f2f2f2f2f2f"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Created
const url = 'https://iot.telia.lt/api/v1/user/mfa';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"type":{"id":0},"password":"2f2f2f2f2f2f2f2f2f2f2f2f"}'
};

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

```go Created
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/user/mfa"

	payload := strings.NewReader("{\n  \"type\": {\n    \"id\": 0\n  },\n  \"password\": \"2f2f2f2f2f2f2f2f2f2f2f2f\"\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 Created
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v1/user/mfa")

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  \"type\": {\n    \"id\": 0\n  },\n  \"password\": \"2f2f2f2f2f2f2f2f2f2f2f2f\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v1/user/mfa")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"type\": {\n    \"id\": 0\n  },\n  \"password\": \"2f2f2f2f2f2f2f2f2f2f2f2f\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v1/user/mfa', [
  'body' => '{
  "type": {
    "id": 0
  },
  "password": "2f2f2f2f2f2f2f2f2f2f2f2f"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Created
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v1/user/mfa");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"type\": {\n    \"id\": 0\n  },\n  \"password\": \"2f2f2f2f2f2f2f2f2f2f2f2f\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Created
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "type": ["id": 0],
  "password": "2f2f2f2f2f2f2f2f2f2f2f2f"
] as [String : Any]

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

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