> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.messageblue.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.messageblue.ai/_mcp/server.

# Reassign an agent to a different account

POST https://api.messageblue.ai/agents/{phoneNumber}/reassign
Content-Type: application/json

Moves ownership of the agent to the target accountId in the request body. Caller must currently own the agent, or provide a valid X-Admin-Token to force reassignment.

Reference: https://docs.messageblue.ai/api-reference/agents/reassign-agent-to-account

## Authentication

- `X-App-Id` header (required) — Your MessageBlue App ID, sent in clear on every request. It is paired with request signing: each request is also signed with your App Secret (see the **Authentication** tag). The App Secret itself is NEVER transmitted — it is only the HMAC signing key.

## Servers

- `https://api.messageblue.ai` (Production, default)
- `http://localhost:8080` (Local development)

## Request

### Path parameters

- `phoneNumber` (string, required)

### Body (application/json)

This endpoint expects an AgentReassignRequest.

- `accountId` (string, required) — Target account that should own the agent after reassignment

## Response

### 200

Agent reassigned

- `ok` (boolean, required)
- `data` (AgentReassignResponseData, required) — Endpoint-specific payload wrapped in a standard success envelope.
- `meta` (ResponseMeta, required)

## Errors

### 400 Bad Request Error

Validation error

- `ok` (boolean, required)
- `error` (ErrorResponseError, required)

### 401 Unauthorized Error

Unauthorized

- `ok` (boolean, required)
- `error` (ErrorResponseError, required)

### 403 Forbidden Error

Caller does not own the agent

- `ok` (boolean, required)
- `error` (ErrorResponseError, required)

### 404 Not Found Error

Agent is not assigned yet

- `ok` (boolean, required)
- `error` (ErrorResponseError, required)

### 500 Internal Server Error

Failed to reassign agent

- `ok` (boolean, required)
- `error` (ErrorResponseError, required)

## Types

### AgentReassignResponseData

Endpoint-specific payload wrapped in a standard success envelope.

- `phoneNumber` (string, required)
- `accountId` (string, required) — New owning accountId
- `previousAccountId` (string, optional, nullable) — Previous owning accountId, if any
- `changed` (boolean, optional)
- `agent` (AgentInfo, optional)

### ResponseMeta

- `requestId` (string, required)
- `timestamp` (datetime, required)

### ErrorResponseError

- `code` (string, required)
- `message` (string, required)
- `requestId` (string, required)
- `details` (ErrorResponseErrorDetails, optional) — Field validation errors (array) or domain-specific context (object).

### AgentInfo

- `number` (string, optional)
- `machineId` (string, optional)
- `lastSeen` (double, optional)
- `status` (enum, optional)
  - Allowed values: `online`, `offline`, `blocked`
- `blocked` (boolean, optional)
- `blockedReason` (string, optional, nullable)
- `blockedAt` (double, optional, nullable)
- `meta` (AgentInfoMeta, optional)
- `registeredAt` (double, optional, nullable)
- `gatewayInstance` (string, optional, nullable)
- `accountId` (string, optional, nullable)

### ErrorResponseErrorDetails

Field validation errors (array) or domain-specific context (object).

- list of FieldError
- map from string to any

### AgentInfoMeta

### FieldError

- `field` (string, required)
- `issue` (string, required)
- `message` (string, required)

## Examples

**Request**

```json
{
  "accountId": "acct_target_123"
}
```

**Response**

```json
{
  "ok": true,
  "data": {
    "phoneNumber": "+14155550123",
    "accountId": "string",
    "previousAccountId": "string",
    "changed": true,
    "agent": {
      "number": "string",
      "machineId": "string",
      "lastSeen": 1.1,
      "status": "online",
      "blocked": true,
      "blockedReason": "string",
      "blockedAt": 1.1,
      "meta": {},
      "registeredAt": 1.1,
      "gatewayInstance": "string",
      "accountId": "string"
    }
  },
  "meta": {
    "requestId": "550e8400-e29b-41d4-a716-446655440000",
    "timestamp": "2026-07-10T06:00:00.000Z"
  }
}
```

**SDK Code**

```python Agents_reassignAgentToAccount_example
import requests

url = "https://api.messageblue.ai/agents/%2B14155550123/reassign"

payload = { "accountId": "acct_target_123" }
headers = {
    "X-App-Id": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Agents_reassignAgentToAccount_example
const url = 'https://api.messageblue.ai/agents/%2B14155550123/reassign';
const options = {
  method: 'POST',
  headers: {'X-App-Id': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"accountId":"acct_target_123"}'
};

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

```go Agents_reassignAgentToAccount_example
package main

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

func main() {

	url := "https://api.messageblue.ai/agents/%2B14155550123/reassign"

	payload := strings.NewReader("{\n  \"accountId\": \"acct_target_123\"\n}")

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

	req.Header.Add("X-App-Id", "<apiKey>")
	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 Agents_reassignAgentToAccount_example
require 'uri'
require 'net/http'

url = URI("https://api.messageblue.ai/agents/%2B14155550123/reassign")

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

request = Net::HTTP::Post.new(url)
request["X-App-Id"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"accountId\": \"acct_target_123\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.messageblue.ai/agents/%2B14155550123/reassign")
  .header("X-App-Id", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"accountId\": \"acct_target_123\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.messageblue.ai/agents/%2B14155550123/reassign', [
  'body' => '{
  "accountId": "acct_target_123"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-App-Id' => '<apiKey>',
  ],
]);

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

```csharp Agents_reassignAgentToAccount_example
using RestSharp;

var client = new RestClient("https://api.messageblue.ai/agents/%2B14155550123/reassign");
var request = new RestRequest(Method.POST);
request.AddHeader("X-App-Id", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"accountId\": \"acct_target_123\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Agents_reassignAgentToAccount_example
import Foundation

let headers = [
  "X-App-Id": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["accountId": "acct_target_123"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.messageblue.ai/agents/%2B14155550123/reassign")! 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()
```