# Get the workspace's current subscription, plan and capabilities

Needs workspace:billing:view.

`GET /api/v1/public/workspaces/workspaceId/subscription`

- Sign-in: A signed-in user's session: send the session id in the x-session-id header.
- Rate limit: Up to 500 requests every 3 seconds per IP address; up to 1,000 requests a minute per API key (some requests are not counted).

Needs `workspace:billing:view`. Returns the subscription, its plan version, plan group, credits and what the customer may do to it (pause, cancel now, interval switch). A workspace that never held a plan is started on the org's onboarding plan on this first read.

## Request

| Field         | Type   | Required | Constraints | Description |
| ------------- | ------ | -------- | ----------- | ----------- |
| `workspaceId` | string | Yes      | -           | -           |

## Example request

Replace each `YOUR_...` value with your own, and set the credential in the environment variable the sample reads.

```bash title="cURL"
curl -X GET "https://api.console.buildbase.app/api/v1/public/workspaces/YOUR_WORKSPACE_ID/subscription" \
  -H "x-session-id: $BUILDBASE_SESSION_ID"
```

```ts title="TypeScript"
const response = await fetch(
  'https://api.console.buildbase.app/api/v1/public/workspaces/YOUR_WORKSPACE_ID/subscription',
  {
    method: 'GET',
    headers: {
      'x-session-id': process.env.BUILDBASE_SESSION_ID ?? '',
    },
  }
);
if (!response.ok) {
  throw new Error(`${response.status}: ${await response.text()}`);
}
const data = await response.json();
```

```python title="Python"
import os

import requests

response = requests.get(
    "https://api.console.buildbase.app/api/v1/public/workspaces/YOUR_WORKSPACE_ID/subscription",
    headers={
        "x-session-id": os.environ["BUILDBASE_SESSION_ID"],
    },
    timeout=30,
)
response.raise_for_status()
data = response.json()
```

## Responses

### 200 OK

OK

