> 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://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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: rest
  version: 1.0.0
paths:
  /api/v1/billing/subscription/preview:
    post:
      operationId: preview-subscription-change
      summary: Preview a subscription change
      description: >-
        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.
      tags:
        - subpackage_billing
      parameters:
        - name: Authorization
          in: header
          description: 'Your Dial API key, sent as `Authorization: Bearer sk_live_...`'
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The previewed charge for the proposed change.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Billing_previewSubscriptionChange_Response_200
        '400':
          description: The request body failed validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                interval:
                  $ref: >-
                    #/components/schemas/ApiV1BillingSubscriptionPreviewPostRequestBodyContentApplicationJsonSchemaInterval
                  description: Target billing interval. Defaults to the current interval.
                quantity:
                  type: integer
                  description: >-
                    Target number count (one unit per phone number). Defaults to
                    the current quantity.
                promotionCode:
                  type: string
                  description: >-
                    Optional customer-facing promotion code; the preview
                    reflects the discount it produces.
servers:
  - url: https://getdial.ai
    description: Dial API (provisional host)
components:
  schemas:
    ApiV1BillingSubscriptionPreviewPostRequestBodyContentApplicationJsonSchemaInterval:
      type: string
      enum:
        - monthly
        - annual
      description: Target billing interval. Defaults to the current interval.
      title: >-
        ApiV1BillingSubscriptionPreviewPostRequestBodyContentApplicationJsonSchemaInterval
    ApiV1BillingSubscriptionPreviewPostResponsesContentApplicationJsonSchemaLinesItems:
      type: object
      properties:
        description:
          type: string
        amountCents:
          type: integer
      title: >-
        ApiV1BillingSubscriptionPreviewPostResponsesContentApplicationJsonSchemaLinesItems
    Billing_previewSubscriptionChange_Response_200:
      type: object
      properties:
        amountDueCents:
          type: integer
          description: >-
            Amount that would be charged today, in USD cents (prorations and
            discounts included).
        currency:
          type: string
        prorationDate:
          type: integer
          description: >-
            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:
          type: integer
          description: >-
            Total discount applied by the coupon, in USD cents (0 when no coupon
            or no effect).
        lines:
          type: array
          items:
            $ref: >-
              #/components/schemas/ApiV1BillingSubscriptionPreviewPostResponsesContentApplicationJsonSchemaLinesItems
          description: >-
            The invoice preview line items (proration credits appear as
            negatives).
      title: Billing_previewSubscriptionChange_Response_200
    ErrorError:
      oneOf:
        - type: string
        - type: object
          additionalProperties:
            description: Any type
      description: An error message, or a validation-error object for 400 responses.
      title: ErrorError
    Error:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorError'
          description: An error message, or a validation-error object for 400 responses.
      title: Error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your Dial API key, sent as `Authorization: Bearer sk_live_...`'

```

## 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://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://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://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://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://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://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://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://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()
```