GET
/
api
/
v1
/
billing
/
state
Get billing state
curl --request GET \
  --url https://api.example.com/api/v1/billing/state
import 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_body

Overview

Combines two facts into a single read:
  1. 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.
  2. The caller’s subscription statusACTIVE, TRIALING, CANCELLED, EXPIRED, PAST_DUE, or NONE when the user has never subscribed.
The client uses these together: while 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

FieldTypeNotesExample
paywallActivebooleantrue 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
reasonenumlaunch_phase while paywallActive is still false; after_launch once it has flipped.launch_phase
currentListingsintegerLive count of CurrentHome rows where status === 'LIVE' AND ownerTenancyApproved === true. Read through the 60s cache.12
thresholdintegerThe launch-phase threshold. Currently 50 (PAYWALL_THRESHOLD_DEFAULT).50
subscriptionStatusenumACTIVE, 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

ValueMeaningSource RC event
NONEUser has never subscribed (no subscriptions row).
TRIALINGIn the 7-day free trial.INITIAL_PURCHASE with period_type === 'TRIAL'
ACTIVEPaid period in effect.RENEWAL, NON_RENEWING_PURCHASE, PRODUCT_CHANGE, UNCANCELLATION
CANCELLEDUser cancelled but still has access until currentPeriodEnd.CANCELLATION
EXPIREDPeriod ended; access revoked.EXPIRATION
PAST_DUEBilling failed or RC paused the subscription.BILLING_ISSUE, SUBSCRIPTION_PAUSED
The full RC → local status table is documented in Paywall and launch phase — Subscription state.

Error responses

StatusCodeMeaning
401UNAUTHENTICATEDMissing, 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

curl

curl https://api.swappr.co.uk/api/v1/billing/state \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Postman

See docs/postman/swappr.postman_collection.jsonBilling → Get state.