```json title="Example"
{
  "capabilities": {
    "cancelNow": {
      "enabled": false,
      "refund": "none",
      "refundWhenAllowanceUsed": "prorate_by_time"
    },
    "intervalSwitch": {
      "enabled": true
    },
    "pause": {
      "enabled": false,
      "maxMonths": 3
    }
  },
  "credits": {
    "available": 0,
    "totalConsumed": 0,
    "totalExpired": 0,
    "totalGranted": 0
  },
  "entitlement": {
    "decidedBy": {
      "onb-calls-1794380639113": "plan",
      "sso-1794380633736": "default"
    },
    "features": {
      "sso-1794380633736": false
    },
    "grants": [],
    "limits": {},
    "planSlug": "onboarding-free-1767225600000",
    "planVersionId": "000000000000000000000001",
    "quotas": {
      "onb-calls-1794380639113": {
        "allowOverage": false,
        "monthly": {
          "included": 100
        }
      }
    },
    "standing": "entitled",
    "subject": {
      "id": "000000000000000000000002",
      "type": "workspace"
    }
  },
  "featurePlanVersion": null,
  "group": {
    "_id": "000000000000000000000003",
    "archived": false,
    "createdAt": "2026-01-01T00:00:00.000Z",
    "deleted": false,
    "id": "000000000000000000000003",
    "isDefault": false,
    "latestVersion": {
      "_id": "000000000000000000000004",
      "archived": false,
      "createdAt": "2026-01-01T00:00:00.000Z",
      "deleted": false,
      "isCurrent": true,
      "isLegacy": false,
      "planVersionIds": ["000000000000000000000001"],
      "publishedAt": "2026-01-01T00:00:00.000Z",
      "requiredItems": [],
      "status": "published",
      "termsHash": "2b405ef8c061c9a1bc71684181c8b72ab7e28a2d4f3beb31e921c62c80c528be",
      "termsHashVersion": 1,
      "updatedAt": "2026-01-01T00:00:00.000Z",
      "version": 1
    },
    "name": "Onboarding 1767225600000",
    "payerType": "workspace",
    "slug": "onboarding-1767225600000",
    "updatedAt": "2026-01-01T00:00:00.000Z"
  },
  "groupVersion": {
    "_id": "000000000000000000000004",
    "archived": false,
    "createdAt": "2026-01-01T00:00:00.000Z",
    "deleted": false,
    "group": {
      "_id": "000000000000000000000003",
      "name": "Onboarding 1767225600000"
    },
    "id": "000000000000000000000004",
    "isCurrent": true,
    "isLegacy": false,
    "planVersionIds": [
      {
        "_id": "000000000000000000000001",
        "features": {},
        "limits": {},
        "name": "Version 1",
        "plan": {
          "_id": "000000000000000000000005",
          "isFreemium": true,
          "name": "Onboarding Free 1767225600000",
          "slug": "onboarding-free-1767225600000"
        },
        "quotas": {
          "onb-calls-1794380639113": {
            "allowOverage": false,
            "monthly": {
              "included": 100
            }
          }
        },
        "version": 1
      }
    ],
    "publishedAt": "2026-01-01T00:00:00.000Z",
    "requiredItems": [],
    "status": "published",
    "termsHash": "2b405ef8c061c9a1bc71684181c8b72ab7e28a2d4f3beb31e921c62c80c528be",
    "termsHashVersion": 1,
    "updatedAt": "2026-01-01T00:00:00.000Z",
    "version": 1
  },
  "migration": null,
  "plan": {
    "_id": "000000000000000000000005",
    "archived": false,
    "createdAt": "2026-01-01T00:00:00.000Z",
    "deleted": false,
    "id": "000000000000000000000005",
    "isFreemium": true,
    "latestVersion": {
      "_id": "000000000000000000000001",
      "archived": false,
      "createdAt": "2026-01-01T00:00:00.000Z",
      "deleted": false,
      "features": {},
      "isCurrent": true,
      "isLegacy": false,
      "limits": {},
      "name": "Version 1",
      "pricingVariants": [
        {
          "_id": "000000000000000000000006",
          "basePricing": {
            "monthly": 0
          },
          "currency": "usd",
          "quotaOverageMeters": {},
          "quotaOveragePriceIds": {},
          "quotaOverages": {},
          "seatPricing": {
            "enabled": false,
            "includedSeats": 0,
            "perSeat": {}
          },
          "seatStripePrices": {},
          "stripePrices": {}
        }
      ],
      "publishedAt": "2026-01-01T00:00:00.000Z",
      "quotas": {
        "onb-calls-1794380639113": {
          "allowOverage": false,
          "monthly": {
            "included": 100
          }
        }
      },
      "status": "published",
      "subscriptionItems": ["000000000000000000000007"],
      "termsHash": "f26fec2b01c5a8f44302f84dd3b5355cda9f6a2bb165534be753751541de6810",
      "termsHashVersion": 1,
      "updatedAt": "2026-01-01T00:00:00.000Z",
      "version": 1
    },
    "name": "Onboarding Free 1767225600000",
    "slug": "onboarding-free-1767225600000",
    "updatedAt": "2026-01-01T00:00:00.000Z",
    "versionMoves": {
      "mode": "off",
      "noticeDays": 30
    }
  },
  "planVersion": {
    "_id": "000000000000000000000001",
    "archived": false,
    "createdAt": "2026-01-01T00:00:00.000Z",
    "deleted": false,
    "features": {},
    "id": "000000000000000000000001",
    "isCurrent": true,
    "isLegacy": false,
    "limits": {},
    "name": "Version 1",
    "plan": {
      "_id": "000000000000000000000005",
      "archived": false,
      "isFreemium": true,
      "name": "Onboarding Free 1767225600000",
      "slug": "onboarding-free-1767225600000"
    },
    "pricingVariants": [
      {
        "_id": "000000000000000000000006",
        "basePricing": {
          "monthly": 0
        },
        "currency": "usd",
        "quotaOverageMeters": {},
        "quotaOveragePriceIds": {},
        "quotaOverages": {},
        "seatPricing": {
          "enabled": false,
          "includedSeats": 0,
          "perSeat": {}
        },
        "seatStripePrices": {},
        "stripePrices": {}
      }
    ],
    "publishedAt": "2026-01-01T00:00:00.000Z",
    "quotas": {
      "onb-calls-1794380639113": {
        "allowOverage": false,
        "monthly": {
          "included": 100
        }
      }
    },
    "status": "published",
    "subscriptionItems": [
      {
        "_id": "000000000000000000000007",
        "category": "000000000000000000000008",
        "name": "Onboarding calls 1767225600000",
        "slug": "onb-calls-1767225600000",
        "type": "quota"
      }
    ],
    "termsHash": "f26fec2b01c5a8f44302f84dd3b5355cda9f6a2bb165534be753751541de6810",
    "termsHashVersion": 1,
    "updatedAt": "2026-01-01T00:00:00.000Z",
    "version": 1
  },
  "scheduledAddOnChanges": [],
  "scheduledVersionChange": null,
  "subscription": {
    "_id": "000000000000000000000009",
    "cancelAtPeriodEnd": false,
    "canceledAt": null,
    "cancellation": null,
    "createdAt": "2026-01-01T00:00:00.000Z",
    "currency": null,
    "currentSeatCount": null,
    "discounts": [],
    "dunningState": "none",
    "featurePlanVersionUntil": null,
    "lastPaidInvoiceAt": null,
    "pause": null,
    "plan": {
      "_id": "000000000000000000000005",
      "currency": null,
      "description": null,
      "isFreemium": true,
      "name": "Onboarding Free 1767225600000",
      "slug": "onboarding-free-1767225600000"
    },
    "retentionUsed": false,
    "seatPricingEnabled": false,
    "stripeCurrentPeriodEnd": "2026-01-01T00:00:00.000Z",
    "subscriptionId": null,
    "subscriptionStatus": "active",
    "trialEnd": null,
    "trialStart": null,
    "updatedAt": "2026-01-01T00:00:00.000Z",
    "usageCurrentPeriodEnd": "2026-01-01T00:00:00.000Z"
  }
}
```

