Files
cfw-autumn/shared/openapi.yaml
John Yeo 9b6f57f872 feat: Add OpenAPI schemas for Features, Entities, Core, and Customers (ENG-628)
- Created operation models and OpenAPI specs for Features (Create, Update, List, Get, Delete)
- Created operation models and OpenAPI specs for Entities (Create, List, Get, Delete)
- Created operation models and OpenAPI specs for Core endpoints (Cancel, Track, Query)
- Created operation models and OpenAPI specs for Customers (Create, Update, List, Get, Delete)
- Fixed bug: Added 'archived' field to UpdateProductV2Params
- Fixed enum usage: Changed z.enum() to z.nativeEnum() for TypeScript enums
- Updated all OpenAPI specs to use requestParams format (path/query with zod schemas)
- Created shared SuccessResponseSchema in common/commonResponses.ts
- Updated models.ts to export all new schemas and OpenAPI operations
- Changed OpenAPI export to JSON format (YAML export has serialization issues with zod schemas)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-02 14:55:58 +01:00

800 lines
23 KiB
YAML

openapi: 3.1.0
info:
title: Autumn API
version: 1.2.0
servers:
- url: https://api.useautumn.com
description: Production server
security:
- secretKey: []
paths:
/products:
post:
summary: Create Product
tags:
- products
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateProductParams"
responses:
"200":
description: 200 OK
content:
application/json:
schema:
$ref: "#/components/schemas/Product"
patch:
summary: Update Product
tags:
- products
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateProductParams"
responses:
"200":
description: 200 OK
content:
application/json:
schema:
$ref: "#/components/schemas/Product"
components:
schemas:
CreateProductParams:
description: Create Product
type: object
properties:
id:
type: string
minLength: 1
pattern: ^[a-zA-Z0-9_-]+$
name:
type: string
is_add_on:
default: false
type: boolean
is_default:
default: false
type: boolean
version:
type: number
group:
default: ""
type: string
items:
type: array
items:
type: object
properties:
feature_id:
anyOf:
- type: string
- type: "null"
feature_type:
anyOf:
- type: string
enum:
- single_use
- continuous_use
- boolean
- static
- type: "null"
included_usage:
anyOf:
- anyOf:
- type: number
- type: string
const: inf
- type: "null"
interval:
anyOf:
- type: string
enum:
- minute
- hour
- day
- week
- month
- quarter
- semi_annual
- year
- type: "null"
interval_count:
anyOf:
- type: number
- type: "null"
entity_feature_id:
anyOf:
- type: string
- type: "null"
usage_model:
anyOf:
- type: string
enum:
- prepaid
- pay_per_use
- type: "null"
price:
anyOf:
- type: number
- type: "null"
tiers:
anyOf:
- type: array
items:
type: object
properties:
to:
anyOf:
- type: number
- type: string
const: inf
amount:
type: number
required:
- to
- amount
- type: "null"
billing_units:
anyOf:
- type: number
- type: "null"
usage_limit:
anyOf:
- type: number
- type: "null"
reset_usage_when_enabled:
anyOf:
- type: boolean
- type: "null"
config:
anyOf:
- type: object
properties:
on_increase:
anyOf:
- type: string
enum:
- bill_immediately
- prorate_immediately
- prorate_next_cycle
- bill_next_cycle
- type: "null"
on_decrease:
anyOf:
- type: string
enum:
- prorate
- prorate_immediately
- prorate_next_cycle
- none
- no_prorations
- type: "null"
rollover:
anyOf:
- type: object
properties:
max:
anyOf:
- type: number
- type: "null"
duration:
default: month
type: string
enum:
- month
- forever
length:
type: number
required:
- max
- length
- type: "null"
- type: "null"
created_at:
anyOf:
- type: number
- type: "null"
entitlement_id:
anyOf:
- type: string
- type: "null"
price_id:
anyOf:
- type: string
- type: "null"
price_config:
anyOf:
- {}
- type: "null"
free_trial:
anyOf:
- type: object
properties:
length:
anyOf:
- type: string
- type: number
unique_fingerprint:
default: false
type: boolean
duration:
default: day
type: string
enum:
- day
- month
- year
card_required:
default: true
type: boolean
required:
- length
- type: "null"
required:
- id
- name
UpdateProductParams:
description: Update Product
type: object
properties:
id:
type: string
minLength: 1
pattern: ^[a-zA-Z0-9_-]+$
name:
type: string
is_add_on:
type: boolean
is_default:
type: boolean
version:
type: number
group:
type: string
items:
type: array
items:
type: object
properties:
feature_id:
anyOf:
- type: string
- type: "null"
feature_type:
anyOf:
- type: string
enum:
- single_use
- continuous_use
- boolean
- static
- type: "null"
included_usage:
anyOf:
- anyOf:
- type: number
- type: string
const: inf
- type: "null"
interval:
anyOf:
- type: string
enum:
- minute
- hour
- day
- week
- month
- quarter
- semi_annual
- year
- type: "null"
interval_count:
anyOf:
- type: number
- type: "null"
entity_feature_id:
anyOf:
- type: string
- type: "null"
usage_model:
anyOf:
- type: string
enum:
- prepaid
- pay_per_use
- type: "null"
price:
anyOf:
- type: number
- type: "null"
tiers:
anyOf:
- type: array
items:
type: object
properties:
to:
anyOf:
- type: number
- type: string
const: inf
amount:
type: number
required:
- to
- amount
- type: "null"
billing_units:
anyOf:
- type: number
- type: "null"
usage_limit:
anyOf:
- type: number
- type: "null"
reset_usage_when_enabled:
anyOf:
- type: boolean
- type: "null"
config:
anyOf:
- type: object
properties:
on_increase:
anyOf:
- type: string
enum:
- bill_immediately
- prorate_immediately
- prorate_next_cycle
- bill_next_cycle
- type: "null"
on_decrease:
anyOf:
- type: string
enum:
- prorate
- prorate_immediately
- prorate_next_cycle
- none
- no_prorations
- type: "null"
rollover:
anyOf:
- type: object
properties:
max:
anyOf:
- type: number
- type: "null"
duration:
default: month
type: string
enum:
- month
- forever
length:
type: number
required:
- max
- length
- type: "null"
- type: "null"
created_at:
anyOf:
- type: number
- type: "null"
entitlement_id:
anyOf:
- type: string
- type: "null"
price_id:
anyOf:
- type: string
- type: "null"
price_config:
anyOf:
- {}
- type: "null"
free_trial:
anyOf:
- type: object
properties:
length:
anyOf:
- type: string
- type: number
unique_fingerprint:
default: false
type: boolean
duration:
default: day
type: string
enum:
- day
- month
- year
card_required:
default: true
type: boolean
required:
- length
- type: "null"
archived:
type: boolean
Product:
description: A product
type: object
properties:
id:
description: The ID of the product you set when creating the product
example: pro_plan
type: string
name:
description: The name of the product
example: Pro Plan
type: string
group:
description: The group of the product
example: product_set_1
anyOf:
- type: string
- type: "null"
env:
description: The environment of the product
example: production
type: string
enum:
- sandbox
- live
is_add_on:
description: Whether the product is an add-on and can be purchased alongside
other products
example: true
type: boolean
is_default:
description: Whether the product is the default product
example: true
type: boolean
archived:
description: Whether this product has been archived and is no longer available
example: false
type: boolean
version:
description: The version of the product
example: 1
type: number
created_at:
description: The timestamp of when the product was created in milliseconds since
epoch
example: 1759247877000
type: number
items:
description: Array of product items that define the features and pricing
example:
- feature_id: <string>
feature_type: single_use
included_usage: 123
interval: <string>
usage_model: prepaid
price: 123
billing_units: 123
entity_feature_id: <string>
reset_usage_when_enabled: true
tiers:
- to: 123
amount: 123
type: array
items:
$ref: "#/components/schemas/ProductItem"
free_trial:
description: Free trial configuration for this product, if available
example:
duration: <string>
length: 123
unique_fingerprint: true
anyOf:
- type: object
properties:
duration:
type: string
enum:
- day
- month
- year
length:
type: number
unique_fingerprint:
type: boolean
card_required:
type: boolean
trial_available:
default: true
anyOf:
- type: boolean
- type: "null"
required:
- duration
- length
- unique_fingerprint
- card_required
- trial_available
additionalProperties: false
- type: "null"
base_variant_id:
description: ID of the base variant this product is derived from
example: var_1234567890abcdef
anyOf:
- type: string
- type: "null"
scenario:
description: Scenario context for when this product is used in attach flows
example: upgrade
type: string
enum:
- scheduled
- active
- new
- renew
- upgrade
- downgrade
- cancel
- expired
properties:
description: Additional properties and metadata for the product
example:
is_free: false
is_one_off: false
interval_group: monthly
has_trial: true
updateable: true
type: object
properties:
is_free:
description: True if the product has no base price or usage prices
example: false
type: boolean
is_one_off:
description: True if the product only contains a one-time price
example: false
type: boolean
interval_group:
description: The billing interval group for recurring products (e.g., 'monthly',
'yearly')
example: monthly
anyOf:
- type: string
- type: "null"
has_trial:
description: True if the product includes a free trial
example: true
anyOf:
- type: boolean
- type: "null"
updateable:
description: True if the product can be updated after creation (only applicable
if there are prepaid recurring prices)
example: true
anyOf:
- type: boolean
- type: "null"
required:
- is_free
- is_one_off
additionalProperties: false
required:
- id
- name
- group
- env
- is_add_on
- is_default
- archived
- version
- created_at
- items
- free_trial
- base_variant_id
additionalProperties: false
ProductItem:
description: A product item that defines a feature
example:
feature_id: feature_1
feature_type: single_use
included_usage: 123
interval: monthly
usage_model: prepaid
type: object
properties:
type:
anyOf:
- type: string
enum:
- feature
- priced_feature
- price
- type: "null"
feature_id:
anyOf:
- type: string
- type: "null"
feature_type:
anyOf:
- type: string
enum:
- single_use
- continuous_use
- boolean
- static
- type: "null"
feature:
anyOf:
- type: object
properties:
id:
type: string
name:
anyOf:
- type: string
- type: "null"
type:
type: string
enum:
- boolean
- single_use
- continuous_use
- credit_system
display:
anyOf:
- type: object
properties:
singular:
type: string
plural:
type: string
required:
- singular
- plural
additionalProperties: false
- type: "null"
credit_schema:
anyOf:
- type: array
items:
type: object
properties:
metered_feature_id:
type: string
credit_cost:
type: number
required:
- metered_feature_id
- credit_cost
additionalProperties: false
- type: "null"
archived:
anyOf:
- type: boolean
- type: "null"
required:
- id
- type
additionalProperties: false
- type: "null"
included_usage:
anyOf:
- anyOf:
- type: number
- type: string
const: inf
- type: "null"
interval:
anyOf:
- type: string
enum:
- minute
- hour
- day
- week
- month
- quarter
- semi_annual
- year
- type: "null"
interval_count:
anyOf:
- type: number
- type: "null"
price:
anyOf:
- type: number
- type: "null"
tiers:
anyOf:
- type: array
items:
type: object
properties:
to:
anyOf:
- type: number
- type: string
const: inf
amount:
type: number
required:
- to
- amount
additionalProperties: false
- type: "null"
usage_model:
anyOf:
- type: string
enum:
- prepaid
- pay_per_use
- type: "null"
billing_units:
anyOf:
- type: number
- type: "null"
reset_usage_when_enabled:
anyOf:
- type: boolean
- type: "null"
quantity:
anyOf:
- type: number
- type: "null"
next_cycle_quantity:
anyOf:
- type: number
- type: "null"
entity_feature_id:
anyOf:
- type: string
- type: "null"
display:
anyOf:
- type: object
properties:
primary_text:
type: string
secondary_text:
anyOf:
- type: string
- type: "null"
required:
- primary_text
additionalProperties: false
- type: "null"
additionalProperties: false
AutumnError:
description: An error that occurred in the API
type: object
properties:
message:
type: string
code:
type: string
env:
type: string
enum:
- sandbox
- live
required:
- message
- code
- env
additionalProperties: false
securitySchemes:
secretKey:
type: http
scheme: bearer
bearerFormat: JWT