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

# Migrate SIMs between Workspaces

POST https://iot.telia.lt/api/v1/sim/migration/workspace
Content-Type: application/json

Migrate SIMs from one Workspace to another.

## Requirements

* The calling user must have **Administrator** permissions on both the target and source Workspaces
* The target Workspace must be an enterprise Workspace
* Only 500 SIMs can be migrated per request
* You must provide exactly one of: `sims`, `iccids`, or `iccid_range`

This endpoint requires authentication with [user credentials](/developers/auth/user-credentials), as application tokens are scoped to a single Workspace.

## Behavior

* **Dry run mode**: The `dry_run` parameter defaults to `true`.
  Set it to `false` to execute the migration.
* **Activated SIMs**: SIMs in status `ACTIVATED` are automatically suspended during migration.
* **Attached devices**: If SIMs are attached to devices, set `auto_detach_devices: true` or the request fails.

The request fails if one or more SIMs don't meet the requirements for migration.
Check the `errors` array in the response for details.

Reference: https://docs.iot.telia.lt/developers/api/sim/sim-migration-workspace

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

- `target_workspace` (ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaTargetWorkspace, required) — Target Workspace to migrate SIMs to. Must be an enterprise Workspace. The calling user must have **Administrator** permissions on the target Workspace.
- `sims` (list of ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaSimsItems, optional) — List of SIMs to migrate. The list may include up to 500 SIMs. Cannot be used in combination with the `iccids` or the `iccid_range` field.
- `iccids` (list of string, optional) — List of ICCIDs to migrate. All SIMs must belong to the source Workspace. The list may include up to 500 ICCIDs. Cannot be used in combination with the `sims` or the `iccid_range` field.
- `iccid_range` (ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaIccidRange, optional) — ICCID range to migrate. All SIMs within the range must belong to the source Workspace. The range may include up to 500 ICCIDs. The `end` value must be greater than or equal to the `start` value. Cannot be used in combination with the `iccids` or the `sims` field.
- `allowed_sim_statuses` (list of ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaAllowedSimStatusesItems, optional) — List of SIM statuses that are allowed to be migrated. The request is rejected if a SIM has a status that isn't in this list. If not provided, all SIM statuses are allowed.
- `dry_run` (boolean, optional, default: true) — Controls whether the migration is executed or simulated. * `true` (default): Returns a preview of SIMs that would be migrated without making changes * `false`: Executes the migration Always test with a dry run first to verify the SIMs match your expectations.
- `auto_detach_devices` (boolean, optional) — If set to `true`, the SIMs automatically detach from the devices before being migrated. Otherwise, the request is rejected if one or more SIMs are attached to devices.

## Response

### 200

Successful migration request. If `dry_run` was set to `false`, the migration is processed. If `dry_run` was set to `true`, the response contains a summary of the changes that would be executed.

- `sim_count` (double, required) — The amount of SIMs to be migrated
- `dry_run` (boolean, required) — The `dry_run` option specified in the request
- `target_workspace` (ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaTargetWorkspace, required) — The `target_workspace` specified in the request
- `auto_detach_devices` (boolean, required) — The `auto_detach_devices` option specified in the request
- `sims` (list of ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItems, required) — List of SIMs to be migrated
- `allowed_sim_statuses` (list of ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaAllowedSimStatusesItems, optional) — The `allowed_sim_statuses` option specified in the request

## Errors

### 400 Bad Request Error

The request is malformed. Common causes: - Exceeds the maximum count of 500 SIMs - Multiple SIM identifiers provided (only one of `sims`, `iccids`, or `iccid_range` is allowed) - Invalid ICCID format (must be exactly 19 digits) - ICCID range `end` value is less than `start`

- `any`

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

### 404 Not Found Error

One or more SIMs or the target Workspace couldn't be found or are inaccessible.

- `any`

### 409 Conflict Error

One or more SIMs don't meet the requirements for migration. The response includes an `errors` array with details about which SIMs failed and why. | Error Code | Message | Resolution | |------------|---------|------------| | 1502 | SIM(s) attached to devices | Set `auto_detach_devices: true` to automatically detach SIMs before migration | | 1503 | SIM(s) in disallowed status | Adjust the `allowed_sim_statuses` filter or change the SIM status before migrating | | 1504 | No admin access on source workspace | Request **Administrator** permissions on the source Workspace | | 1505 | Migration between Brazilian and non-Brazilian workspaces is not allowed | This is a regulatory restriction and cannot be bypassed |

- `status_code` (double, required) — HTTP status code (409)
- `message` (string, required) — Summary error message
- `errors` (list of ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItems, required) — List of specific errors grouped by error type

## Types

### ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaTargetWorkspace

Target Workspace to migrate SIMs to. Must be an enterprise Workspace. The calling user must have **Administrator** permissions on the target Workspace.

- `id` (double, required)

### ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaSimsItems

- `id` (double, required)

### ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaIccidRange

ICCID range to migrate. All SIMs within the range must belong to the source Workspace. The range may include up to 500 ICCIDs. The `end` value must be greater than or equal to the `start` value. Cannot be used in combination with the `iccids` or the `sims` field.

- `start` (string, required) — First ICCID in the range (19-digit format).
- `end` (string, required) — Last ICCID in the range (19-digit format). Must be greater than or equal to `start`.

### ApiV1SimMigrationWorkspacePostRequestBodyContentApplicationJsonSchemaAllowedSimStatusesItems

- `id` (double, required)

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaTargetWorkspace

The `target_workspace` specified in the request

- `id` (double, required)
- `name` (string, required)

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItems

- `status` (ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItemsStatus, required)
- `id` (double, optional)
- `iccid` (string, optional)
- `iccid_with_luhn` (string, optional)
- `endpoint` (ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItemsEndpoint, optional) — The device currently attached to the SIM. Defaults to `undefined` if no device is attached.
- `source_workspace` (ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItemsSourceWorkspace, optional) — The source Workspace of the SIM

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaAllowedSimStatusesItems

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

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItems

- `error_code` (double, required) — Specific error code (1502, 1503, 1504, or 1505)
- `message` (string, required) — Error message describing the issue
- `sims` (list of ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItems, required) — List of SIMs affected by this specific error

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItemsStatus

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

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItemsEndpoint

The device currently attached to the SIM. Defaults to `undefined` if no device is attached.

- `id` (double, required)
- `name` (string, required)

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaSimsItemsSourceWorkspace

The source Workspace of the SIM

- `id` (double, required)
- `name` (string, required)

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItems

- `id` (double, optional)
- `iccid` (string, optional)
- `iccid_with_luhn` (string, optional)
- `endpoint` (ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItemsEndpoint, optional) — The device currently attached to the SIM. Only present if a device is attached.
- `status` (ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItemsStatus, optional)
- `source_workspace` (ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItemsSourceWorkspace, optional) — The source Workspace of the SIM

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItemsEndpoint

The device currently attached to the SIM. Only present if a device is attached.

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

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItemsStatus

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

### ApiV1SimMigrationWorkspacePostResponsesContentApplicationJsonSchemaErrorsItemsSimsItemsSourceWorkspace

The source Workspace of the SIM

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

## Examples

### SIM_SimMigrationWorkspace_example

**Response**

```json
{
  "sim_count": 2,
  "dry_run": false,
  "target_workspace": {
    "id": 98,
    "name": "My Target Workspace"
  },
  "auto_detach_devices": true,
  "sims": [
    {
      "status": {
        "id": 1,
        "description": "ACTIVATED"
      },
      "id": 1,
      "iccid": "1234567890123456789",
      "iccid_with_luhn": "12345678901234567891",
      "endpoint": {
        "id": 75,
        "name": "My Device"
      },
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    },
    {
      "status": {
        "id": 2,
        "description": "SUSPENDED"
      },
      "id": 24,
      "iccid": "1234567890123456790",
      "iccid_with_luhn": "12345678901234567901",
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    }
  ]
}
```

**SDK Code**

```python SIM_SimMigrationWorkspace_example
import requests

url = "https://iot.telia.lt/api/v1/sim/migration/workspace"

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

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

print(response.json())
```

```javascript SIM_SimMigrationWorkspace_example
const url = 'https://iot.telia.lt/api/v1/sim/migration/workspace';
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 SIM_SimMigrationWorkspace_example
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/sim/migration/workspace"

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

url = URI("https://iot.telia.lt/api/v1/sim/migration/workspace")

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

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp SIM_SimMigrationWorkspace_example
using RestSharp;

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

```swift SIM_SimMigrationWorkspace_example
import Foundation

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

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

### By ICCID

**Request**

```json
{
  "target_workspace": {
    "id": 1
  },
  "iccids": [
    "1234567890123456789",
    "1234567890123456790"
  ],
  "allowed_sim_statuses": [
    {
      "id": 1
    }
  ],
  "dry_run": false,
  "auto_detach_devices": true
}
```

**Response**

