Skip to content

Preview converting an order to a Subscription, or attaching billing to it

POST
/orders/{id}/create-subscription/preview
Code sample: Shell / cURL
curl --request POST \
--url https://example.com/api/v1/orders/example/create-subscription/preview \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "collectionMethod": "CHARGE_AUTOMATICALLY", "contactId": "example", "currency": "example", "hoursPerPeriod": 1, "interval": "WEEKLY", "intervalCount": 1, "invoiceNote": "example", "lineItems": [ { "description": "example", "discountPercent": 1, "note": "example", "quantity": 1, "rate": 1, "serviceId": "example" } ], "nextChargeDate": "example", "orderTypeId": "example", "periodStart": "example", "renewalPrice": 1, "serviceId": "example" }'

Runs every check POST /orders/{id}/create-subscription runs and returns what it would do: the order’s type and hours per period before and after, the renewal price, the current period’s first day and the first automatic charge. Writes nothing. Same permissions as the create call.

id
required

Resource identifier (CUID2).

string
>= 1 characters

Resource identifier (CUID2).

Media typeapplication/json

Attaches manual recurring billing to an existing order with none yet. Converts an HOUR_BLOCK or TIME_AND_MATERIALS order to a Subscription type; on an existing SUBSCRIPTION order it changes nothing else. Nothing is invoiced, charged or emailed now.

object
collectionMethod

How each cycle is collected. CHARGE_AUTOMATICALLY sends the cycle invoice and charges the card on file; SEND_INVOICE only sends the invoice with its payment link, due by the company’s payment terms, and is never charged or retried.

string
Allowed values: CHARGE_AUTOMATICALLY SEND_INVOICE
contactId

A user of the company its cycle invoices are addressed to; left out or null addresses the company’s Billing contact.

Any of:
string
>= 1 characters
currency
required

ISO 4217 currency code, e.g. USD.

string
>= 3 characters <= 3 characters
hoursPerPeriod

Hours the converted order gets every billing period; its current budget hours when left out. Not used when the order already is a Subscription.

number
interval
required
string
Allowed values: WEEKLY MONTHLY QUARTERLY YEARLY
intervalCount

Number of interval units between charges, e.g. 1 for monthly, 3 for a quarterly cadence billed by month.

integer
default: 1 > 0 <= 9007199254740991
invoiceNote

Printed on every cycle invoice; left out, null or empty prints none.

Any of:
string
<= 5000 characters
lineItems

The lines every cycle invoice bills; renewalPrice must be their sum. Left out or empty, each cycle bills renewalPrice as one line named after the order.

Array<object>
<= 100 items
object
description

Required unless serviceId is given, which then lends its name.

string
<= 500 characters
discountPercent

Percentage taken off the line, above 0 and below 100; null for none.

number | null
note
Any of:
string
<= 2000 characters
quantity
required
number
> 0
rate
required
number
serviceId
Any of:
string
>= 1 characters
nextChargeDate
required

First automatic charge date (YYYY-MM-DD), resolved at workspace-local midnight. Must be after today. No invoice or charge is issued by this call — the renewal job bills it automatically once the date arrives.

string
/^\d{4}-\d{2}-\d{2}$/
orderTypeId

The Subscription order type (see GET /order-types) an Hour block or Time & Materials order moves to; the workspace’s system Subscription type when left out. Not used when the order already is a Subscription.

string
>= 1 characters
periodStart

First day of the period the next charge renews, YYYY-MM-DD in the workspace timezone; hours logged from it count against that period. An existing order defaults to one billing interval before nextChargeDate, never before the order’s start; a new order to today.

string
/^\d{4}-\d{2}-\d{2}$/
renewalPrice
required

The price charged every renewal cycle, in currency.

number
serviceId

Service to attribute the subscription to; omit or null for none.

string | null

What the conversion or attachment would do.

Media typeapplication/json
object
data
required
object
collectionMethod
required

How each cycle is collected. CHARGE_AUTOMATICALLY sends the cycle invoice and charges the card on file; SEND_INVOICE only sends the invoice with its payment link, due by the company’s payment terms, and is never charged or retried.

string
Allowed values: CHARGE_AUTOMATICALLY SEND_INVOICE
currency
required
string
endsOn
required

The order’s end date, YYYY-MM-DD; its subscription is cancelled then.

string | null
hasUsablePaymentMethod
required
boolean
hoursPerPeriod
required

Budget hours before and the hours per period after a conversion.

Any of:
object
after
required
number
before
required
number
interval
required
string
Allowed values: WEEKLY MONTHLY QUARTERLY YEARLY
intervalCount
required
integer
>= -9007199254740991 <= 9007199254740991
nextChargeOn
required

First automatic charge, YYYY-MM-DD.

string
order
required
Any of:
object
code
required
string | null
fromType
required
string
id
required
string
name
required
string
toType
required
string
path
required

Convert: the order changes type; attach: it already is a Subscription; new: no order yet.

string
Allowed values: convert attach new
periodStartsOn
required

First day of the current period, YYYY-MM-DD.

string
renewalPrice
required
number

Example

{
"data": {
"collectionMethod": "CHARGE_AUTOMATICALLY",
"interval": "WEEKLY",
"path": "convert"
}
}

Validation error. Parse failures include field paths and expectations.

Media typeapplication/json

Validation error with safe field paths and expected values; submitted values are never returned.

object
error
required
object
code
required

Stable machine-readable error code.

string
issues
Array<object>
object
expected
required
string
message
required
string
path
required
Array<string | number>
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Unauthorized.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Forbidden.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Not found.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

The order already has a subscription.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Invalid input.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Rate limit exceeded. Wait for Retry-After before retrying.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}
RateLimit-Limit
string
/^\d+$/

Maximum requests in the current quota window.

RateLimit-Policy
string

Quota policy in requests and window seconds, for example 60;w=60.

RateLimit-Remaining
string
/^\d+$/

Requests left in this quota window (zero when blocked).

RateLimit-Reset
string
/^\d+$/

Seconds until the current quota window resets, when available from the rate-limit store.

Retry-After
string
/^\d+$/

Seconds until another request may be attempted.