#nick-metered-subscription-qs
1 messages ยท Page 1 of 1 (latest)
Thanks!
I also just tried with the CLI, and it did the same thing. However, my usage could be incorrect: stripe usage_records create si_KuttA54npWIBbD --quantity 1818 --action set
thank you for your patience
still looking into it
No worries!
Do you have the request ID (req_123) from a time you tried to record this usage?
I am having trouble finding the calls for recording usage to si_KuttA54npWIBbD on the account that si_KuttA54npWIBbD exists on
Oh never mind I see it
I don't, and the "Logs" tab of the Developers section doesn't record them either
stripe usage_records create si_KuttA54npWIBbD --quantity 1818 --action set
{
"id": "mbur_1KJhIJI67GP2qpb4JIoPQaju",
"object": "usage_record",
"livemode": false,
"quantity": 1818,
"subscription_item": "si_KuttA54npWIBbD",
"timestamp": 1642610759
}
This payload was returned by the last CLI call, if that's helpful in any way
Thank you, I'm able to find the requests and records. Still not sure why the dashboard shows it incrementing despite the set... https://dashboard.stripe.com/test/logs/req_WX2W7muerxDoGk
Ah, this may be from from the price's aggregate_usage property https://stripe.com/docs/api/prices/create#create_price-recurring-aggregate_usage
Yes, it looks like it is not set on this price so it defaults to sum . You will want to create a new price and set aggregate_usage to last_during_period or last_ever
Will that still allow me to sum if I want to?
Basically I'm wondering, can I use a mix of both SET and INCREMENT?
We are recording usage daily throughout the month (using INCREMENT), but at the end of the month I'm trying to validate that the usage in Stripe matches what we have on our end, and if it doesn't, I want to override the value with SET
๐
Let me start by clarifying usage records + set/increment. Set/Increment are more relevant when you are override the quantity at a specific timestamp. For example if you created a new usage record at timestamp 1642610759, using increment and set would both behave the same since there is no existing usage record at timestamp 1642610759. If you were to create another usage record at the same timestamp 1642610759 after the first request, you'd use set if you wanted to override the previous value, and you'd use increment if you wanted the new usage record to be added to the previous one.
With that in mind, if you want to correct usage records at the end of the month you can:
- create a new usage record for the current timestamp if you want to ADD more usage
- modify existing usage records at previous timestamps with
action: setto override the usage value at that point to a lower number
Thanks for the clarification. Just to confirm, you can use set for any aggregation type, but you must pass a timestamp you want it to "set", otherwise it will just see it as new usage and increment
Yup!
Got it. Ok, thanks for your help, @summer lark and @turbid jackal and @civic bear