```json
{
  "sim_count": 2,
  "dry_run": false,
  "target_workspace": {
    "id": 98,
    "name": "My Target Workspace"
  },
  "auto_detach_devices": true,
  "sims": [
    {
      "status": {
        "id": 1,
        "description": "ACTIVATED"
      },
      "id": 1,
      "iccid": "1234567890123456789",
      "iccid_with_luhn": "12345678901234567891",
      "endpoint": {
        "id": 75,
        "name": "My Device"
      },
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    },
    {
      "status": {
        "id": 2,
        "description": "SUSPENDED"
      },
      "id": 24,
      "iccid": "1234567890123456790",
      "iccid_with_luhn": "12345678901234567901",
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    }
  ]
}
```

**SDK Code**

```python By ICCID
import requests

url = "https://iot.telia.lt/api/v1/sim/migration/workspace"

payload = {
    "target_workspace": { "id": 1 },
    "iccids": ["1234567890123456789", "1234567890123456790"],
    "allowed_sim_statuses": [{ "id": 1 }],
    "dry_run": False,
    "auto_detach_devices": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript By ICCID
const url = 'https://iot.telia.lt/api/v1/sim/migration/workspace';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"target_workspace":{"id":1},"iccids":["1234567890123456789","1234567890123456790"],"allowed_sim_statuses":[{"id":1}],"dry_run":false,"auto_detach_devices":true}'
};

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

```go By ICCID
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/sim/migration/workspace"

	payload := strings.NewReader("{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccids\": [\n    \"1234567890123456789\",\n    \"1234567890123456790\"\n  ],\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 1\n    }\n  ],\n  \"dry_run\": false,\n  \"auto_detach_devices\": true\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 By ICCID
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v1/sim/migration/workspace")

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  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccids\": [\n    \"1234567890123456789\",\n    \"1234567890123456790\"\n  ],\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 1\n    }\n  ],\n  \"dry_run\": false,\n  \"auto_detach_devices\": true\n}"

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

```java By ICCID
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v1/sim/migration/workspace")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccids\": [\n    \"1234567890123456789\",\n    \"1234567890123456790\"\n  ],\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 1\n    }\n  ],\n  \"dry_run\": false,\n  \"auto_detach_devices\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v1/sim/migration/workspace', [
  'body' => '{
  "target_workspace": {
    "id": 1
  },
  "iccids": [
    "1234567890123456789",
    "1234567890123456790"
  ],
  "allowed_sim_statuses": [
    {
      "id": 1
    }
  ],
  "dry_run": false,
  "auto_detach_devices": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp By ICCID
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v1/sim/migration/workspace");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccids\": [\n    \"1234567890123456789\",\n    \"1234567890123456790\"\n  ],\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 1\n    }\n  ],\n  \"dry_run\": false,\n  \"auto_detach_devices\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift By ICCID
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "target_workspace": ["id": 1],
  "iccids": ["1234567890123456789", "1234567890123456790"],
  "allowed_sim_statuses": [["id": 1]],
  "dry_run": false,
  "auto_detach_devices": true
] as [String : Any]

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

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

### By SIM ID

**Request**

```json
{
  "target_workspace": {
    "id": 1
  },
  "sims": [
    {
      "id": 1
    },
    {
      "id": 24
    }
  ]
}
```

**Response**

```json
{
  "sim_count": 2,
  "dry_run": false,
  "target_workspace": {
    "id": 98,
    "name": "My Target Workspace"
  },
  "auto_detach_devices": true,
  "sims": [
    {
      "status": {
        "id": 1,
        "description": "ACTIVATED"
      },
      "id": 1,
      "iccid": "1234567890123456789",
      "iccid_with_luhn": "12345678901234567891",
      "endpoint": {
        "id": 75,
        "name": "My Device"
      },
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    },
    {
      "status": {
        "id": 2,
        "description": "SUSPENDED"
      },
      "id": 24,
      "iccid": "1234567890123456790",
      "iccid_with_luhn": "12345678901234567901",
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    }
  ]
}
```

**SDK Code**

```python By SIM ID
import requests

url = "https://iot.telia.lt/api/v1/sim/migration/workspace"

payload = {
    "target_workspace": { "id": 1 },
    "sims": [{ "id": 1 }, { "id": 24 }]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript By SIM ID
const url = 'https://iot.telia.lt/api/v1/sim/migration/workspace';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"target_workspace":{"id":1},"sims":[{"id":1},{"id":24}]}'
};

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

```go By SIM ID
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/sim/migration/workspace"

	payload := strings.NewReader("{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"sims\": [\n    {\n      \"id\": 1\n    },\n    {\n      \"id\": 24\n    }\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 By SIM ID
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v1/sim/migration/workspace")

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  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"sims\": [\n    {\n      \"id\": 1\n    },\n    {\n      \"id\": 24\n    }\n  ]\n}"

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

```java By SIM ID
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v1/sim/migration/workspace")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"sims\": [\n    {\n      \"id\": 1\n    },\n    {\n      \"id\": 24\n    }\n  ]\n}")
  .asString();
