# Move a subscription

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Moves a subscription from one [customer](/docs/api/customers) to another asynchronously. All related resources such as `[unbilled_charge](/docs/api/unbilled_charges)`, `[invoice](/docs/api/invoices)`, `[credit_note](/docs/api/credit_notes)`, and `[transaction](/docs/api/transactions)` are also moved to the new customer.

After moving, Chargebee adds a `[comment](/docs/api/comments)` to the original `customer` resource to document the move, including the `[to_customer_id](/docs/api/subscriptions/move-a-subscription#to_customer_id)` and the `id`s of all the resources transferred to the destination customer.

**Warning**

-   If `[auto_collection](/docs/api/subscriptions/create-subscription-for-items#auto_collection)` is `on`, it might fail after this operation. Refer to the warning in `[copy_payment_source](/docs/api/subscriptions/move-a-subscription#copy_payment_source)` for details.
-   During the time that it takes for the operation to complete, no modifications are allowed on the source customer, the destination customer, and the subscription.
-   After moving a subscription, the change does not reflect in Chargebee Billing's [accounting integrations](https://www.chargebee.com/docs/2.0/finance-integration-index.html) or in [Chargebee RevRec](https://www.chargebee.com/docs/revrec/chargebee-billing-features.html).
-   This API will return an error when [multi-frequency billing](/docs/api/subscriptions) is enabled.

#### Prerequisites[](#prerequisites)

