riverty logo

Docs

Create or Update A Consumption

Create or update a consumption.

Path

PUT /v1/clients/{clientId}/consumptions/{consumptionId}

Request Parameters

clientId required
integer
Your assigned `ClientId`.
consumptionId required
string
Id of the consumption.

Request Body

application/json

customerNumber
required
string > 100 Characters
Id of the customer to assign the consumption to.
subscriptionId
string
Optional. If set, associates this consumption with a subscription.
items
required
array
The items that make up this consumption.
metadata
array
Optional. A list of key-value pairs.

Responses

Successful Request, Consumption CreatedSuccessful Request, Consumption UpdatedUnsuccessful Request, Bad/Missing Information

Response Example

    
        {
 "consumptionTotal": {
  "grossAmount": 125,
  "vatAmount": 25,
  "currencyCode": "NOK"
 },
 "refundTotal": {
  "grossAmount": 20,
  "vatAmount": 25,
  "currencyCode": "NOK"
 },
 "id": "consumption-id-1",
 "customerNumber": "customer-number-1",
 "subscriptionId": "subscription-id",
 "invoiceId": "100484",
 "items": [
  {
   "id": "1",
   "productDetails": {
    "productId": "pack-2gb",
    "description": "2gb data pack."
   },
   "unit": {
    "netPrice": 100,
    "quantity": 1,
    "code": "PCS",
    "currencyCode": "NOK"
   },
   "total": {
    "grossAmount": 125,
    "netAmount": 100,
    "currencyCode": "NOK",
    "vatPercentage": 25
   },
   "occurredAt": {
    "start": "2022-09-28T10:40:44.421Z",
    "end": null
   },
   "metadata": [
    {
     "key": "product-number",
     "value": "3937501"
    }
   ]
  }
 ],
 "createdAt": "2022-09-28T10:40:44.421Z",
 "billingDate": null,
 "metadata": [
  {
   "key": "order-id",
   "value": "a9ee9996-e941-4aa8-90b9-4b047c4afe87"
  }
 ],
 "_links": [
  {
   "method": "GET",
   "href": "https://api.riverty.io/subscription/v1/clients/1234/consumptions/consumption-id-1",
   "rel": "self",
   "target": "API"
  },
  {
   "method": "GET",
   "href": "https://api.riverty.io/subscription/v1/clients/1234/consumptions/consumption-id-1/timeline",
   "rel": "timeline",
   "target": "API"
  },
  {
   "method": "GET",
   "href": "https://api.riverty.io/subscription/v1/clients/1234/subscriptions/subscription-id-1",
   "rel": "subscription",
   "target": "API"
  }
 ]
}
    

Request Example

    
        {
 "customerNumber": "customer-number-1",
 "subscriptionId": "subscription-id-1",
 "items": [
  {
   "id": "1",
   "productDetails": {
    "productId": "pack-2gb",
    "description": "2gb data pack."
   },
   "unit": {
    "netPrice": 100,
    "quantity": 1,
    "code": "PCS"
   },
   "tax": {
    "vatPercentage": 25
   },
   "total": {
    "grossAmount": 125,
    "netAmount": 100
   },
   "occurredAt": {
    "start": "2022-09-28T10:40:44.421Z",
    "end": null
   },
   "metadata": [
    {
     "key": "product-number",
     "value": "3937501"
    }
   ]
  }
 ],
 "metadata": [
  {
   "key": "order-id",
   "value": "a9ee9996-e941-4aa8-90b9-4b047c4afe87"
  }
 ]
}