```

```php By SIM ID
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v1/sim/migration/workspace', [
  'body' => '{
  "target_workspace": {
    "id": 1
  },
  "sims": [
    {
      "id": 1
    },
    {
      "id": 24
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp By SIM ID
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v1/sim/migration/workspace");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"sims\": [\n    {\n      \"id\": 1\n    },\n    {\n      \"id\": 24\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift By SIM ID
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "target_workspace": ["id": 1],
  "sims": [["id": 1], ["id": 24]]
] as [String : Any]

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

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

### By ICCID range

**Request**

```json
{
  "target_workspace": {
    "id": 1
  },
  "iccid_range": {
    "start": "1234567890123456789",
    "end": "1234567890123456790"
  },
  "allowed_sim_statuses": [
    {
      "id": 2
    }
  ],
  "dry_run": true,
  "auto_detach_devices": false
}
```

**Response**

```json
{
  "sim_count": 2,
  "dry_run": false,
  "target_workspace": {
    "id": 98,
    "name": "My Target Workspace"
  },
  "auto_detach_devices": true,
  "sims": [
    {
      "status": {
        "id": 1,
        "description": "ACTIVATED"
      },
      "id": 1,
      "iccid": "1234567890123456789",
      "iccid_with_luhn": "12345678901234567891",
      "endpoint": {
        "id": 75,
        "name": "My Device"
      },
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    },
    {
      "status": {
        "id": 2,
        "description": "SUSPENDED"
      },
      "id": 24,
      "iccid": "1234567890123456790",
      "iccid_with_luhn": "12345678901234567901",
      "source_workspace": {
        "id": 53,
        "name": "My Workspace"
      }
    }
  ]
}
```

**SDK Code**

```python By ICCID range
import requests

url = "https://iot.telia.lt/api/v1/sim/migration/workspace"

payload = {
    "target_workspace": { "id": 1 },
    "iccid_range": {
        "start": "1234567890123456789",
        "end": "1234567890123456790"
    },
    "allowed_sim_statuses": [{ "id": 2 }],
    "dry_run": True,
    "auto_detach_devices": False
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript By ICCID range
const url = 'https://iot.telia.lt/api/v1/sim/migration/workspace';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"target_workspace":{"id":1},"iccid_range":{"start":"1234567890123456789","end":"1234567890123456790"},"allowed_sim_statuses":[{"id":2}],"dry_run":true,"auto_detach_devices":false}'
};

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

```go By ICCID range
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/sim/migration/workspace"

	payload := strings.NewReader("{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccid_range\": {\n    \"start\": \"1234567890123456789\",\n    \"end\": \"1234567890123456790\"\n  },\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 2\n    }\n  ],\n  \"dry_run\": true,\n  \"auto_detach_devices\": false\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 By ICCID range
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v1/sim/migration/workspace")

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  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccid_range\": {\n    \"start\": \"1234567890123456789\",\n    \"end\": \"1234567890123456790\"\n  },\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 2\n    }\n  ],\n  \"dry_run\": true,\n  \"auto_detach_devices\": false\n}"

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

```java By ICCID range
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://iot.telia.lt/api/v1/sim/migration/workspace")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccid_range\": {\n    \"start\": \"1234567890123456789\",\n    \"end\": \"1234567890123456790\"\n  },\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 2\n    }\n  ],\n  \"dry_run\": true,\n  \"auto_detach_devices\": false\n}")
  .asString();
```

```php By ICCID range
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://iot.telia.lt/api/v1/sim/migration/workspace', [
  'body' => '{
  "target_workspace": {
    "id": 1
  },
  "iccid_range": {
    "start": "1234567890123456789",
    "end": "1234567890123456790"
  },
  "allowed_sim_statuses": [
    {
      "id": 2
    }
  ],
  "dry_run": true,
  "auto_detach_devices": false
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp By ICCID range
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v1/sim/migration/workspace");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"target_workspace\": {\n    \"id\": 1\n  },\n  \"iccid_range\": {\n    \"start\": \"1234567890123456789\",\n    \"end\": \"1234567890123456790\"\n  },\n  \"allowed_sim_statuses\": [\n    {\n      \"id\": 2\n    }\n  ],\n  \"dry_run\": true,\n  \"auto_detach_devices\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift By ICCID range
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "target_workspace": ["id": 1],
  "iccid_range": [
    "start": "1234567890123456789",
    "end": "1234567890123456790"
  ],
  "allowed_sim_statuses": [["id": 2]],
  "dry_run": true,
  "auto_detach_devices": false
] as [String : Any]

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

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