# Create order

URL: https://docs.hanzo.ai/docs/openapi/billing/post-billing-paypal-order

> Opens a server-priced PayPal REST v2 order for either a bounded credit top-up (intent CAPTURE) or a plan purchase's first period (intent AUTHORIZE).

`POST /v1/billing/paypal/order`

> [Billing →](https://docs.hanzo.ai/docs/openapi/billing) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                |
| ------------- | ---------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/billing/paypal/order` |
| **Method**    | `POST`                                         |
| **Operation** | `post_billing_paypal_order`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`         |

Opens a server-priced PayPal REST v2 order for either a
bounded credit top-up (intent CAPTURE) or a plan purchase's first period
(intent AUTHORIZE).

No balance or subscription row is minted here: the browser hands the returned
`orderId` to the PayPal Smart Buttons SDK for buyer approval, then settles
the payment through POST /v1/billing/topup/token or
POST /v1/billing/subscribe/card with `provider: "paypal"`.

## Request

13 fields, body `application/json` (required).

| Field               | In     | Type                | Required | Description                                                                    |
| ------------------- | ------ | ------------------- | -------- | ------------------------------------------------------------------------------ |
| `X-Idempotency-Key` | header | string              | —        |                                                                                |
| `amountCents`       | body   | integer (int64)     | —        | AmountCents is the top-up amount in whole cents when PlanID is empty.          |
| `balanceCents`      | body   | integer (int64)     | —        | BalanceCents is an organization's optional starting usage balance.             |
| `coupon`            | body   | string              | —        | Coupon is an optional plan coupon code for a monthly subscription.             |
| `currency`          | body   | string              | —        | Currency is the ISO-4217 code (default usd).                                   |
| `interval`          | body   | string              | —        | Interval selects the billing term ("month" or "year").                         |
| `level`             | body   | integer (int64)     | —        | Level selects which published price level of the plan to buy.                  |
| `lines`             | body   | billing.SaleLine\[] | —        | Lines are a team's additional seat types bought on the same subscription.      |
| `lines[].planId`    | body   | string              | —        | PlanID is the seat type, e.g. "team-premium".                                  |
| `lines[].quantity`  | body   | integer (int64)     | —        | Quantity is the seats of it bought, at least 1.                                |
| `planId`            | body   | string              | —        | PlanID is the plan slug when buying a plan's first period; empty for a top-up. |
| `quantity`          | body   | integer (int64)     | —        | Quantity is the seat count for a per-seat plan.                                |
| `storeId`           | body   | string              | —        | StoreID scopes the plan catalog when set.                                      |

## Response

| Status    | Body                   | Meaning |
| --------- | ---------------------- | ------- |
| `200`     | billing.PayPalOrderOut | ok      |
| `default` | problem-details        | refused |

`200` body — 7 fields.

| Field         | In   | Type            | Always | Description |
| ------------- | ---- | --------------- | ------ | ----------- |
| `amountCents` | body | integer (int64) | —      |             |
| `currency`    | body | string          | —      |             |
| `environment` | body | string          | —      |             |
| `intent`      | body | string          | —      |             |
| `orderId`     | body | string          | —      |             |
| `status`      | body | string          | —      |             |
| `test`        | body | boolean         | —      |             |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo billing paypal order
```

**SDK**

**.ts**

```ts
import { Configuration, BillingApi } from 'hanzoai';

const api = new BillingApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postBillingPaypalOrder({ amountCents: 0, balanceCents: 0 });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import BillingApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = BillingApi(client).post_billing_paypal_order(amount_cents=0, balance_cents=0)
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.BillingAPI.PostBillingPaypalOrder(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, billing_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = billing_api::post_billing_paypal_order(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.BillingApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new BillingApi(client).postBillingPaypalOrder();
```

The method above is the one at the current release of the document. `hanzoai@8.5.914` (npm) and `hanzoai@8.5.914` (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. [SDKs →](https://docs.hanzo.ai/docs/sdks)

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/billing/paypal/order \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "amountCents": 0,
       "balanceCents": 0
     }'
```

**MCP**

MCP reaches **billing** through the `billing` tool, which names its 45 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_billing_accounts"
         }
       }
     }'
```

---

[Billing API](https://docs.hanzo.ai/docs/openapi/billing) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
