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

# Preview a subscription change

POST https://api.getdial.ai/api/v1/billing/subscription/preview
Content-Type: application/json

Computes the prorated amount that a subscription change would invoice **today**, without making any change or charge. Use it to show the customer what they'll pay before confirming an interval switch, a number addition, or a coupon application. The amounts come straight from Stripe's invoice preview — the same engine that bills the actual change.

Provide the target state: `interval` and/or `quantity` (each defaults to the subscription's current value when omitted), and an optional `promotionCode`. An invalid, expired, or inapplicable code is rejected with `400`. Requires an active subscription.

Reference: https://docs.getdial.ai/api-reference/rest-api/billing/preview-subscription-change

## Authentication

- `Authorization` header (bearer token, required) — Your Dial API key, sent as `Authorization: Bearer sk_live_...`

## Request

### Body (application/json)

- `interval` (enum, optional) — Target billing interval. Defaults to the current interval.
  - Allowed values: `monthly`, `annual`
- `quantity` (integer, optional) — Target number count (one unit per phone number). Defaults to the current quantity.
- `promotionCode` (string, optional) — Optional customer-facing promotion code; the preview reflects the discount it produces.

## Response

### 200

The previewed charge for the proposed change.

- `amountDueCents` (integer, optional) — Amount that would be charged today, in USD cents (prorations and discounts included).
- `currency` (string, optional)
- `prorationDate` (integer, optional) — Unix timestamp (seconds) the proration was calculated as of. Pass it back as `prorationDate` to the change endpoint to charge exactly this quoted amount.
- `discountCents` (integer, optional) — Total discount applied by the coupon, in USD cents (0 when no coupon or no effect).
- `lines` (list of object, optional) — The invoice preview line items (proration credits appear as negatives).
  - `description` (string, optional)
  - `amountCents` (integer, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "amountDueCents": 1500,
  "currency": "usd",
  "prorationDate": 1718000000,
  "discountCents": 300,
  "lines": [
    {
      "description": "Remaining time on 3 × Dial Subscription",
      "amountCents": 1800
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.getdial.ai/api/v1/billing/subscription/preview"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.getdial.ai/api/v1/billing/subscription/preview';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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

```go
package main

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

func main() {

	url := "https://api.getdial.ai/api/v1/billing/subscription/preview"

	payload := strings.NewReader("{}")

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

url = URI("https://api.getdial.ai/api/v1/billing/subscription/preview")

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 = "{}"

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

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

HttpResponse<String> response = Unirest.post("https://api.getdial.ai/api/v1/billing/subscription/preview")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getdial.ai/api/v1/billing/subscription/preview', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.getdial.ai/api/v1/billing/subscription/preview");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getdial.ai/api/v1/billing/subscription/preview")! 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()
```