إرسال
Project

Usage and Consumptions

View SMS usage and consumption history for the project

Endpoint

GET /api/project/consumptions

Query parameters

FieldTypeRequiredDescription
pageintegerNoPage number, minimum 1 (default: 1)
per_pageintegerNoResults per page, minimum 1 (default: 10)
fromdateNoFilter records on/after this date (YYYY-MM-DD)
todateNoFilter records on/before this date (YYYY-MM-DD)

Records are returned newest first.

This endpoint reports subscription quota consumption only. Messages paid for with payment_type: "wallet" are charged against the company wallet and do not appear here — use List Messages or the dashboard's wallet transactions for those.

Example

curl "https://sms.lamah.com/api/project/consumptions?from=2024-01-01&to=2024-01-31" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response

The response is wrapped in a data key containing a Laravel paginator object:

{
  "data": {
    "current_page": 1,
    "data": [
      {
        "consumption": 5,
        "type": "SMS",
        "request_id": "b9e8a1f2-4c60-4b0b-9f51-0c4f2f6c9e7a",
        "allocation_index": 0,
        "created_at": "2024-01-15T10:30:00Z",
        "updated_at": "2024-01-15T10:30:00Z"
      }
    ],
    "first_page_url": "https://sms.lamah.com/api/project/consumptions?page=1",
    "from": 1,
    "last_page": 25,
    "last_page_url": "https://sms.lamah.com/api/project/consumptions?page=25",
    "links": [
      { "url": null, "label": "« Previous", "active": false },
      { "url": "https://sms.lamah.com/api/project/consumptions?page=1", "label": "1", "active": true },
      { "url": "https://sms.lamah.com/api/project/consumptions?page=2", "label": "Next »", "active": false }
    ],
    "next_page_url": "https://sms.lamah.com/api/project/consumptions?page=2",
    "path": "https://sms.lamah.com/api/project/consumptions",
    "per_page": 10,
    "prev_page_url": null,
    "to": 10,
    "total": 250
  }
}

Top-level response fields

FieldTypeDescription
dataobjectLaravel paginator object

Pagination fields

FieldTypeDescription
current_pageintegerCurrent page number
dataarrayConsumption records on the current page
first_page_urlstringURL of the first page
frominteger|nullIndex of the first record on the current page
last_pageintegerTotal number of pages
last_page_urlstringURL of the last page
linksarrayLaravel pagination navigation links
next_page_urlstring|nullURL of the next page
pathstringBase URL for this paginated resource
per_pageintegerResults per page
prev_page_urlstring|nullURL of the previous page
tointeger|nullIndex of the last record on the current page
totalintegerTotal number of consumption records

Consumption record fields

FieldTypeDescription
consumptionintegerUnits consumed (SMS parts, or 1 per OTP)
typestringFeature type: SMS or OTP
request_idstring|nullThe send request this consumption was recorded against
allocation_indexinteger|nullPosition when a single send is split across multiple subscriptions
created_atstringISO 8601 timestamp when consumption was recorded
updated_atstringISO 8601 timestamp when record was last updated

One send can produce several records when its quota is drawn from more than one active subscription. Group by request_id to reassemble the total charged for a single send.

Error responses

422 Unprocessable Entity — Validation failed

{
  "message": "The from field must be a valid date.",
  "errors": {
    "from": ["The from field must be a valid date."]
  }
}

401 Unauthorized

{ "message": "Invalid or missing token." }
{ "message": "Unauthorized IP address." }

Use this to build usage reports or billing dashboards for your users. Timestamps are returned in UTC.

On this page