# Products ## List `products.list() -> ProductListResponse` **get** `/products` Lists all products for the workspace ### Returns - `class ProductListResponse: …` List of products - `data: List[Data]` - `id: str` Unique identifier for the product - `code: str` User-defined product identifier. - `created: datetime` ISO 8601 timestamp when the product was created - `description: str` Description of the product - `paid_by_roles: List[DataPaidByRole]` User roles that can pay for this product - `id: str` The unique ID of the role - `name: str` The name of the role - `paid_to_roles: List[DataPaidToRole]` User roles that receive payment for this product - `id: str` The unique ID of the role - `name: str` The name of the role - `update_version: float` Version number for optimistic locking - `workspace_id: str` Workspace ID this product belongs to ### Example ```python from fragment import Fragment client = Fragment() products = client.products.list() print(products.data) ``` ## Create `products.create(ProductCreateParams**kwargs) -> ProductCreateResponse` **post** `/products` Creates a new product ### Parameters - `code: str` Product code (unique identifier) - `description: str` Description of the product - `paid_by_roles: Optional[Iterable[PaidByRole]]` Roles that can pay for this product. Reference roles by id or name. At least one of paid_by_roles or paid_to_roles must be provided. - `class PaidByRoleRoleMatchByID: …` - `id: str` The unique ID of the role - `class PaidByRoleRoleMatchByName: …` - `name: str` The name of the role - `paid_to_roles: Optional[Iterable[PaidToRole]]` Roles that receive payment for this product. Reference roles by id or name. At least one of paid_by_roles or paid_to_roles must be provided. - `class PaidToRoleRoleMatchByID: …` - `id: str` The unique ID of the role - `class PaidToRoleRoleMatchByName: …` - `name: str` The name of the role ### Returns - `class ProductCreateResponse: …` - `data: Data` Product object - `id: str` Unique identifier for the product - `code: str` User-defined product identifier. - `created: datetime` ISO 8601 timestamp when the product was created - `description: str` Description of the product - `paid_by_roles: List[DataPaidByRole]` User roles that can pay for this product - `id: str` The unique ID of the role - `name: str` The name of the role - `paid_to_roles: List[DataPaidToRole]` User roles that receive payment for this product - `id: str` The unique ID of the role - `name: str` The name of the role - `update_version: float` Version number for optimistic locking - `workspace_id: str` Workspace ID this product belongs to ### Example ```python from fragment import Fragment client = Fragment() product = client.products.create( code="PROD_001", description="Premium subscription service", ) print(product.data) ``` ## Retrieve `products.retrieve(strcode) -> ProductRetrieveResponse` **get** `/products/{code}` Gets a product by code ### Parameters - `code: str` Product code ### Returns - `class ProductRetrieveResponse: …` - `data: Data` Product object - `id: str` Unique identifier for the product - `code: str` User-defined product identifier. - `created: datetime` ISO 8601 timestamp when the product was created - `description: str` Description of the product - `paid_by_roles: List[DataPaidByRole]` User roles that can pay for this product - `id: str` The unique ID of the role - `name: str` The name of the role - `paid_to_roles: List[DataPaidToRole]` User roles that receive payment for this product - `id: str` The unique ID of the role - `name: str` The name of the role - `update_version: float` Version number for optimistic locking - `workspace_id: str` Workspace ID this product belongs to ### Example ```python from fragment import Fragment client = Fragment() product = client.products.retrieve( "PROD_001", ) print(product.data) ```