-   The subscription should not be part of a `customer` resource that is within an account hierarchy [relationship](/docs/api/customers/customer-object#relationship).
-   There must be no invoices with the [statuses](/docs/api/invoices/invoice-object#status) `payment_due`, `pending`, or `posted` associated with the subscription.
-   The site must have [consolidated invoicing](https://www.chargebee.com/docs/2.0/consolidated-invoicing.html) disabled.
-   There should be no consolidated invoices linked to the subscription.
-   No `credit_note` resources with the [statuses](/docs/api/credit_notes/credit_note-object#status) `adjusted` or `refund_due` should be associated with the subscription.
-   With muti business entity (MBE) enabled on your site, moving a subscription to a customer belonging to another business entity is not allowed.

#### Asynchronous operation[](#asynchronous-operation)

If the above prerequisites are met, the API call returns a `200 OK` response containing the `subscription` resource as is. However, the actual move operation can take up to **five** minutes to complete.

To know whether the operation was successful, we recommend that you watch for the `[subscription_changed](/docs/api/events)` event and see if `subscription.customer_id` has changed.

#### Limitations[](#limitations)

-   Subscriptions cannot be moved on the same calendar day as their renewal. For instance, if a renewal is scheduled for 2 PM on April 10, 2024, the endpoint is restricted from 12 AM on April 10, 2024, until the renewal is completed.
-   After moving a subscription, the change does not reflect in Chargebee Billing's [accounting integrations](https://www.chargebee.com/docs/2.0/finance-integration-index.html) or in [Chargebee RevRec](https://www.chargebee.com/docs/revrec/chargebee-billing-features.html).

**Note**: Resources linked to the original customer such as `unbilled_charge` , `invoice` , `credit_note` , and `transaction` but **not** linked to the subscription being moved, are **not** moved to the destination customer by this operation.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/__test__8asukSOXdwKMPo/move \
     -u {site_api_key}:\
     -d to_customer_id="__test__KyVnHhSBWlCdz2cv" \
     -d copy_payment_source="true"
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.Move("__test__8asukSOXdwKMPo")
		.ToCustomerId("__test__KyVnHhSBWlCdz2cv")
		.CopyPaymentSource(true)
		.Request();

Subscription subscription = result.Subscription;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    subscriptionAction "github.com/chargebee/chargebee-go/v3/actions/subscription"
    "github.com/chargebee/chargebee-go/v3/models/subscription"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.Move("__test__8asukSOXdwKMPo", &subscription.MoveRequestParams{
        ToCustomerId : "__test__KyVnHhSBWlCdz2cv",
        CopyPaymentSource : chargebee.Bool(true),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.SubscriptionMoveRequest{
    ToCustomerId : "__test__KyVnHhSBWlCdz2cv",
    CopyPaymentSource : chargebee.Bool(true),
}
  res, err := client.Subscription.Move("__test__8asukSOXdwKMPo", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Subscription := res.Subscription
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.move("__test__8asukSOXdwKMPo")
            .toCustomerId("__test__KyVnHhSBWlCdz2cv")
            .copyPaymentSource(true)
            .request();

        Subscription subscription = result.subscription();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.subscription.Subscription;
import com.chargebee.v4.models.subscription.params.SubscriptionMoveParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionMoveResponse;

public class SubscriptionMove {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        SubscriptionMoveParams params = SubscriptionMoveParams.builder()
            .toCustomerId("__test__KyVnHhSBWlCdz2cv")
            .copyPaymentSource(true)
            .build();

        SubscriptionMoveResponse response = client
            .subscriptions()
            .move("__test__8asukSOXdwKMPo", params);

        Subscription subscription = response.getSubscription();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.subscription.move("__test__8asukSOXdwKMPo", {
        to_customer_id: "__test__KyVnHhSBWlCdz2cv",
        copy_payment_source: true
    });

    console.log(result);
    const subscription = result.subscription;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->subscription()->move("__test__8asukSOXdwKMPo", [
    "to_customer_id" => "__test__KyVnHhSBWlCdz2cv",
    "copy_payment_source" => true
]);
$subscription = $result->subscription;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.move("__test__8asukSOXdwKMPo",
    cb_client.Subscription.MoveParams(
        to_customer_id="__test__KyVnHhSBWlCdz2cv",
        copy_payment_source=True
    )
)
subscription = response.subscription
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Subscription.move("__test__8asukSOXdwKMPo",{
  :to_customer_id => "__test__KyVnHhSBWlCdz2cv",
  :copy_payment_source => "true"
})

subscription = result.subscription
```

## Sample Response

```json
{
  "subscription": {
    "id": "__test__8asukSOXdwKMPo",
    "billing_period": 1,
    "billing_period_unit": "month",
    "customer_id": "fromcustomer",
    "status": "active",
    "current_term_start": 1710867589,
    "current_term_end": 1713545989,
    "next_billing_at": 1713545989,
    "created_at": 1710867589,
    "started_at": 1710867589,
    "activated_at": 1710867589,
    "created_from_ip": "44.196.151.224",
    "updated_at": 1710867590,
    "has_scheduled_changes": false,
    "channel": "web",
    "resource_version": 1710867590342,
    "deleted": false,
    "object": "subscription",
    "currency_code": "USD",
    "subscription_items": [
      {
        "item_price_id": "Basic-USD-Monthly",
        "item_type": "plan",
        "quantity": 1,
        "quantity_in_decimal": "1",
        "unit_price": 1000,
        "unit_price_in_decimal": "10.00",
        "amount": 1000,
        "amount_in_decimal": "10.00",
        "free_quantity": 0,
        "free_quantity_in_decimal": "0",
        "object": "subscription_item"
      },
      {..}
    ],
    "due_invoices_count": 0,
    "mrr": 0,
    "has_scheduled_advance_invoices": false
  },
  "customer": {
    "id": "fromcustomer",
    "auto_collection": "on",
    "net_term_days": 0,
    "allow_direct_debit": false,
    "created_at": 1709740187,
    "created_from_ip": "44.196.151.224",
    "taxability": "taxable",
    "updated_at": 1710867570,
    "pii_cleared": "active",
    "channel": "web",
    "resource_version": 1710867570674,
    "deleted": false,
    "object": "customer",
    "card_status": "valid",
    "promotional_credits": 0,
    "refundable_credits": 0,
    "excess_payments": 0,
    "unbilled_charges": 0,
    "preferred_currency_code": "USD",
    "mrr": 0,
    "primary_payment_source_id": "pm_15rQxzU7UHyFl3Z",
    "payment_method": {
      "object": "payment_method",
      "type": "card",
      "reference_id": "tok_15rQxzU7UHyFB3Y",
      "gateway": "chargebee",
      "gateway_account_id": "gw_15olFFT46Yzjv61q",
      "status": "valid"
    }
  },
  "card": {
    "status": "valid",
    "gateway": "chargebee",
    "gateway_account_id": "gw_15olFFT46Yzjv61q",
    "iin": "510510",
    "last4": "5100",
    "card_type": "mastercard",
    "funding_type": "prepaid",
    "expiry_month": 12,
    "expiry_year": 2025,
    "created_at": 1710867570,
    "updated_at": 1710867570,
    "ip_address": "44.196.151.224",
    "resource_version": 1710867570665,
    "object": "card",
    "masked_number": "************5100",
    "customer_id": "fromcustomer",
    "payment_source_id": "pm_15rQxzU7UHyFl3Z"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/subscriptions/{subscription-id}/move

## Input Parameters

- `to_customer_id` (required, string, max chars=50)
  Specifies the unique ID of the `customer` resource to which the subscription will be moved.
  
  **Note**: If there are [multiple business entities](/docs/api/advanced-features) , the `customer.business_entity_id` of the destination customer must match the `subscription.business_entity_id`.

- `copy_payment_source` (optional, boolean, default=false)
  **When `true`:** If the subscription has an [associated `payment_source`](/docs/api/subscriptions/subscription-object#payment_source_id):
  
  1.  A new duplicate copy of the `payment_source` resource is created.
  2.  This new copy of the payment source is linked to the subscription and the destination customer.
  
  **Note**: Deleting any copy of the `payment_source` also deletes the other copies and the details stored at the payment gateway.
  
  **When `false`:** No new payment source is created for the subscription. Moreover, if a `payment_source` is already [linked](/docs/api/subscriptions/subscription-object#payment_source_id) to the subscription, it gets removed, meaning the `subscription.payment_source_id` is cleared.
  
  **Warning**: When `copy_payment_source` is `false` and if `[subscription.auto_collection](/docs/api/subscriptions/create-subscription-for-items#auto_collection)` is enabled, auto-collection will fail, in turn preventing subscription renewal. To prevent auto-collection failure, [link a payment source](/docs/api/subscriptions/override-billing-profile) to the subscription after this operation.

## Returns

- `subscription` (Subscription object)
  Resource object representing subscription
