# Platform API

URL: https://docs.folkways.io/docs/platform-api

Read your workspace, segments, subscription and usage from your own servers, with the response envelope, paging, rate limits and errors.

The Platform API is the management API behind the Console. Your servers can call it with an
[API key](/docs/console/api-keys) to read your workspace, its segments, its subscription and its usage, for example to
feed your own dashboards or alerts. **It is read-only for API keys for now.** Changes are made in the Console.

<Callout>
  The Platform API manages Folkways. To publish and subscribe, use the [Realtime API](/docs/realtime-api).
</Callout>

## Base URL [#base-url]

```text
https://api.folkways.io/api/v1
```

Request and response bodies are JSON.

## Endpoints [#endpoints]

| Method | Path | API key access | Returns |
| --- | --- | --- | --- |
| `GET` | [`/organizations/{workspaceId}`](/docs/platform-api/workspaces) | Workspace | The workspace |
| `GET` | [`/organizations/{workspaceId}/segments`](/docs/platform-api/workspaces#list-segments) | Workspace | Its segments |
| `GET` | [`/segments/{segmentId}`](/docs/platform-api/segments) | Segment | One segment, with its effective limits |
| `GET` | [`/organizations/{workspaceId}/usage`](/docs/platform-api/usage) | Workspace | Usage over a time range |
| `GET` | [`/organizations/{workspaceId}/usage/period`](/docs/platform-api/usage#current-period) | Workspace | The current period against its allowances |
| `GET` | [`/segments/{segmentId}/usage`](/docs/platform-api/usage#segment-usage) | Segment | One segment's usage |
| `GET` | [`/organizations/{workspaceId}/subscription`](/docs/platform-api/subscription) | Workspace | The subscription and its plan |
| `GET` | [`/packages`](/docs/platform-api/catalog#packages) | none: public | The public packages |
| `GET` | [`/plans`](/docs/platform-api/catalog#plans), `/plans/{planId}` | none: public | Plans and their limits |
| `GET` | [`/rate-profiles`](/docs/platform-api/catalog#rate-profiles) | none: public | The rate presets' profiles |

The API calls workspaces *organizations* in paths and fields: they are the same thing.

## Example [#example]

```bash
curl https://api.folkways.io/api/v1/organizations/$WORKSPACE_ID/usage/period \
  -H "X-API-Key: $FOLKWAYS_API_KEY"
```

## Response envelope [#response-envelope]

Responses, successes and errors alike, come in one envelope. The exception is a request whose API key is missing,
invalid or not allowed: it is refused before the envelope, with an empty body (see [Errors](#errors)).

```json
{
  "status": "SUCCESS",
  "message": "…",
  "data": { "…": "the payload" },
  "meta": {
    "requestId": "5bbcd5c2-0d71-444b-9dd5-f24d02c22d36",
    "timestamp": "2026-12-01T14:50:32.169Z",
    "version": "v1"
  }
}
```

| Field | Meaning |
| --- | --- |
| `status` | `SUCCESS` or `ERROR` |
| `message` | A short, human-readable summary |
| `data` | The payload; its shape depends on the endpoint. Lists are a JSON array |
| `meta` | Always present: `requestId`, `timestamp`, `version`, and on paged lists `totalCount`, `page` and `limit` |
| `errors` | On errors only: `[{ "code", "message", "field", "details" }]` |

Conventions:

- **IDs** are UUIDs.
- **Timestamps** are ISO 8601 in UTC with milliseconds, e.g. `2026-12-01T14:50:32.169Z`.
- **Null fields are left out**, and object keys come in alphabetical order. Treat a missing field as "no value".
- **`X-Request-ID`**: every response carries one, the same as `meta.requestId`. Send your own to correlate logs; quote
  it when you contact support.

## Rate limits [#rate-limits]

API keys get **1,000 requests per minute** per key, or less if the key sets its own hourly limit. Every response
carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (Unix seconds). Over the limit you get
`429` with `RATE_LIMIT_EXCEEDED` and a `Retry-After` header in seconds.

## Errors [#errors]

| HTTP | `errors[0].code` | When |
| --- | --- | --- |
| `400` | `INVALID_ARGUMENT` | A bad path or query value, e.g. a malformed UUID or a bad time range |
| `400` | (no body) | An API key sent to an endpoint that doesn't name a workspace or segment, such as the public catalogue |
| `401` | (no body) | Missing, unknown, revoked, expired or paused API key |
| `403` | (no body) | The key has no access to the workspace or segment in the path |
| `403` | `FORBIDDEN`, `ACCESS_DENIED` | The endpoint needs a signed-in Console user |
| `404` | `RESOURCE_NOT_FOUND`, `ENDPOINT_NOT_FOUND` | No such resource or route |
| `429` | `RATE_LIMIT_EXCEEDED` | Over the rate limit; see `Retry-After` |
| `500` | `INTERNAL_SERVER_ERROR` | An unexpected error; `message` carries an error ID to quote to support |

Authentication failures of the API key itself are answered before the envelope, with an empty body.
