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

# Retrieve authentication token

POST https://cdn.emnify.net/api/v1/authenticate
Content-Type: application/json

Required permissions Beta [Learn more](/developers/api-guidelines/permissions#how-permissions-work)Public endpoint. No permission required.Returns a [JSON Web Token (JWT)](/developers/auth/jwts) `auth_token` for authenticating further requests to the API.This API path has a rate limit of 100 requests per IP in a 5-minute window.
Make sure to store your authentication token to avoid hitting this limit.
For more information, see [Rate limits](/developers/api-guidelines/rate-limits).### Multi-factor authentication flowWhen multi-factor authentication (MFA) is enabled for a user account:1) **Initial login**: Send your username and SHA-1 hashed password.
   If MFA is enabled and the device isn't trusted, you receive an `mfa_token` instead of `auth_token` in the response and a one-time password (OTP) via email.
2) **MFA verification**: Send the `mfa_token` with the 6-digit OTP `code`.
   Optionally include `trusted_device` information to skip MFA for 90 days.
3) **Subsequent logins**: If you included a trusted device fingerprint during verification, send your username and SHA-1 hashed password with the `fingerprint` to bypass MFA.For more information, see [Multi-factor authentication](/developers/auth/multi-factor-authentication).

Reference: https://docs.emnify.com/developers/api/authentication/authenticate

## Request

### Body (application/json)

This endpoint expects an object.

- `application_token` (string, optional) — Application token for authentication
- `username` (string, optional) — Username for user credentials authentication
- `password` (string, optional) — User password. Must be SHA-1 hashed when authenticating with user credentials.
- `fingerprint` (string, optional) — Device fingerprint for trusted device authentication (skips MFA)
- `refresh_token` (string, optional) — Refresh token to obtain a new `auth_token`
- `mfa_token` (string, optional) — MFA token received when MFA is enabled
- `code` (string, optional) — 6-digit one-time password (OTP) for MFA verification
- `trusted_device` (ApiV1AuthenticatePostRequestBodyContentApplicationJsonSchemaTrustedDevice, optional) — Device information to register as trusted (90-day MFA exemption)

## Response

### 200

Successful Authentication Request

- `auth_token` (string, optional) — JWT authentication token (returned for successful authentication)
- `refresh_token` (string, optional) — Refresh token (returned with `auth_token` for user credentials auth)
- `mfa_token` (string, optional) — MFA token (returned instead of `auth_token` when MFA is enabled and device isn't trusted)

## Errors

### 400 Bad Request Error

The request body is malformed or fails validation.

- `any`

### 401 Unauthorized Error

The response body is empty for most authentication failures (invalid credentials, suspended or deleted user, etc.). When account lockout is triggered after three consecutive failed authentication attempts, the response body contains the `TooManyRequests` error and further attempts are blocked for five minutes.

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

### 404 Not Found Error

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

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

## Types

### ApiV1AuthenticatePostRequestBodyContentApplicationJsonSchemaTrustedDevice

Device information to register as trusted (90-day MFA exemption)

- `fingerprint` (string, optional) — Unique device identifier
- `operating_system` (string, optional) — Device operating system
- `browser` (string, optional) — Browser name
- `name` (string, optional) — Optional name for the device

## Examples

### Application Token Authentication

**Request**

```json
{
  "application_token": "5cCI6IkpXVCJ9.."
}
```

**Response**

```json
{
  "auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

**SDK Code**

```python Application Token Authentication
import requests

url = "https://cdn.emnify.net/api/v1/authenticate"

payload = { "application_token": "5cCI6IkpXVCJ9.." }
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Application Token Authentication
const url = 'https://cdn.emnify.net/api/v1/authenticate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"application_token":"5cCI6IkpXVCJ9.."}'
};

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

```go Application Token Authentication
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/authenticate"

	payload := strings.NewReader("{\n  \"application_token\": \"5cCI6IkpXVCJ9..\"\n}")

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

	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 Application Token Authentication
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/authenticate")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"application_token\": \"5cCI6IkpXVCJ9..\"\n}"

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

```java Application Token Authentication
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/authenticate")
  .header("Content-Type", "application/json")
  .body("{\n  \"application_token\": \"5cCI6IkpXVCJ9..\"\n}")
  .asString();
```

```php Application Token Authentication
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/authenticate', [
  'body' => '{
  "application_token": "5cCI6IkpXVCJ9.."
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Application Token Authentication
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/authenticate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"application_token\": \"5cCI6IkpXVCJ9..\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Application Token Authentication
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["application_token": "5cCI6IkpXVCJ9.."] as [String : Any]

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

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

### User Credentials Authentication

**Request**

```json
{
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd"
}
```

**Response**

```json
{
  "auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

**SDK Code**

```python User Credentials Authentication
import requests

