Get billing state
curl --request GET \
--url https://api.example.com/api/v1/billing/stateimport requests
url = "https://api.example.com/api/v1/billing/state"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/billing/state', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/billing/state",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/billing/state"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/billing/state")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/billing/state")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyBilling
Get billing state
Returns the user-facing paywall flag, the launch-phase counters, and the caller’s current subscription status.
GET
/
api
/
v1
/
billing
/
state
Get billing state
curl --request GET \
--url https://api.example.com/api/v1/billing/stateimport requests
url = "https://api.example.com/api/v1/billing/state"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/billing/state', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/billing/state",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/billing/state"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/billing/state")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/billing/state")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyOverview
Combines two facts into a single read:- The global paywall flag — is the 50-listing launch-phase threshold still active for the platform as a whole? See Paywall and launch phase for the rule and the one-way flip semantics.
- The caller’s subscription status —
ACTIVE,TRIALING,CANCELLED,EXPIRED,PAST_DUE, orNONEwhen the user has never subscribed.
paywallActive === false no purchase prompt is needed; once it flips to true, only users with subscriptionStatus ∈ { ACTIVE, TRIALING } retain access to paywalled features.
The paywall calculator is cached in Redis for 60 seconds (key
paywall:state:v1). Two requests within the same 60s window may return identical currentListings even if the live count just changed. The flip itself is one-way and durable — the cache TTL only affects how quickly clients observe a new flip, not whether the paywall stays on once it has flipped.Authentication
Bearer <accessToken> required. requireAuth middleware applied. requireOnboarded is NOT applied — pre-onboarded users still need to be able to read the paywall flag (e.g. to gate the onboarding CTA itself).
Path parameters
None.Query parameters
None.Request body
None.Response — 200 OK
| Field | Type | Notes | Example |
|---|---|---|---|
paywallActive | boolean | true once the platform has ever crossed the 50-listing threshold. Once true, never goes back to false in the same deployment (one-way flip — see concept page). | false |
reason | enum | launch_phase while paywallActive is still false; after_launch once it has flipped. | launch_phase |
currentListings | integer | Live count of CurrentHome rows where status === 'LIVE' AND ownerTenancyApproved === true. Read through the 60s cache. | 12 |
threshold | integer | The launch-phase threshold. Currently 50 (PAYWALL_THRESHOLD_DEFAULT). | 50 |
subscriptionStatus | enum | ACTIVE, TRIALING, CANCELLED, EXPIRED, PAST_DUE, or NONE if the user has never had a subscription row. Mirrored from the user’s denormalised subscriptionStatus field; the source of truth lives in the subscriptions collection. | NONE |
{
"paywallActive": false,
"reason": "launch_phase",
"currentListings": 12,
"threshold": 50,
"subscriptionStatus": "NONE"
}
After the flip + an active subscriber
{
"paywallActive": true,
"reason": "after_launch",
"currentListings": 87,
"threshold": 50,
"subscriptionStatus": "ACTIVE"
}
After the flip + a trial user
{
"paywallActive": true,
"reason": "after_launch",
"currentListings": 87,
"threshold": 50,
"subscriptionStatus": "TRIALING"
}
Subscription status values
| Value | Meaning | Source RC event |
|---|---|---|
NONE | User has never subscribed (no subscriptions row). | — |
TRIALING | In the 7-day free trial. | INITIAL_PURCHASE with period_type === 'TRIAL' |
ACTIVE | Paid period in effect. | RENEWAL, NON_RENEWING_PURCHASE, PRODUCT_CHANGE, UNCANCELLATION |
CANCELLED | User cancelled but still has access until currentPeriodEnd. | CANCELLATION |
EXPIRED | Period ended; access revoked. | EXPIRATION |
PAST_DUE | Billing failed or RC paused the subscription. | BILLING_ISSUE, SUBSCRIPTION_PAUSED |
Error responses
| Status | Code | Meaning |
|---|---|---|
| 401 | UNAUTHENTICATED | Missing, malformed, or expired access token. |
Example error — 401 UNAUTHENTICATED
{
"type": "https://api.swappr.co.uk/errors/unauthenticated",
"title": "Unauthenticated",
"status": 401,
"code": "UNAUTHENTICATED",
"detail": "Authenticated user required",
"instance": "/api/v1/billing/state",
"requestId": "01HZQ7K3M4N5P6Q7R8S9T0V1W2"
}
See also
- Paywall and launch phase — the rule, the one-way flip, the cache.
- Push notification fan-out — trial-ending pushes (deferred to Phase 7).
- RevenueCat webhook — how subscription status gets updated.
curl
curl https://api.swappr.co.uk/api/v1/billing/state \
-H "Authorization: Bearer $ACCESS_TOKEN"
Postman
Seedocs/postman/swappr.postman_collection.json → Billing → Get state.