LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/wallets" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"wallet": {
"name": "Prepaid",
"rate_amount": "1.5",
"paid_credits": "20.0",
"granted_credits": "10.0",
"currency": "USD",
"expiration_at": "2022-07-07",
"external_customer_id": "hooli_1234"
}
}'
from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models import Wallet
client = Client(api_key='__YOUR_API_KEY__')
wallet = Wallet(
name='Prepaid',
rate_amount='1.5',
paid_credits='20.0',
granted_credits='10.0',
currency='USD',
expiration_at='2022-07-07T23:59:59Z',
external_customer_id='hooli_1234'
)
try:
client.wallets.create(wallet)
except LagoApiError as e:
repair_broken_state(e) # do something on error or raise your own exception
require 'lago-ruby-client'
client = Lago::Api::Client.new(api_key: '__YOUR_API_KEY__')
client.wallets.create({
name: 'Prepaid',
rate_amount: '1.5',
paid_credits: '20.0',
granted_credits: '10.0',
currency: 'USD',
expiration_at: '2022-07-07T23:59:59Z',
external_customer_id: 'hooli_1234'
})
await client.wallets.createWallet({
wallet: {
name: "Prepaid",
currency: "USD",
rate_amount: 1.5,
paid_credits: 20.0,
granted_credits: 10.0,
expiration_at: "2022-07-07T23:59:59Z",
external_customer_id: "hooli_1234",
},
});
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().
SetApiKey("__YOUR_API_KEY__")
expirationAt := time.Date(2022, 7, 7, 23, 59, 59, 0, time.UTC)
walletInput := &lago.WalletInput{
Name: "Prepaid",
RateAmount: "1.5",
PaidCredits: "20.0"
GrantedCredits: "10.0",
Currency: "USD",
ExpirationAt: &expirationAt,
ExternalCustomerID: "hooli_1234",
}
wallet, err := lagoClient.Wallet().Create(walletInput)
if err != nil {
// Error is *lago.Error
panic(err)
}
// wallet is *lago.Wallet
fmt.Println(wallet)
}
{
"wallet": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "hooli_1234",
"status": "active",
"currency": "USD",
"rate_amount": "1.5",
"credits_balance": "28.0",
"balance_cents": 1000,
"consumed_credits": "2.0",
"created_at": "2022-04-29T08:59:51Z",
"invoice_requires_successful_payment": false,
"ongoing_balance_cents": 800,
"ongoing_usage_balance_cents": 200,
"credits_ongoing_balance": "8.0",
"credits_ongoing_usage_balance": "2.0",
"billing_entity_code": "default",
"name": "Prepaid",
"code": "prepaid",
"priority": 50,
"expiration_at": null,
"last_balance_sync_at": "2022-04-29T08:59:51Z",
"last_consumed_credit_at": "2022-04-29T08:59:51Z",
"terminated_at": "2022-09-14T16:35:31Z",
"applies_to": {
"fee_types": [
"charge"
],
"billable_metric_codes": [
"bm1"
]
},
"recurring_transaction_rules": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"trigger": "interval",
"method": "target",
"interval": "monthly",
"status": "active",
"threshold_credits": "20.0",
"paid_credits": "20.0",
"granted_credits": "10.0",
"grants_target_top_up": false,
"started_at": "2022-08-08T00:00:00Z",
"target_ongoing_balance": "200.0",
"created_at": "2022-04-29T08:59:51Z",
"expiration_at": "2023-09-30T23:59:59Z",
"invoice_requires_successful_payment": false,
"transaction_metadata": [
{
"key": "example_key",
"value": "example_value"
},
{
"key": "another_key",
"value": "another_value"
}
],
"transaction_name": "Tokens for models 'high-fidelity-boost'",
"ignore_paid_top_up_limits": false,
"applied_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z",
"invoice_custom_section": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "EU Bank Details",
"code": "eu_bank_details",
"description": "This section contains the bank details for EU customers.",
"details": "Bank Name: Lago Bank, IBAN: FR7630004000031234567890143",
"display_name": "Bank Details:",
"applied_to_organization": true,
"organization_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z"
},
"invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
],
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
}
],
"paid_top_up_min_amount_cents": 100,
"paid_top_up_max_amount_cents": 1000,
"applied_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z",
"invoice_custom_section": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "EU Bank Details",
"code": "eu_bank_details",
"description": "This section contains the bank details for EU customers.",
"details": "Bank Name: Lago Bank, IBAN: FR7630004000031234567890143",
"display_name": "Bank Details:",
"applied_to_organization": true,
"organization_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z"
},
"invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
],
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15",
"source": null
}
}
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 403,
"error": "Forbidden",
"code": "feature_unavailable"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}Wallets
Create a wallet
This endpoint is used to create a wallet with prepaid credits.
POST
/
wallets
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/wallets" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"wallet": {
"name": "Prepaid",
"rate_amount": "1.5",
"paid_credits": "20.0",
"granted_credits": "10.0",
"currency": "USD",
"expiration_at": "2022-07-07",
"external_customer_id": "hooli_1234"
}
}'
from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models import Wallet
client = Client(api_key='__YOUR_API_KEY__')
wallet = Wallet(
name='Prepaid',
rate_amount='1.5',
paid_credits='20.0',
granted_credits='10.0',
currency='USD',
expiration_at='2022-07-07T23:59:59Z',
external_customer_id='hooli_1234'
)
try:
client.wallets.create(wallet)
except LagoApiError as e:
repair_broken_state(e) # do something on error or raise your own exception
require 'lago-ruby-client'
client = Lago::Api::Client.new(api_key: '__YOUR_API_KEY__')
client.wallets.create({
name: 'Prepaid',
rate_amount: '1.5',
paid_credits: '20.0',
granted_credits: '10.0',
currency: 'USD',
expiration_at: '2022-07-07T23:59:59Z',
external_customer_id: 'hooli_1234'
})
await client.wallets.createWallet({
wallet: {
name: "Prepaid",
currency: "USD",
rate_amount: 1.5,
paid_credits: 20.0,
granted_credits: 10.0,
expiration_at: "2022-07-07T23:59:59Z",
external_customer_id: "hooli_1234",
},
});
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().
SetApiKey("__YOUR_API_KEY__")
expirationAt := time.Date(2022, 7, 7, 23, 59, 59, 0, time.UTC)
walletInput := &lago.WalletInput{
Name: "Prepaid",
RateAmount: "1.5",
PaidCredits: "20.0"
GrantedCredits: "10.0",
Currency: "USD",
ExpirationAt: &expirationAt,
ExternalCustomerID: "hooli_1234",
}
wallet, err := lagoClient.Wallet().Create(walletInput)
if err != nil {
// Error is *lago.Error
panic(err)
}
// wallet is *lago.Wallet
fmt.Println(wallet)
}
{
"wallet": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"external_customer_id": "hooli_1234",
"status": "active",
"currency": "USD",
"rate_amount": "1.5",
"credits_balance": "28.0",
"balance_cents": 1000,
"consumed_credits": "2.0",
"created_at": "2022-04-29T08:59:51Z",
"invoice_requires_successful_payment": false,
"ongoing_balance_cents": 800,
"ongoing_usage_balance_cents": 200,
"credits_ongoing_balance": "8.0",
"credits_ongoing_usage_balance": "2.0",
"billing_entity_code": "default",
"name": "Prepaid",
"code": "prepaid",
"priority": 50,
"expiration_at": null,
"last_balance_sync_at": "2022-04-29T08:59:51Z",
"last_consumed_credit_at": "2022-04-29T08:59:51Z",
"terminated_at": "2022-09-14T16:35:31Z",
"applies_to": {
"fee_types": [
"charge"
],
"billable_metric_codes": [
"bm1"
]
},
"recurring_transaction_rules": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"trigger": "interval",
"method": "target",
"interval": "monthly",
"status": "active",
"threshold_credits": "20.0",
"paid_credits": "20.0",
"granted_credits": "10.0",
"grants_target_top_up": false,
"started_at": "2022-08-08T00:00:00Z",
"target_ongoing_balance": "200.0",
"created_at": "2022-04-29T08:59:51Z",
"expiration_at": "2023-09-30T23:59:59Z",
"invoice_requires_successful_payment": false,
"transaction_metadata": [
{
"key": "example_key",
"value": "example_value"
},
{
"key": "another_key",
"value": "another_value"
}
],
"transaction_name": "Tokens for models 'high-fidelity-boost'",
"ignore_paid_top_up_limits": false,
"applied_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z",
"invoice_custom_section": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "EU Bank Details",
"code": "eu_bank_details",
"description": "This section contains the bank details for EU customers.",
"details": "Bank Name: Lago Bank, IBAN: FR7630004000031234567890143",
"display_name": "Bank Details:",
"applied_to_organization": true,
"organization_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z"
},
"invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
],
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
}
],
"paid_top_up_min_amount_cents": 100,
"paid_top_up_max_amount_cents": 1000,
"applied_invoice_custom_sections": [
{
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z",
"invoice_custom_section": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "EU Bank Details",
"code": "eu_bank_details",
"description": "This section contains the bank details for EU customers.",
"details": "Bank Name: Lago Bank, IBAN: FR7630004000031234567890143",
"display_name": "Bank Details:",
"applied_to_organization": true,
"organization_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"created_at": "2023-07-06T14:35:58Z"
},
"invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
}
],
"payment_method": {
"payment_method_type": "provider",
"payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
},
"metadata": {
"external_id": "ext-123",
"synced_at": "2024-01-15",
"source": null
}
}
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 403,
"error": "Forbidden",
"code": "feature_unavailable"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/wallets" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"wallet": {
"name": "Prepaid",
"rate_amount": "1.5",
"paid_credits": "20.0",
"granted_credits": "10.0",
"currency": "USD",
"expiration_at": "2022-07-07",
"external_customer_id": "hooli_1234"
}
}'
from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models import Wallet
client = Client(api_key='__YOUR_API_KEY__')
wallet = Wallet(
name='Prepaid',
rate_amount='1.5',
paid_credits='20.0',
granted_credits='10.0',
currency='USD',
expiration_at='2022-07-07T23:59:59Z',
external_customer_id='hooli_1234'
)
try:
client.wallets.create(wallet)
except LagoApiError as e:
repair_broken_state(e) # do something on error or raise your own exception
require 'lago-ruby-client'
client = Lago::Api::Client.new(api_key: '__YOUR_API_KEY__')
client.wallets.create({
name: 'Prepaid',
rate_amount: '1.5',
paid_credits: '20.0',
granted_credits: '10.0',
currency: 'USD',
expiration_at: '2022-07-07T23:59:59Z',
external_customer_id: 'hooli_1234'
})
await client.wallets.createWallet({
wallet: {
name: "Prepaid",
currency: "USD",
rate_amount: 1.5,
paid_credits: 20.0,
granted_credits: 10.0,
expiration_at: "2022-07-07T23:59:59Z",
external_customer_id: "hooli_1234",
},
});
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().
SetApiKey("__YOUR_API_KEY__")
expirationAt := time.Date(2022, 7, 7, 23, 59, 59, 0, time.UTC)
walletInput := &lago.WalletInput{
Name: "Prepaid",
RateAmount: "1.5",
PaidCredits: "20.0"
GrantedCredits: "10.0",
Currency: "USD",
ExpirationAt: &expirationAt,
ExternalCustomerID: "hooli_1234",
}
wallet, err := lagoClient.Wallet().Create(walletInput)
if err != nil {
// Error is *lago.Error
panic(err)
}
// wallet is *lago.Wallet
fmt.Println(wallet)
}
⌘I