Overview
- Versioned base path:
/v1/ - Plural resource names:
/v1/customers/,/v1/orders/ - Standard methods:
GET,POST,PATCH,DELETE - Consistent schemas across list and get responses
- No shape-changing parameters (avoid toggling fields on/off in responses)
Core conventions
- Always use
polar.kit.Schema(orTimestampedSchemawhen timestamps exist) - Snake_case field names
- Add docstrings, field descriptions, and meaningful examples
- Separate read/create/update schemas; updates must be partial (all fields optional)
- Validation errors should return
422 Unprocessable Entityin FastAPI format viaPolarRequestValidationError
Schemas
Our schemas are defined in our Python backend using Pydantic models. Each schema represents a resource to read, create, or update. Inherit frompolar.kit.Schema
created_at or updated_at fields, inherit from polar.kit.TimestampedSchema
None, allowing clients to update only the fields they need.
Endpoints
Authentication Subjects
All authenticated endpoints should clearly define the authentication subject, which can be one of the following:- User: An individual user authenticated via PAT, OAuth access token or web session cookie.
- Organization: An organization authenticated via an OAT or OAuth access token.
- Customer: A customer authenticated via a Customer Session.
List endpoints
List endpoints return a list of resources and support filtering, pagination, and sorting.-
Filtering: By default, no filter is applied; return all resources the subject can access. Avoid implicit filters like
active=true. Allow repeated query parameters for multi-value filters: -
Pagination: Page-based with
pageandlimit. -
Sorting: Use
sortingwith comma-separated fields; prefix with-for descending: -
For endpoints supporting User subject, they’ll typically expect an
organization_idfilter to scope results to a specific organization. If not set return resources across all organizations the subject has access to. -
Response shape:
- Do not add parameters that change the response schema. Use separate endpoints if different representations are needed.
Get endpoints
- Retrieve a single resource by its unique identifier (typically ID).
- Response schema matches the list item schema.
- Do not add parameters that change the response schema; prefer separate endpoints for alternate representations.
Create endpoints
- Request body uses the create schema.
- On validation errors, return
422 Unprocessable Entitywith FastAPI-style details (PolarRequestValidationError). - On success, return
201 Createdwith the read schema.
Update endpoints
- Request body uses the update schema (partial updates allowed).
- On validation errors, return
422 Unprocessable Entitywith FastAPI-style details (PolarRequestValidationError). - On success, return
200 OKwith the read schema.
Delete endpoints
- Delete an existing resource.
- On success, return
204 No Contentwith an empty response body.

