> This is a page from the ElevenLabs documentation. For an index of the documentation, fetch https://elevenlabs.io/docs/llms.txt.

# サブスクリプションと請求

各顧客のワークスペースは、販売するティアのサブスクリプションを1つ持つことができます。すべてのワークスペースの請求書は、リセラーのカードで支払われます。ワークスペースの現在のサブスクリプションは、`has_payment_issue`とともに`workspaces.list`の`subscription`フィールドに格納されています。

## プランを割り当てる

まだプランがないワークスペースをプランに加入させます。`billing_period`には`monthly_period`（デフォルト）または`annual_period`を指定します。

```python
from elevenlabs import ElevenLabs

elevenlabs = ElevenLabs()

elevenlabs.reception.subscriptions.assign(
    "8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7",
    tier_id="smbtier_4401k8r2c6hxe9tq3vz7m5wd1nb0",
    billing_period="annual_period",
    idempotency_key="assign-8f1c2a7e-2026-11-03",
)
```

```typescript
import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

const elevenlabs = new ElevenLabsClient();

await elevenlabs.reception.subscriptions.assign("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7", {
  tierId: "smbtier_4401k8r2c6hxe9tq3vz7m5wd1nb0",
  billingPeriod: "annual_period",
  idempotencyKey: "assign-8f1c2a7e-2026-11-03",
});
```

```bash
curl -X POST "https://api.elevenlabs.io/v1/reception/reseller/workspaces/8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7/subscription" \
  -H "xi-api-key: $ELEVENLABS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tier_id": "smbtier_4401k8r2c6hxe9tq3vz7m5wd1nb0", "billing_period": "annual_period", "idempotency_key": "assign-8f1c2a7e-2026-11-03" }'
```

プランを割り当てたり変更したりするたびに、生成した`idempotency_key`を送信します。リクエストがタイムアウトした場合も、同じキーで再試行すれば、ワークスペースが重複してプランに加入したり、二重に請求されたりすることはありません。

`has_payment_issue`が`true`の間は、プランの割り当てや変更が拒否されます。再試行する前に、未払いの請求書を顧客に提示するか、その`pay_url`から支払ってください。

## プランを変更する

`subscriptions.change`は`assign`と同じリクエストボディを受け取ります。

* アップグレードはすぐに適用されます。
* ダウングレードまたは同レベルのティアへの変更は、請求期間の終了時に適用されます。それまでは、サブスクリプションの`pending_downgrade_tier`に新しいティア、`pending_downgrade_at_unix`に適用日が表示されます。

ワークスペースを現在のティアのまま維持するには、`subscriptions.cancel_pending_downgrade`で予定されているダウングレードを取り消します。

```python
elevenlabs.reception.subscriptions.change(
    "8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7",
    tier_id="smbtier_4401k8r2d3pfw8ys6bq2n9ja7kc5",
)

elevenlabs.reception.subscriptions.cancel_pending_downgrade("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7")
```

```typescript
await elevenlabs.reception.subscriptions.change("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7", {
  tierId: "smbtier_4401k8r2d3pfw8ys6bq2n9ja7kc5",
});

await elevenlabs.reception.subscriptions.cancelPendingDowngrade("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7");
```

```bash
curl -X PATCH "https://api.elevenlabs.io/v1/reception/reseller/workspaces/8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7/subscription" \
  -H "xi-api-key: $ELEVENLABS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tier_id": "smbtier_4401k8r2d3pfw8ys6bq2n9ja7kc5" }'

curl -X POST "https://api.elevenlabs.io/v1/reception/reseller/workspaces/8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7/subscription/cancel-downgrade" \
  -H "xi-api-key: $ELEVENLABS_API_KEY"
```

ダウングレードが適用されると、新しいプランの上限を超える受付担当者と電話番号は無効になり、チーム人数の上限を超えるメンバーは一時停止されます。

## プランを終了する

