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

# Get Billing

GET https://api.rray.app/v1/billing

Your current plan and billing state: the effective included volume and daily cap, any
overage ceiling, the current period's boundaries, and whether a plan change or a
cancellation is already scheduled for the next period. Read-only.

Reference: https://docs.rray.app/api/api-reference/billing/get

## Authentication

- `Authorization` header (bearer token, required) — A workspace key (`rray_live_…`, bound to one workspace) or the account's platform key. Platform keys name the target workspace with `RRay-Workspace-Id`. See [Credentials](https://docs.rray.app/docs/concepts/authentication).

## Response

### 200

Successful Response

- `plan` (string, required) — The account's current plan.
- `billing_status` (string, required) — `active`, `past_due`, or `suspended` — only an `active` account can send.
- `included_deliveries` (integer, required) — Deliveries included this period. After a mid-period plan change this is prorated by the time spent on each plan — see `allowance_proration`.
- `plan_included_deliveries` (integer, required) — Deliveries the current plan includes in a full period, before any proration.
- `daily_cap` (integer, required) — Deliveries the account may send in one UTC day.
- `object` ("billing", optional, default: billing) — Always `billing`.
- `allowance_proration` (AllowanceProration, optional, nullable) — Breakdown of `included_deliveries` per plan; `null` when the whole period ran on one plan.
- `overall_overage_cap_usd` (double, optional, nullable) — Ceiling in USD on total overage per period; `null` when no cap is set.
- `current_period_start` (datetime, optional, nullable) — Start of the current billing period; `null` before the first period opens.
- `current_period_end` (datetime, optional, nullable) — End of the current billing period; `null` before the first period opens.
- `cancel_at_period_end` (boolean, optional, default: false) — `true` when the subscription is set to end at `current_period_end`.
- `pending_plan` (string, optional, nullable) — Plan that takes effect at the start of the next period; `null` when no change is scheduled.
- `outstanding_invoice` (OutstandingInvoice, optional, nullable) — Open overage invoice freezing the account; `null` when nothing is owed.

## Errors

### 401 Unauthorized Error

Unauthorized

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 422 Unprocessable Entity Error

Unprocessable Entity

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Always `validation.request_invalid` for a schema-validation failure.
  - Allowed values: `validation.request_invalid`
- `category` (enum, required) — Always `validation` for a schema-validation failure.
  - Allowed values: `validation`
- `invalid_params` (list of ValidationIssue, required) — The request fields that failed schema validation.
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 429 Too Many Requests Error

Too Many Requests

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

### 500 Internal Server Error

Internal Server Error

- `type` (string, required) — Dereferenceable URL to this error's entry in the public /errors catalog.
- `title` (string, required) — Human-readable summary of the error code (constant per `code`).
- `status` (integer, required) — HTTP status code, determined by `code`.
- `code` (enum, required) — Stable machine-readable error key to match on. Full catalog: `GET /errors`.
  - Allowed values: `api_key.not_found`, `app.internal_error`, `auth.dashboard_session_required`, `auth.forbidden`, `auth.platform_credential_required`, `auth.provider_unavailable`, `auth.unauthorized`, `billing.daily_cap_reached`, `billing.outstanding_invoice`, `billing.overage_cap_reached`, `billing.payment_method_required`, `billing.plan_quota_exhausted`, `billing.provider_error`, `billing.suspended`, `billing.workspace_limit_exceeded`, `domain.already_exists`, `error_type.not_found`, `idempotency.body_mismatch`, `idempotency.conflict`, `message.body_unavailable`, `message.injection_failed`, `message.not_found`, `pat.name_taken`, `pat.not_found`, `rate_limit.exceeded`, `resource.conflict`, `resource.not_found`, `validation.attachment_too_large`, `validation.attachment_url_forbidden`, `validation.batch_empty`, `validation.batch_invalid`, `validation.batch_too_large`, `validation.cursor_filters_mismatch`, `validation.cursor_invalid`, `validation.duplicate_recipient`, `validation.failed`, `validation.invalid_attachment`, `validation.limit_below_usage`, `validation.limit_exceeds_capacity`, `validation.overage_cap_unavailable_on_free`, `validation.request_invalid`, `validation.workspace_header_conflict`, `validation.workspace_header_invalid`, `validation.workspace_header_required`, `workspace.name_taken`, `workspace.not_found`
- `category` (enum, required) — Coarse error class for client handling (one level above `code`): validation / authentication / authorization / not_found / conflict / rate_limit / billing / upstream / server.
  - Allowed values: `validation`, `authentication`, `authorization`, `not_found`, `conflict`, `rate_limit`, `billing`, `upstream`, `server`
- `detail` (string, optional, nullable) — Human-readable explanation of this error (constant per `code`); omitted when `title` says it all.
- `request_id` (string, optional, nullable) — Correlation id of the request, for support.
- `instance` (string, optional, nullable) — Path of the request that produced this error.
- `invalid_params` (list of ValidationIssue, optional, nullable) — Request fields that failed validation; present on field-scoped errors, else omitted.
- `state_errors` (list of StateError, optional, nullable) — Resource-state preconditions that failed; present on state-scoped errors, else omitted.

