Skip to content

Deal routes: propose, win

The Deal Verbs propose, win as api.sb routes, with inputs, result, refusals and an example.

Reference for Deal, one group of Deal routes.

Deal.propose

Propose sends a Deal’s buyer a Quote they accept to place an Order. Verb page.

Text
POST /{namespace}/deals/{deal}/propose

Path: deal. Body, as JSON: the other inputs. Emits Deal.proposed.

Inputs

InputTypeRequiredDescription
dealDealrequiredThe qualified Deal.
quoteQuoterequiredThe Quote to send.

Returns

OutputTypeRequiredDescription
dealDealrequiredThe Deal with its Quote out.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/deals/deal_NgACZ6DcII/propose \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"quote":"qt_GZnH5OK100"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "deal": {
    "$id": "https://api.sb/leaseline.app/deals/deal_NgACZ6DcII",
    "$type": "Deal",
    "status": "Proposed"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Deal.propose",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Deal.win

Win closes a Deal as won, which places its Order and makes the buyer a Customer. Verb page.

Text
POST /{namespace}/deals/{deal}/win

Path: deal. Emits Deal.won.

Inputs

InputTypeRequiredDescription
dealDealrequiredThe proposed Deal.

Returns

OutputTypeRequiredDescription
orderOrderrequiredThe placed Order.
dealDealrequiredThe Deal, now won.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The record is not in a state that allows this Verb, so the call is refused.refusedRead the record, run the Verb that moves it to an allowed state, then retry.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/deals/deal_NgACZ6DcII/win \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "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"
  },
  "deal": {
    "$id": "https://api.sb/leaseline.app/deals/deal_NgACZ6DcII",
    "$type": "Deal",
    "status": "Won"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Deal.win",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}