Order routes: create, get, list
The Order Verbs create, get, list as api.sb routes, with inputs, result, refusals and an example.
Reference for Order, one group of Order routes.
Order.create
Creates an Order. Verb page.
POST /{namespace}/ ordersBody, as JSON: the inputs. Emits Order.created.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
total | money | required | The amount charged. |
merchantOfRecord | Party | The Party that charges and books the revenue. | |
outside | boolean | Computed: true when its Customer shares no owner, Studio account, Agreement, or sibling chain with the Startup. | |
lines | json | Each Offer bought, its quantity, amount and the Party that charges for it; a Service line carries its own verdict. | |
fulfillment | string | Where a Service Order’s work stands between paid and fulfilled. | |
payment | string | authorized when the Quote is accepted; captured on the Event the Outcome Contract earns names. | |
revisionsUsed | integer | Revisions the Customer has asked for, counted against the Outcome Contract’s revisions. | |
risk | number | The payment’s fraud risk score from 0 to 99 at screening, as Stripe scored it. | |
tax | money | The sales tax, VAT or GST computed at placement for the buyer’s location and the Offer’s tax category. | |
taxJurisdiction | string | Where the tax is owed, such as US-CA or EU-DE, or none when no registration applies. | |
brief | json | The scope a Service Order bought, from its Quote request: sizes, inputs and turnaround. Intake checks the inputs against it. | |
dueAt | datetime | When a Service Order’s work is due; time waiting on the Customer moves it later. | |
collectedBy | string | The id of the venue that charged the buyer and pays the Startup; unset when the Startup’s own checkout collected. | |
customer | Customer | A Customer commits to one-time purchases as Orders. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
order | Order | required | The Order. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
curl -X POST https: //api.sb/ leaseline.app/ orders \
-H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
-H "Content-Type: application/ json" \
-d '{"total": {"amount": 29, "currency": "USD"}}'{
"api": "https: //api.sb/ leaseline.app",
"order": {
"$id": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt",
"$type": "Order",
"total": {
"amount": 29,
"currency": "USD"
},
"status": "placed"
},
"action": {
"$id": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG",
"operation": "Order.create",
"status": "done"
},
"links": {
"self": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG"
}
}Order.get
Returns one Order by id. Verb page.
GET /{namespace}/ orders/ {id}Path: id. Query: the other inputs. Reads only: it emits no Event.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
id | string | required | The id of the Order. |
at | string | A time or Version name: the record as it stood then. Unset: as it stands now. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
order | Order | required | The Order. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
curl https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt \
-H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"{
"api": "https: //api.sb/ leaseline.app",
"$type": "Order",
"$id": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt",
"order": {
"$id": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt",
"$type": "Order",
"total": {
"amount": 29,
"currency": "USD"
},
"status": "placed"
},
"links": {
"self": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt",
"up": "https: //api.sb/ leaseline.app/ orders"
},
"actions": {
"cancel": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt/ cancel",
"confirm": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt/ confirm",
"deliver": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt/ deliver"
}
}Order.list
Returns Orders, newest first, one page at a time. Verb page.
GET /{namespace}/ ordersQuery: the inputs. Reads only: it emits no Event.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
limit | integer | At most this many records, up to 100. The default is 20. | |
after | string | The cursor from the previous page. | |
where | string | A filter over the properties, such as paidAt = null and total.amount > 500. | |
sort | string | Properties to sort by, comma-separated; a leading minus sorts descending. | |
total | boolean | True adds the match count as meta.total, exact up to 10,000 matches and estimated above. | |
facets | string | Properties to count by value, comma-separated, returned as meta.facets. | |
fields | string | Properties to return on each record, comma-separated; $id and $type always return. | |
include | string | Related records to embed in place of their URLs, comma-separated. | |
depth | integer | How many levels of related records to embed. The default is 1. | |
q | string | Words to match across the text properties, ranked by relevance. | |
match | string | Ranks the search by words, or meaning; words is the default. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
orders | list of Order | required | One page of Orders. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
curl "https: //api.sb/ leaseline.app/ orders? limit= 20" \
-H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"{
"api": "https: //api.sb/ leaseline.app",
"$type": "Order",
"orders": [
{
"$id": "https: //api.sb/ leaseline.app/ orders/ order_dswDnxf2vt",
"$type": "Order",
"total": {
"amount": 29,
"currency": "USD"
},
"status": "placed"
}
],
"meta": {
"limit": 20,
"after": "order_dswDnxf2vt"
},
"links": {
"self": "https: //api.sb/ leaseline.app/ orders? limit= 20",
"next": "https: //api.sb/ leaseline.app/ orders? after= order_dswDnxf2vt"
}
}