url = "https://cdn.emnify.net/api/v1/authenticate"

payload = {
    "username": "user@service.org",
    "password": "8Y8knYSkeyYV23kd"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript User Credentials Authentication
const url = 'https://cdn.emnify.net/api/v1/authenticate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"username":"user@service.org","password":"8Y8knYSkeyYV23kd"}'
};

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

```go User Credentials Authentication
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/authenticate"

	payload := strings.NewReader("{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}")

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

	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 User Credentials Authentication
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/authenticate")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}"

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

```java User Credentials Authentication
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/authenticate")
  .header("Content-Type", "application/json")
  .body("{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}")
  .asString();
```

```php User Credentials Authentication
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/authenticate', [
  'body' => '{
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp User Credentials Authentication
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/authenticate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift User Credentials Authentication
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd"
] as [String : Any]

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

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

### Refresh Authentication - Renew Expired Auth Token

**Request**

```json
{
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

**Response**

```json
{
  "auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

**SDK Code**

```python Refresh Authentication - Renew Expired Auth Token
import requests

url = "https://cdn.emnify.net/api/v1/authenticate"

payload = { "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript Refresh Authentication - Renew Expired Auth Token
const url = 'https://cdn.emnify.net/api/v1/authenticate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"refresh_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}'
};

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

```go Refresh Authentication - Renew Expired Auth Token
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/authenticate"

	payload := strings.NewReader("{\n  \"refresh_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\"\n}")

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

	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 Refresh Authentication - Renew Expired Auth Token
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/authenticate")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"refresh_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\"\n}"

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

```java Refresh Authentication - Renew Expired Auth Token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/authenticate")
  .header("Content-Type", "application/json")
  .body("{\n  \"refresh_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\"\n}")
  .asString();
```

```php Refresh Authentication - Renew Expired Auth Token
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/authenticate', [
  'body' => '{
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Refresh Authentication - Renew Expired Auth Token
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/authenticate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"refresh_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Refresh Authentication - Renew Expired Auth Token
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."] as [String : Any]

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

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

### User Authentication with MFA Enabled - Receive MFA Token

**Request**

```json
{
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd"
}
```

**Response**

```json
{
  "mfa_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

**SDK Code**

```python User Authentication with MFA Enabled - Receive MFA Token
import requests

url = "https://cdn.emnify.net/api/v1/authenticate"

payload = {
    "username": "user@service.org",
    "password": "8Y8knYSkeyYV23kd"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript User Authentication with MFA Enabled - Receive MFA Token
const url = 'https://cdn.emnify.net/api/v1/authenticate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"username":"user@service.org","password":"8Y8knYSkeyYV23kd"}'
};

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

```go User Authentication with MFA Enabled - Receive MFA Token
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/authenticate"

	payload := strings.NewReader("{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}")

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

	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 User Authentication with MFA Enabled - Receive MFA Token
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/authenticate")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}"

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

```java User Authentication with MFA Enabled - Receive MFA Token
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/authenticate")
  .header("Content-Type", "application/json")
  .body("{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}")
  .asString();
```

```php User Authentication with MFA Enabled - Receive MFA Token
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/authenticate', [
  'body' => '{
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp User Authentication with MFA Enabled - Receive MFA Token
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/authenticate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift User Authentication with MFA Enabled - Receive MFA Token
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd"
] as [String : Any]

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

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

### MFA Code Verification - Trust Device for 90 Days

**Request**

```json
{
  "mfa_token": "zI1NiIsInR5cCI6IkpXV...",
  "code": "123456",
  "trusted_device": {
    "fingerprint": "zI1NiIsInR5cCI6IkpXV",
    "operating_system": "Ubuntu 16.04.2 LTS (Xenial)",
    "browser": "Mozilla Firefox"
  }
}
```

**Response**

```json
{
  "auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

**SDK Code**

```python MFA Code Verification - Trust Device for 90 Days
import requests

url = "https://cdn.emnify.net/api/v1/authenticate"

payload = {
    "mfa_token": "zI1NiIsInR5cCI6IkpXV...",
    "code": "123456",
    "trusted_device": {
        "fingerprint": "zI1NiIsInR5cCI6IkpXV",
        "operating_system": "Ubuntu 16.04.2 LTS (Xenial)",
        "browser": "Mozilla Firefox"
    }
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript MFA Code Verification - Trust Device for 90 Days
const url = 'https://cdn.emnify.net/api/v1/authenticate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"mfa_token":"zI1NiIsInR5cCI6IkpXV...","code":"123456","trusted_device":{"fingerprint":"zI1NiIsInR5cCI6IkpXV","operating_system":"Ubuntu 16.04.2 LTS (Xenial)","browser":"Mozilla Firefox"}}'
};

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

```go MFA Code Verification - Trust Device for 90 Days
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/authenticate"

	payload := strings.NewReader("{\n  \"mfa_token\": \"zI1NiIsInR5cCI6IkpXV...\",\n  \"code\": \"123456\",\n  \"trusted_device\": {\n    \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\",\n    \"operating_system\": \"Ubuntu 16.04.2 LTS (Xenial)\",\n    \"browser\": \"Mozilla Firefox\"\n  }\n}")

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

	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 MFA Code Verification - Trust Device for 90 Days
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/authenticate")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"mfa_token\": \"zI1NiIsInR5cCI6IkpXV...\",\n  \"code\": \"123456\",\n  \"trusted_device\": {\n    \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\",\n    \"operating_system\": \"Ubuntu 16.04.2 LTS (Xenial)\",\n    \"browser\": \"Mozilla Firefox\"\n  }\n}"

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

```java MFA Code Verification - Trust Device for 90 Days
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/authenticate")
  .header("Content-Type", "application/json")
  .body("{\n  \"mfa_token\": \"zI1NiIsInR5cCI6IkpXV...\",\n  \"code\": \"123456\",\n  \"trusted_device\": {\n    \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\",\n    \"operating_system\": \"Ubuntu 16.04.2 LTS (Xenial)\",\n    \"browser\": \"Mozilla Firefox\"\n  }\n}")
  .asString();
```

```php MFA Code Verification - Trust Device for 90 Days
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/authenticate', [
  'body' => '{
  "mfa_token": "zI1NiIsInR5cCI6IkpXV...",
  "code": "123456",
  "trusted_device": {
    "fingerprint": "zI1NiIsInR5cCI6IkpXV",
    "operating_system": "Ubuntu 16.04.2 LTS (Xenial)",
    "browser": "Mozilla Firefox"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp MFA Code Verification - Trust Device for 90 Days
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/authenticate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"mfa_token\": \"zI1NiIsInR5cCI6IkpXV...\",\n  \"code\": \"123456\",\n  \"trusted_device\": {\n    \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\",\n    \"operating_system\": \"Ubuntu 16.04.2 LTS (Xenial)\",\n    \"browser\": \"Mozilla Firefox\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift MFA Code Verification - Trust Device for 90 Days
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "mfa_token": "zI1NiIsInR5cCI6IkpXV...",
  "code": "123456",
  "trusted_device": [
    "fingerprint": "zI1NiIsInR5cCI6IkpXV",
    "operating_system": "Ubuntu 16.04.2 LTS (Xenial)",
    "browser": "Mozilla Firefox"
  ]
] as [String : Any]

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

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

### User Authentication with Trusted Device Fingerprint - Skip MFA

**Request**

```json
{
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd",
  "fingerprint": "zI1NiIsInR5cCI6IkpXV"
}
```

**Response**

```json
{
  "auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

**SDK Code**

```python User Authentication with Trusted Device Fingerprint - Skip MFA
import requests

url = "https://cdn.emnify.net/api/v1/authenticate"

payload = {
    "username": "user@service.org",
    "password": "8Y8knYSkeyYV23kd",
    "fingerprint": "zI1NiIsInR5cCI6IkpXV"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript User Authentication with Trusted Device Fingerprint - Skip MFA
const url = 'https://cdn.emnify.net/api/v1/authenticate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"username":"user@service.org","password":"8Y8knYSkeyYV23kd","fingerprint":"zI1NiIsInR5cCI6IkpXV"}'
};

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

```go User Authentication with Trusted Device Fingerprint - Skip MFA
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/authenticate"

	payload := strings.NewReader("{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\",\n  \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\"\n}")

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

	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 User Authentication with Trusted Device Fingerprint - Skip MFA
require 'uri'
require 'net/http'

url = URI("https://cdn.emnify.net/api/v1/authenticate")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\",\n  \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\"\n}"

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

```java User Authentication with Trusted Device Fingerprint - Skip MFA
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://cdn.emnify.net/api/v1/authenticate")
  .header("Content-Type", "application/json")
  .body("{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\",\n  \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\"\n}")
  .asString();
```

```php User Authentication with Trusted Device Fingerprint - Skip MFA
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://cdn.emnify.net/api/v1/authenticate', [
  'body' => '{
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd",
  "fingerprint": "zI1NiIsInR5cCI6IkpXV"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp User Authentication with Trusted Device Fingerprint - Skip MFA
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/authenticate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"username\": \"user@service.org\",\n  \"password\": \"8Y8knYSkeyYV23kd\",\n  \"fingerprint\": \"zI1NiIsInR5cCI6IkpXV\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift User Authentication with Trusted Device Fingerprint - Skip MFA
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "username": "user@service.org",
  "password": "8Y8knYSkeyYV23kd",
  "fingerprint": "zI1NiIsInR5cCI6IkpXV"
] as [String : Any]

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

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