## Types

### AllowanceProration

How the current period's allowance is split, after a mid-period plan change. The allowance and the overage are prorated by time on each plan, exactly as the plan fee is.

- `changed_at` (datetime, required) — When the plan last changed inside this period (RFC 3339, UTC).
- `full_from` (datetime, required) — When the current plan's full allowance applies again — the start of the next period.
- `segments` (list of AllowanceSegment, required) — The period's stretches, in order.

### OutstandingInvoice

An open overage invoice the account still owes. Sending and plan changes are frozen until it is paid.

- `id` (string, required) — Provider invoice id.
- `amount_due_usd` (double, required) — Amount still due in USD.
- `period_start` (datetime, optional, nullable) — Start of the billing period this overage was accrued in.
- `period_end` (datetime, optional, nullable) — End of the billing period this overage was accrued in.
- `hosted_invoice_url` (string, optional, nullable) — Hosted page where the invoice can be paid; `null` when the provider has none.

### ValidationIssue

One failed field — an entry of the ``invalid_params`` array (a request field the caller can fix). Shared by schema-validation failures (pydantic) and field-scoped business rules (e.g. a duplicate recipient), so the two cannot drift in shape.

- `field` (string, required) — Path of the request field that failed, e.g. `to`, `attachments[0]`.
- `message` (string, required) — Human-readable explanation of this field error (safe to surface in a UI).
- `kind` (string, required) — Machine-readable CAUSE token (finer than the error `code`): a pydantic type (`missing`, `string_too_long`, `value_error`) for a schema failure, or a business cause — `duplicate`, `invalid_base64`, `unsupported_scheme`, `missing_host`, `unresolvable_host`, `private_address`, `size_exceeded`, `plan_restricted`. Branch on this, not `message`.

### StateError

One failed resource-state precondition — an entry of the ``state_errors`` array. Unlike ``invalid_params`` it points at a resource/account state (not a request field), e.g. an unverified sender domain or insufficient credits.

- `resource` (string, required) — The resource whose state blocked the request, e.g. `sender_domain`.
- `message` (string, required) — Human-readable explanation of the state problem (safe to surface in a UI).
- `kind` (string, required) — Machine-readable CAUSE token (finer than the error `code`), e.g. `unverified`.
- `resource_id` (string, optional, nullable) — Identifier of that resource, e.g. `example.com`.

### AllowanceSegment

One stretch of the current period spent on one plan, with the part of the period's allowance it contributes and the overage rate it is billed at.

- `plan` (string, required) — Plan in force for this stretch of the period.
- `from` (datetime, required) — Start of the stretch (RFC 3339, UTC).
- `to` (datetime, required) — End of the stretch (RFC 3339, UTC).
- `included_share` (integer, required) — Deliveries this stretch contributes to `included_deliveries`; the shares sum to it exactly.
- `overage_rate_usd` (double, required) — Price in USD of one delivery beyond the allowance in this stretch.

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "plan": "starter",
  "billing_status": "active",
  "included_deliveries": 8500,
  "plan_included_deliveries": 10000,
  "daily_cap": 500,
  "object": "billing",
  "allowance_proration": {
    "changed_at": "2024-06-15T00:00:00Z",
    "full_from": "2024-07-01T00:00:00Z",
    "segments": [
      {
        "plan": "starter",
        "from": "2024-06-01T00:00:00Z",
        "to": "2024-06-15T00:00:00Z",
        "included_share": 4839,
        "overage_rate_usd": 0.0008
      },
      {
        "plan": "growth",
        "from": "2024-06-15T00:00:00Z",
        "to": "2024-07-01T00:00:00Z",
        "included_share": 3661,
        "overage_rate_usd": 0.0006
      }
    ]
  },
  "overall_overage_cap_usd": 25,
  "current_period_start": "2024-06-01T00:00:00Z",
  "current_period_end": "2024-07-01T00:00:00Z",
  "cancel_at_period_end": false,
  "pending_plan": "growth",
  "outstanding_invoice": {
    "id": "in_1PqRsT2eZvKYlo2CxH3mN4oU",
    "amount_due_usd": 12.4,
    "period_start": "2024-05-01T00:00:00Z",
    "period_end": "2024-06-01T00:00:00Z",
    "hosted_invoice_url": "https://invoice.stripe.com/i/acct_1A2B3C4D/live_YWNjdF8xQTJCM0M0RCxzdWJfMVBxUlNUMmVadktZbG8yQ3hIM21ONG9V"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.rray.app/v1/billing"

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

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

print(response.json())
```

```javascript
const url = 'https://api.rray.app/v1/billing';
const options = {
  method: 'GET',
  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.rray.app/v1/billing"

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

	req, _ := http.NewRequest("GET", 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.rray.app/v1/billing")

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

request = Net::HTTP::Get.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.get("https://api.rray.app/v1/billing")
  .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('GET', 'https://api.rray.app/v1/billing', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.rray.app/v1/billing");
var request = new RestRequest(Method.GET);
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.rray.app/v1/billing")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```