Get customer current usage
Route
GET
/api/v1/customers/:external_customer_id/current_usage?external_subscription_id=id
Usage
- Curl
- Python
- Node.js
- Ruby
- Go
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
EXTERNAL_CUSTOMER_ID="__EXTERNAL_CUSTOMER_ID__"
EXTERNAL_SUBSCRIPTION_ID="__EXTERNAL_SUBSCRIPTION_ID__"
curl --location --request GET "$LAGO_URL/api/v1/customers/$EXTERNAL_CUSTOMER_ID/current_usage?external_subscription_id=$EXTERNAL_SUBSCRIPTION_ID" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json'
from lago_python_client import Client
client = Client(api_key='__YOUR_API_KEY__')
customer_usage = client.customers().current_usage(
'external_customer_id', 'external_subscription_id'
)
import Client from 'lago-nodejs-client'
let client = new Client('__API_KEY__')
let customerUsage = await client.customerCurrentUsage(
'external_customer_id', 'external_subscription_id'
)
require 'lago-ruby-client'
client = Lago::Api::Client.new({api_key: '__YOUR_API_KEY__'})
customer_usage = client.customer.current_usage(
'external_customer_id', 'external_subscription_id'
)
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().
SetApiKey("__YOUR_API_KEY__")
customerUsage, err := lagoClient.Customer().CurrentUsage("__YOUR_CUSTOMER_ID__")
if err != nil {
// Error is *lago.Error
panic(err)
}
// customerUsage is *lago.CustomerUsage
fmt.Println(customerUsage)
}
Arguments
Attributes | Type | Description |
---|---|---|
external_customer_id | String Required | Customer unique identifier in your application |
external_subscription_id | String Optional | Subscription unique identifier in your application |
Responses
- HTTP 200
- HTTP 401
- HTTP 404
- HTTP 405
Returns a customer usage object.
{
"status": 401,
"error": "Unauthorized"
}
Access to the API endpoint is unhautorized.
Possible reasons are:
- The
Authorization
header is missing - The
Authorization
header does not contain the API key - The Api key is invalid or expired
{
"status": 404,
"error": "Not Found",
"code": "customer_not_found"
}
The customer
was not found.
{
"status": 405,
"error": "Method Not Allowed",
"code": "no_active_subscription"
}
Customer is not attached to an active subscription.