Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 71 additions & 1 deletion content/2.api-reference/3.one-off-products.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "One-off Products"
description: "On this page, we'll dive into the different one-off product endpoints you can use to query your products programmatically."
---

A one-off product is a digital product that can be bought once. Products are configured in the Vatly dashboard and can be added to checkouts.
A one-off product is a digital product that can be bought once. Products can be created via the API or in the Vatly dashboard, and added to checkouts.

Looking for subscription plans? See the [Subscription Plans API](/api-reference/subscription-plans) instead.

Expand Down Expand Up @@ -97,6 +97,76 @@ $products = $vatly->oneOffProducts->page();
::


---

## Create a one-off product

`POST /v1/one-off-products`

Creates a new one-off product for the authenticated merchant, in the testmode determined from the API token.

A product created with a `live_` token starts in `pending` status and must be approved by Vatly before it can be used in checkouts — the same review that applies to products created in the dashboard. A product created with a `test_` token is auto-approved (`active`) so you can trial checkout immediately.

### Required attributes

| Name | Type | Description |
| --- | --- | --- |
| `name` | `string` | Display name of the product (3–255 characters). |
| `description` | `string` | Detailed description of the product. |
| `basePrice` | `Money` | Price of the product. A Money object with `value` (decimal string) and `currency` (ISO 4217 code). |
| `productType` | `string` | Tax product classification. One of `saas` (Software as a Service) or `ebook` (electronic book). |

::code-group{sync="api"}

```bash [cURL]
curl https://api.vatly.com/v1/one-off-products \
-H "Authorization: Bearer live_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"name": "Premium License",
"description": "Lifetime access to all premium features",
"basePrice": { "value": "299.00", "currency": "EUR" },
"productType": "saas"
}'
```

```php [PHP]
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');

$product = $vatly->oneOffProducts->create([
'name' => 'Premium License',
'description' => 'Lifetime access to all premium features',
'basePrice' => ['value' => '299.00', 'currency' => 'EUR'],
'productType' => 'saas',
]);
```

```json [Response]
{
"id": "one_off_product_Vr8kQdFhSrG4Y3DnfsdqH",
"resource": "one_off_product",
"testmode": false,
"name": "Premium License",
"description": "Lifetime access to all premium features",
"basePrice": {
"value": "299.00",
"currency": "EUR"
},
"status": "pending",
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/one-off-products/one_off_product_Vr8kQdFhSrG4Y3DnfsdqH",
"type": "application/json"
}
}
}
```

::


---

## Get a specific one-off product
Expand Down
83 changes: 83 additions & 0 deletions content/2.api-reference/5.subscription-plans.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,89 @@ $plans = $vatly->subscriptionPlans->page();
::


---

## Create a subscription plan

`POST /v1/subscription-plans`

Creates a new subscription plan for the authenticated merchant, in the testmode determined from the API token.

A plan created with a `live_` token starts in `pending` status and must be approved by Vatly before it can be used in checkouts — the same review that applies to plans created in the dashboard. A plan created with a `test_` token is auto-approved (`active`) so you can trial checkout immediately.

**Constraints:**
- `productType` must be `saas` — e-books are one-off purchases and cannot be sold on a recurring basis.
- The `day` interval is sandbox-only; live plans support `week`, `month`, and `year`.
- `intervalCount` is bounded per unit: up to 365 days, 52 weeks, or 12 months. `year` always bills once per year (`intervalCount` is ignored).

### Required attributes

| Name | Type | Description |
| --- | --- | --- |
| `name` | `string` | Display name of the plan (3–255 characters). |
| `description` | `string` | Detailed description of the plan. |
| `basePrice` | `Money` | Price per billing interval. A Money object with `value` (decimal string) and `currency` (ISO 4217 code). |
| `productType` | `string` | Tax product classification. Must be `saas`. |
| `interval` | `string` | Billing interval unit. One of `day` (sandbox-only), `week`, `month`, or `year`. |
| `intervalCount` | `integer` | Number of interval units between billing cycles (at least 1). |

::code-group{sync="api"}

```bash [cURL]
curl https://api.vatly.com/v1/subscription-plans \
-H "Authorization: Bearer live_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"name": "Pro Monthly",
"description": "Full access to all Pro features, billed monthly",
"basePrice": { "value": "29.00", "currency": "EUR" },
"productType": "saas",
"interval": "month",
"intervalCount": 1
}'
```

```php [PHP]
$vatly = new \Vatly\API\VatlyApiClient();
$vatly->setApiKey('live_your_api_key_here');

$plan = $vatly->subscriptionPlans->create([
'name' => 'Pro Monthly',
'description' => 'Full access to all Pro features, billed monthly',
'basePrice' => ['value' => '29.00', 'currency' => 'EUR'],
'productType' => 'saas',
'interval' => 'month',
'intervalCount' => 1,
]);
```

```json [Response]
{
"id": "subscription_plan_Bm7xNvPwKr3YjTgHcZaE",
"resource": "subscription_plan",
"testmode": false,
"name": "Pro Monthly",
"description": "Full access to all Pro features, billed monthly",
"basePrice": {
"value": "29.00",
"currency": "EUR"
},
"interval": "month",
"intervalCount": 1,
"status": "pending",
"createdAt": "2024-01-15T10:30:00Z",
"links": {
"self": {
"href": "https://api.vatly.com/v1/subscription-plans/subscription_plan_Bm7xNvPwKr3YjTgHcZaE",
"type": "application/json"
}
}
}
```

::


---

## Retrieve a subscription plan
Expand Down
Loading
Loading