The link between user_id and customer_id
What is the link between user_id and customer_id and how do I get customer_id to then run Management API to check/consume usage?
4 Replies
Also when using the Kinde Management API to handle metered billing (with test hardcoded values that I get from Kinde dashboard, because a I cannot programmatically get them) I am encountering a persistent METER_NOT_FOUND error, even though the feature appears to be correctly configured in my dashboard.
Hello, EJ. I would like to make sure that I understand your request correctly to be able to help you.
I want to confirm your request first.
In Kinde, you would like to understand the relationship between the user ID and the consumer ID (I believe you are referring to the consumer agreement ID) [1], and how to get the consumer agreement ID for billing and usage purposes [2], which is associated with a customer's subscription or billing agreement.
To check or consume usage via the Management API, you need the agreement ID. Here’s how you can get it:
1. Retrieve the user’s Kinde user_id (you can get this via the Management API or through the Kinde UI).
2. In the Kinde UI, open the user or organization record and select Billing to view the customer’s agreement ID as part of their subscription details.
3. Alternatively, use the Management API to get the agreement ID for a user by expanding the billing information in your request.
Once you have the agreement ID, you can use it with the Management API to record or check usage.
References:
- Mapping and syncing users for enterprise auth
- Add metered usage for a customer via API
Kinde docs
Mapping and syncing users for enterprise auth
Guide to mapping and syncing users for enterprise authentication including user ID mapping, profile sync, and webhook integration.
Kinde docs
Add metered usage for a customer via API
Guide to manually adding metered usage for customers via the Kinde API including agreement ID and feature code requirements.
I’m currently working with the team to investigate the other issue you raised. We’re actively looking into it and will provide you with a detailed update by next Thursday.
Hello, EJ, regarding your initial question, the team shared this response:
There is the concept of customer_id and customer_agreement_id (of subscription) customer_id is the unique identifier for a user that is on a plan. It's different to user_id or org_id, because a customer can be a user, or an organization. Not all users or organizations are customers, hence why they are different. **customer_agreement_id identifies your subscription to a plan at a point in time.A user or org that agrees to subscribe to a plan become a customer, and get an agreement.>
...We have now made changes to the Kinde Management API so that:>
- You can get the customer_id by making a Get user API call with expand=billing. - This will include the customer_id which can be used to get customer_agreement_id by making a Get billing agreements API call.
Kinde docs
Kinde Management API
The management API is for managing your Kinde account. Most things that can be done via the Kinde admin UI can be done with this API