The v2/usage/ REST API is designed to handle both setting a prorated gauge and incrementing a final value counter for a specific customer in Salesbricks.

To utilize this endpoint, ensure that you are using the v2/usage/ API endpoint:

https://api.salesbricks.com/api/v2/usage/

Request: POST /v2/usage/

Parameters

FieldTypeRequiredDescription
transaction_idStringYesThe unique identifier for this usage entry transaction.
subscription_idUUIDYesThe ID of the Salesbricks subscription associated with the customer.
brick_idUUIDYesThe ID of the associated Usage Brick.
valueIntegerConditionalRequired if setting a gauge. This is the value to set for the gauge (e.g., 1).
countIntegerConditionalRequired if incrementing a counter. This is the amount to increment the counter by (e.g., 1).
timeDateTimeYesThe timestamp indicating when the operation occurs in ISO 8601 format.
propertiesDictNoAdditional properties as a JSON dictionary object (optional).

Notes

  • Either value (for gauge) or count (for counter) must be included in the request, but not both.

Response

  • 201 Created - if the usage entry is successfully submitted.
  • 400 Bad Request - if validation fails or required fields are missing.
{
  "message": "Usage entry submitted successfully."
}

Example: Setting a Prorated Gauge

POST /v2/usage/
Content-Type: application/json
Authorization: Bearer <token>

{
  "transaction_id": "12345",
  "subscription_id": "00000000-0000-0000-0000-000000000000",
  "brick_id": "00000000-0000-0000-0000-000000000000",
  "value": 121,
  "time": "2024-09-16T10:15:30Z"
}

Example: Incrementing a Final Value Counter

POST /v2/usage/
Content-Type: application/json
Authorization: Bearer <token>

{
  "transaction_id": "54321",
  "subscription_id": "00000000-0000-0000-0000-000000000000",
  "brick_id": "00000000-0000-0000-0000-000000000000",
  "count": 1,
  "time": "2024-09-16T10:15:30Z",
  "properties": {
    "source_worker": "8168cf7f-65e0-4f9a-aeb4-3e013ff71f89",
    "region": "us-east-1"
  }
}

DELETE /v2/usage/ - Deleting a Usage Entry

To delete a usage entry, provide the transaction_id in the request body.

Parameters

FieldTypeRequiredDescription
transaction_idStringYesThe unique identifier for the usage entry.

Response

  • 200 OK - if the usage entry is successfully deleted.
  • 404 Not Found - if the usage entry does not exist.
{
  "message": "Usage entry deleted successfully."
}

PATCH /v2/usage/ - Updating a Usage Entry

To update a usage entry, provide the transaction_id and the fields to be updated.

Parameters

FieldTypeRequiredDescription
transaction_idStringYesThe unique identifier for the usage entry.
valueIntegerOptionalUpdate the gauge value (if applicable).
countIntegerOptionalUpdate the counter value (if applicable).
propertiesDictOptionalUpdate the properties dictionary (if applicable).

Response

  • 200 OK - if the usage entry is successfully updated.
  • 400 Bad Request - if validation fails or required fields are missing.
  • 404 Not Found - if the usage entry does not exist.
{
  "message": "Usage entry updated successfully."
}