Create a Usage Record

POST

/v1/usage-records

Create a usage record.


Attributes

quantity

A positive integer representing the usage to be reported.

action

The type of record. One of

  • increment - Add the provided quantity to existing records for the current billing period.
  • set - Set the quantity for the current billing period to the provided quantity.

Defaults to increment if omitted.


Relationships

subscription_item

The subscription item this usage record belongs to.


curl -X "POST" "https://api.lemonsqueezy.com/v1/usage-records" \
  -H "Accept: application/vnd.api+json" \
  -H "Content-Type: application/vnd.api+json" \
  -H "Authorization: Bearer {api_key}" \
  -d '{
    "data": {
      "type": "usage-records",
      "attributes": {
        "quantity": 5
      },
	  "relationships": {
		"subscription-item": {
		  "data": {
            "type": "subscription-items",
            "id": "1"
          }		
		}
	  }
    }
  }'

Returns

Returns s Usage Record object.

{
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://api.lemonsqueezy.com/v1/usage-records/1"
  },
  "data": {
    "type": "usage-records",
    "id": "1",
    "attributes": {
      "subscription_item_id": 1,
      "quantity": 5,
      "action": "increment",
      "created_at": "2023-07-24T14:44:38.000000Z",
      "updated_at": "2023-07-24T14:44:38.000000Z"
    },
    "relationships": {
      "subscription-item": {
        "links": {
          "related": "https://api.lemonsqueezy.com/v1/usage-records/1/subscription-item",
          "self": "https://api.lemonsqueezy.com/v1/usage-records/1/relationships/subscription-item"
        }
      }
    },
    "links": {
      "self": "https://api.lemonsqueezy.com/v1/usage-records/1"
    }
  }
}

Was this page helpful?