`subscriptions.unassign`は、現在の請求期間の終了時にサブスクリプションを終了します。それまでは、`cancel_at_unix`に終了日時が表示されます。`subscriptions.restore`で解約を取り消すと、プランは通常どおり更新されます。

```python
elevenlabs.reception.subscriptions.unassign("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7")

elevenlabs.reception.subscriptions.restore("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7")
```

```typescript
await elevenlabs.reception.subscriptions.unassign("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7");

await elevenlabs.reception.subscriptions.restore("8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7");
```

```bash
curl -X DELETE "https://api.elevenlabs.io/v1/reception/reseller/workspaces/8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7/subscription" \
  -H "xi-api-key: $ELEVENLABS_API_KEY"

curl -X POST "https://api.elevenlabs.io/v1/reception/reseller/workspaces/8f1c2a7e4b9d4e6fa3c5b2d1e0f9a8b7/subscription/restore" \
  -H "xi-api-key: $ELEVENLABS_API_KEY"
```

## 請求書

カードへの各請求は、1つのワークスペースの請求書に対する支払いです。`billing.list_invoices`は、請求書を新しい順に1ページずつ返します。請求書の`status`は次のいずれかです。

| ステータス  | 意味                                      |
| ------ | --------------------------------------- |
| `paid` | カードへの請求が完了しています。                        |
| `open` | カードへの請求を再試行中です。`pay_url`は支払いページへのリンクです。 |
| `void` | 再試行回数の上限に達し、ワークスペースのプランが終了しました。         |

`billing.get_invoice`では、請求書の`lines`も返されます。`amount_cents`が負の明細は日割り計算によるクレジットで、明細の合計は常に請求額と一致します。

```python
page = elevenlabs.reception.billing.list_invoices(page_size=25)
for invoice in page.invoices:
    print(invoice.workspace_name, invoice.status, invoice.amount_cents / 100, invoice.currency)

detail = elevenlabs.reception.billing.get_invoice(page.invoices[0].invoice_id)
for line in detail.lines:
    print(line.kind, line.description, line.amount_cents)
```

```typescript
const page = await elevenlabs.reception.billing.listInvoices({ pageSize: 25 });
for (const invoice of page.invoices) {
  console.log(invoice.workspaceName, invoice.status, invoice.amountCents / 100, invoice.currency);
}

const detail = await elevenlabs.reception.billing.getInvoice(page.invoices[0].invoiceId);
for (const line of detail.lines) {
  console.log(line.kind, line.description, line.amountCents);
}
```

```bash
curl "https://api.elevenlabs.io/v1/reception/reseller/billing/invoices?page_size=25" \
  -H "xi-api-key: $ELEVENLABS_API_KEY"
```

## 今後の支払い

`billing.list_upcoming_payments`は、各ワークスペースの次回更新時の支払い見込みを、期日が近い順に返します。`plan_usd`は更新時に前払いで請求されるプラン料金です。ダウングレードが予定されている場合は、ダウングレード後のティアの料金になります。`overage_so_far_usd`は、現在の請求期間で、これまでに含まれる分数を超えて利用した分の料金です。この料金は更新時に請求され、それまでは利用に応じて増え続けます。

```python
upcoming = elevenlabs.reception.billing.list_upcoming_payments()
for payment in upcoming.payments:
    print(
        payment.workspace_name,
        payment.subscription.billing_period_end_unix,
        payment.plan_usd + payment.overage_so_far_usd,
    )
```

```typescript
const upcoming = await elevenlabs.reception.billing.listUpcomingPayments();
for (const payment of upcoming.payments) {
  console.log(
    payment.workspaceName,
    payment.subscription.billingPeriodEndUnix,
    payment.planUsd + payment.overageSoFarUsd
  );
}
```

```bash
curl "https://api.elevenlabs.io/v1/reception/reseller/billing/upcoming" \
  -H "xi-api-key: $ELEVENLABS_API_KEY"
```