customers
Creates, updates, deletes, gets or lists a customers resource.
Overview​
| Name | customers |
| Type | Resource |
| Id | railway.billing.customers |
Fields​
The following fields are returned by SELECT queries:
- get
One Customer row.
| Name | Datatype | Description |
|---|---|---|
id | string | |
default_payment_method_id | string | |
stripe_customer_id | string | |
applied_credits | number | The total amount of credits that have been applied during the current billing period. |
billing_address | object | CustomerAddress object |
billing_email | string | |
billing_period | object | BillingPeriod object |
credit_balance | number | The total amount of unused credits for the customer. |
current_usage | number | The current usage for the customer. This value is cached and may not be up to date. |
default_payment_method | object | PaymentMethod object |
has_exhausted_free_plan | boolean | |
invoices | array | List of CustomerInvoice objects |
is_prepaying | boolean | |
is_trialing | boolean | |
is_usage_subscriber | boolean | |
is_withdrawing_to_credits | boolean | |
plan_limit_override | object | PlanLimitOverride object |
remaining_usage_credit_balance | number | |
spend_commitment | object | SpendCommitment object |
state | string | (ACTIVE, CANCELLED, INACTIVE, PAST_DUE, UNPAID) |
subscriptions | array | List of CustomerSubscription objects |
supported_withdrawal_platforms | array | |
tax_ids | array | List of CustomerTaxId objects |
trial_days_remaining | integer | |
usage_limit | object | UsageLimit object |
workspace | object | Workspace object |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | workspace_id | Gets a Customer of a Workspace. Backed by the Railway GraphQL query workspace.customer. | |
create_free_plan_subscription | exec | id | Create a free plan subscription for a customer. Backed by the Railway GraphQL mutation customerCreateFreePlanSubscription. | |
remove_usage_limit | exec | customer_id | Remove the usage limit for a customer. Backed by the Railway GraphQL mutation usageLimitRemove. | |
set_usage_limit | exec | customer_id, soft_limit_dollars | hard_limit_dollars | Set the usage limit for a customer. Backed by the Railway GraphQL mutation usageLimitSet. |
toggle_payouts_to_credits | exec | customer_id, is_withdrawing_to_credits | Toggle whether a customer is automatically withdrawing to credits. Backed by the Railway GraphQL mutation customerTogglePayoutsToCredits. |
Parameters​
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
workspace_id | string | |
customer_id | string | |
hard_limit_dollars | string | Integer passed as a string, for example '1'. |
id | string | |
is_withdrawing_to_credits | string | Boolean passed as a string, for example 'true'. |
soft_limit_dollars | string | Integer passed as a string, for example '1'. |
SELECT examples​
- get
Gets a Customer of a Workspace. Backed by the Railway GraphQL query workspace.customer.
SELECT
id,
default_payment_method_id,
stripe_customer_id,
applied_credits,
billing_address,
billing_email,
billing_period,
credit_balance,
current_usage,
default_payment_method,
has_exhausted_free_plan,
invoices,
is_prepaying,
is_trialing,
is_usage_subscriber,
is_withdrawing_to_credits,
plan_limit_override,
remaining_usage_credit_balance,
spend_commitment,
state,
subscriptions,
supported_withdrawal_platforms,
tax_ids,
trial_days_remaining,
usage_limit,
workspace
FROM railway.billing.customers
WHERE workspace_id = '{{ workspace_id }}' -- required
;
Lifecycle Methods​
- create_free_plan_subscription
- remove_usage_limit
- set_usage_limit
- toggle_payouts_to_credits
Create a free plan subscription for a customer. Backed by the Railway GraphQL mutation customerCreateFreePlanSubscription.
EXEC railway.billing.customers.create_free_plan_subscription
@id='{{ id }}' --required
;
Remove the usage limit for a customer. Backed by the Railway GraphQL mutation usageLimitRemove.
EXEC railway.billing.customers.remove_usage_limit
@customer_id='{{ customer_id }}' --required
;
Set the usage limit for a customer. Backed by the Railway GraphQL mutation usageLimitSet.
EXEC railway.billing.customers.set_usage_limit
@customer_id='{{ customer_id }}', --required
@soft_limit_dollars='{{ soft_limit_dollars }}', --required
@hard_limit_dollars='{{ hard_limit_dollars }}'
;
Toggle whether a customer is automatically withdrawing to credits. Backed by the Railway GraphQL mutation customerTogglePayoutsToCredits.
EXEC railway.billing.customers.toggle_payouts_to_credits
@customer_id='{{ customer_id }}', --required
@is_withdrawing_to_credits='{{ is_withdrawing_to_credits }}' --required
;