> 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 device-to-device mode of a service profile

GET https://cdn.emnify.net/api/v1/service_profile/{service_profile_id}/d2d

Required permissions Beta [Learn more](/developers/api-guidelines/permissions#how-permissions-work)`ServiceProfile.D2d` + `Get`Roles: AdministratorRetrieves the device-to-device (D2D) mode of a service profile.
D2D controls whether devices assigned to the service profile can exchange IP traffic with other devices in the same organization and region.A service profile that has never been configured returns `disabled` with `modified_at` set to `null`.Device-to-device is opt-in and enabled per organization.
Until it's enabled for your organization, requests return `403`.
To request access, contact emnify support.

Reference: https://docs.emnify.com/developers/api/service-profiles/service-profile-device-to-device-get

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

- `service_profile_id` (integer, required) — The numeric ID of a service profile.

### Query parameters

- `org_id` (long, optional) — Numeric ID of a child organization to act on. Omit to use your own organization. Returns `403` if the organization isn't a child of yours. The service profile must belong to that organization, and device-to-device must be enabled for it.

## Response

### 200

Success

- `service_profile_id` (integer, required) — ID of the service profile.
- `mode` (enum, required) — Device-to-device mode of the service profile: - `disabled` (default): Traffic between devices is dropped. - `enabled`: Traffic is delivered directly between devices, as long as the service profiles of both devices have device-to-device enabled. - `forward_to_backend`: Traffic between devices is routed through your Cloud Connect backend, for example so your own firewall can inspect it.
  - Allowed values: `disabled`, `enabled`, `forward_to_backend`
- `modified_at` (string, required, nullable) — When the mode was last changed. `null` if device-to-device has never been configured on the service profile.
- `warnings` (list of string, optional) — Advisory messages about the configuration. Only present in `PUT` responses, and only when there's something to report, for example after setting `forward_to_backend`.

## Errors

### 401 Unauthorized Error

Missing or invalid Authorization header.

- `any`

### 403 Forbidden Error

Your user doesn't have the required permission, device-to-device isn't enabled for the organization, or `org_id` isn't a child organization.

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

### 404 Not Found Error

Service profile not found, or it belongs to another organization.

- `any`

### 422 Unprocessable Entity Error

`service_profile_id` or `org_id` isn't a number.

- `any`

## Examples

### Never Configured

**Response**

```json
{
  "service_profile_id": 1234,
  "mode": "disabled",
  "modified_at": null
}
```

**SDK Code**

```python Never Configured
import requests

url = "https://cdn.emnify.net/api/v1/service_profile/1234/d2d"

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

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

print(response.json())
```

```javascript Never Configured
const url = 'https://cdn.emnify.net/api/v1/service_profile/1234/d2d';
const options = {method: 'GET', 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 Never Configured
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/service_profile/1234/d2d"

	req, _ := http.NewRequest("GET", 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 Never Configured
require 'uri'
require 'net/http'

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

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

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

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

```java Never Configured
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://cdn.emnify.net/api/v1/service_profile/1234/d2d")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://cdn.emnify.net/api/v1/service_profile/1234/d2d', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Never Configured
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/service_profile/1234/d2d");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Never Configured
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://cdn.emnify.net/api/v1/service_profile/1234/d2d")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```

### Enabled

**Response**

```json
{
  "service_profile_id": 1234,
  "mode": "enabled",
  "modified_at": "2026-08-04T09:15:22Z"
}
```

**SDK Code**

```python Enabled
import requests

url = "https://cdn.emnify.net/api/v1/service_profile/1234/d2d"

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

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

print(response.json())
```

```javascript Enabled
const url = 'https://cdn.emnify.net/api/v1/service_profile/1234/d2d';
const options = {method: 'GET', 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 Enabled
package main

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

func main() {

	url := "https://cdn.emnify.net/api/v1/service_profile/1234/d2d"

	req, _ := http.NewRequest("GET", 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 Enabled
require 'uri'
require 'net/http'

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

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

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

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

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

HttpResponse<String> response = Unirest.get("https://cdn.emnify.net/api/v1/service_profile/1234/d2d")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://cdn.emnify.net/api/v1/service_profile/1234/d2d', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Enabled
using RestSharp;

var client = new RestClient("https://cdn.emnify.net/api/v1/service_profile/1234/d2d");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Enabled
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://cdn.emnify.net/api/v1/service_profile/1234/d2d")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```