### Any other status

Any other answer the handler sends itself (its own refusals). Not described yet.

## Errors

Each refusal, what it means, and what to do. The request changed nothing.

### 401 Unauthorized

**What it means:** The credential is missing, expired or not accepted here, or the caller's role has no grant for `x-permission` (refused with 401 too). The body is the plain text `Unauthorized`, or a JSON body with a `code` where the gate says why.

**What to do:** Send the credential this operation asks for (see Sign-in above), or sign in again if it expired. A valid credential is also refused when the role has no grant for the permission above.

```text title="Example"
Unauthorized
```

### 429 Too Many Requests

**What it means:** A rate limit in `x-rateLimit` was reached. `retryAfter` and the `Retry-After` header say how many seconds until the window resets.

**What to do:** Wait the number of seconds in the `Retry-After` header (also `retryAfter` in the body), then retry. Slow down repeated calls.

```json title="Example"
{
  "success": false,
  "message": "string",
  "reason": "rate_limited",
  "retryAfter": 1
}
```

## Related

- [Workspaces guide](/workspaces/overview): how this part of BuildBase works
- [All Workspaces operations](/http-api/reference/workspaces)
- [API reference](/http-api/reference): every operation, by tag
- [Sign-in and credentials for the HTTP API](/http-api/authentication)
- [How the HTTP API reports errors](/http-api/errors)
- [Make your first call](/http-api/first-call)
- [Error codes](/reference/error-codes): every `code` the API returns
- OpenAPI: operation `workspaces.subscription.list` in [public-v1.json](https://docs.buildbase.app/openapi/public-v1.json)
