### Search Discounts GET Request Source: https://docs.creem.io/api-reference/endpoint/search-discounts This OpenAPI definition describes the GET request for searching discounts. It includes parameters for pagination, filtering by product, status, type, and creation date. ```yaml openapi: 3.0.0 info: title: Creem API description: >- Creem is an all-in-one platform for managing subscriptions and recurring revenue, tailored specifically for today's SaaS companies. It enables you to boost revenue, enhance customer retention, and scale your operations seamlessly. version: v1 contact: name: Creem Support url: https://creem.io email: support@creem.io license: name: Commercial url: https://creem.io/terms termsOfService: https://creem.io/terms servers: - url: https://api.creem.io - url: https://test-api.creem.io security: [] tags: [] externalDocs: description: Creem Documentation url: https://docs.creem.io paths: /v1/discounts/search: get: tags: - Discounts summary: Search discounts description: Search and list discount codes for a store with filters and pagination. operationId: searchDiscounts parameters: - name: page_number required: false in: query description: The page number for pagination. schema: default: 1 example: 1 type: number - name: page_size required: false in: query description: The number of items per page. schema: default: 10 example: 10 type: number - name: product_id required: false in: query description: Filter discounts that apply to a specific product. schema: example: prod_1234567890 type: string - name: status required: false in: query description: Filter by discount status. schema: enum: - active - deleted type: string - name: type required: false in: query description: Filter by discount type. schema: enum: - percentage - fixed type: string - name: created_after required: false in: query description: Filter discounts created after this date. schema: example: '2024-01-01T00:00:00Z' type: string - name: created_before required: false in: query description: Filter discounts created before this date. schema: example: '2024-12-31T23:59:59Z' type: string responses: '200': description: Successfully retrieved the list of discounts content: application/json: schema: $ref: '#/components/schemas/DiscountListEntity' '400': description: Bad Request - Invalid input parameters '401': description: Unauthorized - Invalid or missing API key '404': description: Not Found - Resource does not exist security: - ApiKey: [] components: schemas: DiscountListEntity: type: object properties: items: description: List of discount items items: $ref: '#/components/schemas/DiscountEntity' type: array pagination: description: Pagination details for the list allOf: - $ref: '#/components/schemas/PaginationEntity' required: - items - pagination DiscountEntity: type: object properties: id: type: string description: Unique identifier for the object. mode: $ref: '#/components/schemas/EnvironmentMode' object: type: string description: >- A string representing the object’s type. Objects of the same type share the same value. example: discount status: type: string description: The status of the discount (e.g., active, inactive). enum: - deleted - active - draft - expired - scheduled example: active name: type: string description: The name of the discount. example: Holiday Sale code: type: string description: The discount code. A unique identifier for the discount. example: HOLIDAY2024 type: type: string description: The type of the discount, either "percentage" or "fixed". enum: - percentage - fixed example: percentage amount: type: number description: The amount of the discount. Can be a percentage or a fixed amount. example: 20 currency: type: string description: The currency of the discount. Only required if type is "fixed". example: USD percentage: ``` -------------------------------- ### Resource Not Found Error Response Source: https://docs.creem.io/api-reference/error-codes An example of a 404 Not Found error response, returned when a requested resource does not exist. ```json { "trace_id": "550e8400-e29b-41d4-a716-446655440000", "status": 404, "error": "Bad Request", "message": ["Product not found"], "timestamp": 1706889600000 } ``` -------------------------------- ### Next.js Checkout Integration Source: https://docs.creem.io/api-reference/introduction Example of setting up a Next.js API route for checkout using the Creem Next.js library. Configure your API key and test mode. ```typescript import { Checkout } from '@creem_io/nextjs'; export const GET = Checkout({ apiKey: process.env.CREEM_API_KEY!, testMode: process.env.NODE_ENV !== 'production', defaultSuccessUrl: '/success', }); ``` -------------------------------- ### Create Checkout Session Source: https://docs.creem.io/api-reference/endpoint/create-checkout Create a new checkout session to accept one-time payments or start subscriptions. Returns a checkout URL to redirect customers. ```APIDOC ## Create Checkout Session ### Description Create a new checkout session to accept one-time payments or start subscriptions. Returns a checkout URL to redirect customers. ### Method POST ### Endpoint /v1/checkout/sessions ### Request Body - **line_items** (array) - Required - List of items to be purchased. - **price** (string) - Required - The ID of the price object that represents the item being purchased. - **quantity** (integer) - Optional - The quantity of the item being purchased. ### Response #### Success Response (200) - **id** (string) - The ID of the checkout session. - **url** (string) - The URL to redirect the customer to complete the checkout. #### Response Example { "id": "cs_test_12345", "url": "https://checkout.creem.io/c/cs_test_12345" } ``` -------------------------------- ### List Account Entries OpenAPI Specification Source: https://docs.creem.io/api-reference/endpoint/list-credits-entries This OpenAPI specification defines the `GET /v1/customer-credits/accounts/{id}/entries` endpoint. It includes parameters for pagination such as `limit`, `starting_after`, and `ending_before`, and specifies response schemas for successful requests and error conditions. ```yaml get /v1/customer-credits/accounts/{id}/entries openapi: 3.0.0 info: title: Creem API description: >- Creem is an all-in-one platform for managing subscriptions and recurring revenue, tailored specifically for today's SaaS companies. It enables you to boost revenue, enhance customer retention, and scale your operations seamlessly. version: v1 contact: name: Creem Support url: https://creem.io email: support@creem.io license: name: Commercial url: https://creem.io/terms termsOfService: https://creem.io/terms servers: - url: https://api.creem.io - url: https://test-api.creem.io security: [] tags: [] externalDocs: description: Creem Documentation url: https://docs.creem.io paths: /v1/customer-credits/accounts/{id}/entries: get: tags: - Customer Credits - Accounts (Experimental) summary: List account entries description: List the credit and debit history for an account with cursor pagination. operationId: listCustomerCreditsAccountEntries parameters: - name: id required: true in: path schema: type: string - name: limit required: false in: query description: Maximum number of entries to return schema: minimum: 1 maximum: 100 default: 10 type: number - name: starting_after required: false in: query description: Cursor for forward pagination — entry ID to start after schema: type: string - name: ending_before required: false in: query description: Cursor for backward pagination — entry ID to end before schema: type: string responses: '200': description: Paginated list of entries content: application/json: schema: $ref: '#/components/schemas/EntryListResponseDto' '400': description: Bad Request - Invalid input parameters '401': description: Unauthorized - Invalid or missing API key '404': description: Not Found - Resource does not exist security: - ApiKey: [] components: schemas: EntryListResponseDto: type: object properties: object: type: string description: Object type example: list data: description: Array of entries type: array items: $ref: '#/components/schemas/EntryResponseDto' has_more: type: boolean description: Whether more items exist beyond this page required: - object - data - has_more EntryResponseDto: type: object properties: id: type: string description: Entry ID example: cce_abc123 transaction_id: type: string description: Transaction ID example: cct_abc123 account_id: type: string description: Account ID example: cca_abc123 side: type: string description: Debit or credit side enum: - debit - credit amount: type: string description: Amount as string for bigint safety example: '1000' created_at: type: string description: Creation timestamp required: - id - transaction_id - account_id - side - amount - created_at securitySchemes: ApiKey: type: apiKey in: header name: x-api-key description: >- API key for authentication. You can find your API key in the Creem dashboard under Settings > API Keys. ``` -------------------------------- ### Get Stats Summary Source: https://docs.creem.io/api-reference/endpoint/get-stats-summary Retrieves a summary of key statistics for a specified period. This endpoint is useful for getting an overview of business performance metrics. ```APIDOC ## GET /stats/summary ### Description Retrieves a summary of key statistics for a specified period. This endpoint is useful for getting an overview of business performance metrics. ### Method GET ### Endpoint /stats/summary ### Parameters #### Query Parameters - **period** (string) - Required - The period for which to retrieve stats (e.g., 'daily', 'weekly', 'monthly', 'yearly'). ### Response #### Success Response (200) - **totalProducts** (number) - Total number of products sold within the queried date range. - **totalSubscriptions** (number) - Total number of subscriptions sold within the queried date range. - **totalCustomers** (number) - Total number of customers within the queried date range. - **totalPayments** (number) - Total number of payments within the queried date range. - **activeSubscriptions** (number) - Number of currently active subscriptions. - **totalRevenue** (number) - Total gross revenue in cents within the queried date range. - **totalNetRevenue** (number) - Total net revenue in cents within the queried date range (after fees and taxes). - **netMonthlyRecurringRevenue** (number) - Net monthly recurring revenue in cents (after estimated fees). - **monthlyRecurringRevenue** (number) - Gross monthly recurring revenue in cents. #### Response Example { "totalProducts": 150, "totalSubscriptions": 100, "totalCustomers": 75, "totalPayments": 120, "activeSubscriptions": 50, "totalRevenue": 1000000, "totalNetRevenue": 900000, "netMonthlyRecurringRevenue": 50000, "monthlyRecurringRevenue": 55000 } ### Authentication API key for authentication. You can find your API key in the Creem dashboard under Settings > API Keys. Header: x-api-key: YOUR_API_KEY ``` -------------------------------- ### Create Checkout in Test Mode (cURL) Source: https://docs.creem.io/api-reference/introduction Use this cURL command to create a checkout session in test mode. Replace placeholders with your actual test API key and product ID. ```bash curl -X POST https://test-api.creem.io/v1/checkouts \ -H "x-api-key: YOUR_TEST_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "product_id": "prod_YOUR_PRODUCT_ID", "success_url": "https://yoursite.com/success" }' ``` -------------------------------- ### POST /v1/discounts Source: https://docs.creem.io/api-reference/endpoint/create-discount-code Create promotional discount codes for products. Set percentage or fixed amount discounts with expiration dates. ```APIDOC ## POST /v1/discounts ### Description Create promotional discount codes for products. Set percentage or fixed amount discounts with expiration dates. ### Method POST ### Endpoint /v1/discounts ### Request Body - **name** (string) - Required - The name of the discount. - **code** (string) - Optional - Optional discount code. If left empty, a code will be generated. - **type** (DiscountType) - Required - The type of the discount. - **amount** (number) - Optional - The fixed value for the discount. Only applicable if the type is "fixed". - **currency** (string) - Optional - The currency of the discount. Only required if type is "fixed". - **percentage** (number) - Optional - The percentage value for the discount. Only applicable if the type is "percentage". - **expiry_date** (string) - Optional - The expiry date of the discount. - **max_redemptions** (number) - Optional - The maximum number of redemptions for the discount. - **duration** (CouponDurationType) - Required - The duration of the discount. - **duration_in_months** (number) - Optional - The number of months the discount is valid for. Only applicable if the duration is "repeating" and the product is a subscription. - **applies_to_products** (array) - Required - The list of product IDs to which this discount applies. ### Request Example { "name": "Holiday Sale", "code": "HOLIDAY2024", "type": "percentage", "percentage": 15, "expiry_date": "2024-12-31T23:59:59Z", "duration": "repeating", "applies_to_products": [ "prod_123", "prod_456" ] } ### Response #### Success Response (200) - **id** (string) - Unique identifier for the object. - **mode** (EnvironmentMode) - The environment mode. - **object** (string) - A string representing the object’s type. - **status** (string) - The status of the discount. - **name** (string) - The name of the discount. - **code** (string) - The discount code. - **type** (string) - The type of the discount, either "percentage" or "fixed". - **amount** (number) - The fixed value for the discount. #### Response Example { "id": "disc_abc123", "mode": "test", "object": "discount", "status": "active", "name": "Holiday Sale", "code": "HOLIDAY2024", "type": "percentage", "amount": 15 } #### Error Response - **400**: Bad Request - Invalid input parameters - **401**: Unauthorized - Invalid or missing API key - **404**: Not Found - Resource does not exist ``` -------------------------------- ### Get Subscription Source: https://docs.creem.io/api-reference/endpoint/get-subscription Retrieves details of a specific subscription using its ID. ```APIDOC ## GET /v1/subscriptions/{id} ### Description Retrieves the details of a specific subscription. ### Method GET ### Endpoint /v1/subscriptions/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the subscription. ### Response #### Success Response (200) - **id** (string) - Unique identifier for the subscription. - **mode** (EnvironmentMode) - The environment mode (test, prod, sandbox). - **object** (string) - The object type, typically 'subscription'. - **customer_id** (string) - The ID of the customer associated with the subscription. - **status** (SubscriptionStatus) - The current status of the subscription. - **collection_method** (CollectionMethod) - The method used for collecting payments. - **created_at** (string) - The date and time when the subscription was created. - **updated_at** (string) - The date and time when the subscription was last updated. #### Response Example { "id": "sub_1234567890abcdef", "mode": "test", "object": "subscription", "customer_id": "cus_abcdef1234567890", "status": "active", "collection_method": "charge_automatically", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ``` -------------------------------- ### POST /v1/customer-credits/accounts Source: https://docs.creem.io/api-reference/endpoint/create-credits-account Create a new credits account for a customer. Optionally seed it with an initial balance. ```APIDOC ## POST /v1/customer-credits/accounts ### Description Create a new credits account for a customer. Optionally seed it with an initial balance. ### Method POST ### Endpoint /v1/customer-credits/accounts ### Request Body - **name** (string) - Optional - Human-readable name for the account. Defaults to 'default'. - **customer_id** (string) - Required - The owner ID this account belongs to (e.g. customer ID). - **unit_label** (string) - Optional - Label for the unit of currency/credits. Defaults to 'credits'. - **initial_balance** (string) - Optional - Seed the account with this many credits on creation. ### Request Example ```json { "name": "default", "customer_id": "cust_abc123", "unit_label": "credits", "initial_balance": "300" } ``` ### Response #### Success Response (201) - **id** (string) - Account ID - **store_id** (string) - Store ID - **customer_id** (string) - Owner ID - **name** (string) - Account name - **unit_label** (string) - Unit label - **status** (string) - Account status (active, frozen, closed) - **created_at** (string) - Creation timestamp - **updated_at** (string) - Last update timestamp #### Response Example ```json { "id": "cca_abc123", "store_id": "st_xyz789", "customer_id": "cust_abc123", "name": "default", "unit_label": "credits", "status": "active", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ``` ### Error Handling - **400**: Bad Request - Invalid input parameters - **401**: Unauthorized - Invalid or missing API key - **404**: Not Found - Resource does not exist ``` -------------------------------- ### Retrieve a customer credits account Source: https://docs.creem.io/api-reference/endpoint/get-credits-account Get details of a customer credits account by ID. ```APIDOC ## GET /v1/customer-credits/accounts/{id} ### Description Get details of a customer credits account by ID. ### Method GET ### Endpoint /v1/customer-credits/accounts/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the customer credits account. #### Request Body None ### Response #### Success Response (200) - **id** (string) - Account ID - **store_id** (string) - Store ID - **customer_id** (string) - Owner ID - **name** (string) - Account name - **unit_label** (string) - Unit label - **status** (string) - Account status (enum: active, frozen, closed) - **created_at** (string) - Creation timestamp - **updated_at** (string) - Last update timestamp #### Response Example ```json { "id": "cca_abc123", "store_id": "st_xyz789", "customer_id": "cust_abc123", "name": "default", "unit_label": "credits", "status": "active", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` #### Error Response - **400** - Bad Request - Invalid input parameters - **401** - Unauthorized - Invalid or missing API key - **404** - Not Found - Resource does not exist ``` -------------------------------- ### POST /v1/products Source: https://docs.creem.io/api-reference/endpoint/create-product Creates a new product for one-time payments or subscriptions. You can configure pricing, billing cycles, and features for the product. ```APIDOC ## POST /v1/products ### Description Creates a new product for one-time payments or subscriptions. Configure pricing, billing cycles, and features. ### Method POST ### Endpoint /v1/products ### Request Body - **name** (string) - Required - Name of the product - **description** (string) - Required - Description of the product - **image_url** (string) - Optional - URL of the product image - **price** (integer) - Required - The price of the product in cents. Must be 0 (free product) or at least 100 (one whole unit of the currency). - **currency** (string) - Required - The currency of the product (e.g., USD). - **billing_type** (string) - Required - The billing type for the product (e.g., recurring). - **billing_period** (string) - Optional - The billing period for recurring products (e.g., every-month). - **tax_mode** (string) - Optional - The tax mode for the product (e.g., inclusive). - **tax_category** (string) - Optional - The tax category for the product (e.g., saas). - **default_success_url** (string) - Optional - The URL to redirect to after successful payment. - **custom_fields** (array) - Optional - Collect additional information using custom fields (up to 3 supported). - **custom_field** (array) - Optional - DEPRECATED: Use `custom_fields` instead. - **abandoned_cart_recovery_enabled** (boolean) - Optional - Enable abandoned cart recovery for this product (defaults to false). ### Request Example ```json { "name": "Premium Subscription", "description": "Monthly subscription for premium features.", "price": 2000, "currency": "USD", "billing_type": "recurring", "billing_period": "every-month" } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the product. - **mode** (string) - The environment mode (e.g., live, test). - **object** (string) - Type of the object (e.g., product). - **name** (string) - The name of the product. - **description** (string) - A brief description of the product. - **image_url** (string) - URL of the product image. - **features** (array) - Features of the product. #### Response Example ```json { "id": "prod_12345", "mode": "test", "object": "product", "name": "Premium Subscription", "description": "Monthly subscription for premium features.", "image_url": "https://example.com/image.jpg", "features": [] } ``` ### Error Handling - **400** Bad Request - Invalid input parameters - **401** Unauthorized - Invalid or missing API key - **404** Not Found - Resource does not exist ``` -------------------------------- ### Retrieve a customer credits account Source: https://docs.creem.io/api-reference/endpoint/get-customer-credits-account Get details of a customer credits account by ID. ```APIDOC ## GET /v1/customer-credits/accounts/{id} ### Description Get details of a customer credits account by ID. ### Method GET ### Endpoint /v1/customer-credits/accounts/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the customer credits account. #### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **id** (string) - Account ID - **store_id** (string) - Store ID - **customer_id** (string) - Owner ID - **name** (string) - Account name - **unit_label** (string) - Unit label - **status** (string) - Account status (enum: active, frozen, closed) - **created_at** (string) - Creation timestamp - **updated_at** (string) - Last update timestamp #### Response Example ```json { "id": "cca_abc123", "store_id": "st_xyz789", "customer_id": "cust_abc123", "name": "default", "unit_label": "credits", "status": "active", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ``` #### Error Responses - **400** - Bad Request - Invalid input parameters - **401** - Unauthorized - Invalid or missing API key - **404** - Not Found - Resource does not exist ``` -------------------------------- ### GET /v1/transactions/search Source: https://docs.creem.io/api-reference/endpoint/get-transactions Search and retrieve payment transactions. You can filter by customer, product, date range, and status. ```APIDOC ## GET /v1/transactions/search ### Description Search and retrieve payment transactions. Filter by customer, product, date range, and status. ### Method GET ### Endpoint /v1/transactions/search ### Parameters #### Query Parameters - **customer_id** (string) - Optional - Filter transactions by customer ID. - **order_id** (string) - Optional - Filter transactions by order ID. - **product_id** (string) - Optional - Filter transactions by product ID. - **page_number** (number) - Optional - The page number for pagination. Defaults to 1. - **page_size** (number) - Optional - The number of items per page. Defaults to 10. ### Response #### Success Response (200) - **items** (array) - List of transactions items. - **pagination** (object) - Pagination details for the list. #### Response Example { "items": [ { "id": "txn_12345", "mode": "test", "object": "transaction", "amount": 2000, "amount_paid": 2000, "discount_amount": 0, "currency": "USD", "type": "charge", "tax_country": null, "tax_amount": 0, "status": "succeeded", "refunded_amount": 0, "order": "ord_abcde", "subscription": null } ], "pagination": { "next_cursor": "cursor_xyz", "has_more": true } } #### Error Response (400) Bad Request - Invalid input parameters #### Error Response (401) Unauthorized - Invalid or missing API key #### Error Response (404) Not Found - Resource does not exist ``` -------------------------------- ### Screen a prompt Source: https://docs.creem.io/api-reference/endpoint/screen-prompt Evaluate a text prompt against content policies before generation. This endpoint is experimental and may change. ```APIDOC ## POST /v1/moderation/prompt ### Description Evaluate a text prompt against content policies before generation. This endpoint is experimental and may change. ### Method POST ### Endpoint /v1/moderation/prompt ### Parameters #### Request Body - **prompt** (string) - Required - The text prompt to evaluate against content policies. - **external_id** (string) - Optional - An optional identifier to associate this request with. ### Request Example { "prompt": "This is a test prompt.", "external_id": "user-12345" } ### Response #### Success Response (200) - **id** (string) - Unique identifier for the moderation result. - **object** (string) - Object type. Example: moderation_result - **prompt** (string) - The prompt that was screened. - **external_id** (string) - The external identifier provided in the request. - **decision** (string) - The moderation decision. Enum: allow, deny, flag - **usage** (object) - Usage information for this call. - **units** (number) - Number of units consumed by this call. #### Response Example { "id": "mod_abc123", "object": "moderation_result", "prompt": "This is a test prompt.", "external_id": "user-12345", "decision": "allow", "usage": { "units": 1 } } #### Error Response (400) Bad Request - Invalid input parameters #### Error Response (401) Unauthorized - Invalid or missing API key #### Error Response (404) Not Found - Resource does not exist ``` -------------------------------- ### Create Customer Source: https://docs.creem.io/api-reference/endpoint/create-customer Creates a new customer record for the authenticated store. Requires an email and name for the customer. ```APIDOC ## POST /v1/customers ### Description Create a new customer record for the authenticated store. ### Method POST ### Endpoint /v1/customers ### Request Body - **email** (string) - Required - The email address of the customer. - **name** (string) - Required - The full name of the customer. - **metadata** (object) - Optional - Additional metadata for the customer. ### Request Example ```json { "email": "john@example.com", "name": "John Doe", "metadata": { "key": "value" } } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the object. - **mode** (string) - Environment mode (test, prod, sandbox). - **object** (string) - Type of the object. - **email** (string) - Customer email address. - **name** (string) - Customer name. - **metadata** (object) - Additional metadata associated with the customer. - **country** (string) - The ISO alpha-2 country code for the customer. - **created_at** (string) - Creation date of the customer. - **updated_at** (string) - Last updated date of the customer. #### Response Example ```json { "id": "cus_12345", "mode": "test", "object": "customer", "email": "user@example.com", "name": "John Doe", "metadata": { "key": "value" }, "country": "US", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ``` #### Error Responses - **400**: Bad Request - Invalid input parameters - **401**: Unauthorized - Invalid or missing API key - **404**: Not Found - Resource does not exist ``` -------------------------------- ### Error Handling Source: https://docs.creem.io/api-reference/endpoint/credit-account Details on the various error types that can be returned by the Creem API, including their structure and common examples. ```APIDOC ## Error Object Structure ### Description This object represents an error returned by the API. It includes a type, a machine-readable code, a human-readable message, and an optional parameter field. ### Fields - **type** (string) - Required - The type of error (e.g., `invalid_request_error`, `api_error`, `authentication_error`, `rate_limit_error`). - **code** (string) - Required - A machine-readable error code. - **message** (string) - Required - A human-readable error message. - **param** (string) - Optional - The parameter related to the error, if applicable. - **request_id** (string) - Required - A unique request identifier for support. ### Example ```json { "type": "invalid_request_error", "code": "unbalanced_transaction", "message": "Total debits must equal total credits", "param": "entries", "request_id": "req_abc123def456" } ``` ``` -------------------------------- ### Get Checkout Information Source: https://docs.creem.io/api-reference/endpoint/get-checkout Retrieves details about a specific checkout. This endpoint is useful for checking the status and contents of a checkout before or after a transaction. ```APIDOC ## GET /checkout/{id} ### Description Retrieves details about a specific checkout using its unique identifier. ### Method GET ### Endpoint /checkout/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the checkout. ### Response #### Success Response (200) - **id** (string) - Unique identifier for the object. - **mode** (EnvironmentMode) - The environment mode of the checkout. - **object** (string) - A string representing the object’s type. - **amount** (number) - The amount in cents. - **currency** (string) - Three-letter ISO currency code. - **type** (TransactionType) - The type of transaction. - **status** (TransactionStatus) - The status of the transaction. - **refunded_amount** (number) - The amount that has been refunded in cents. - **order** (string) - The order associated with the transaction. - **subscription** (string) - The subscription associated with the transaction. - **customer** (string) - The customer associated with the transaction. - **description** (string) - The description of the transaction. - **period_start** (number) - Start period for the invoice as timestamp. - **period_end** (number) - End period for the invoice as timestamp. - **created_at** (number) - Creation date of the order as timestamp. #### Response Example { "id": "ch_12345", "mode": "test", "object": "checkout", "amount": 2000, "currency": "USD", "type": "payment", "status": "open", "refunded_amount": 0, "order": null, "subscription": null, "customer": null, "description": "Example checkout", "period_start": 1678886400, "period_end": 1678886400, "created_at": 1678886400 } ``` -------------------------------- ### Activate License Source: https://docs.creem.io/api-reference/endpoint/activate-license This endpoint is used to activate a license instance. It requires a valid API key for authentication and accepts license details in the request body. ```APIDOC ## POST /licenses/{id}/activate ### Description Activates a specific license instance. ### Method POST ### Endpoint /licenses/{id}/activate ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the license to activate. #### Request Body - **mode** (string) - Required - The mode of the license (e.g., 'test', 'live'). - **object** (string) - Required - The type of object the license is for. - **name** (string) - Required - The name of the license. ### Request Example ```json { "mode": "live", "object": "product", "name": "My Product License" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the license instance. - **mode** (string) - The mode of the license. - **object** (string) - The type of object the license is for. - **name** (string) - The name of the license. - **status** (string) - The status of the license instance (e.g., 'active', 'deactivated'). - **created_at** (string) - The creation date of the license instance. #### Response Example ```json { "id": "license_abc123", "mode": "live", "object": "product", "name": "My Product License", "status": "active", "created_at": "2023-09-13T00:00:00Z" } ``` ### Security - **ApiKey**: API key for authentication. You can find your API key in the Creem dashboard under Settings > API Keys. ``` -------------------------------- ### Get Transaction by ID Source: https://docs.creem.io/api-reference/endpoint/get-transaction Retrieves a single transaction by its unique ID. You can view payment details, status, and associated order information. ```APIDOC ## GET /v1/transactions ### Description Retrieve a single transaction by ID. View payment details, status, and associated order information. ### Method GET ### Endpoint /v1/transactions ### Parameters #### Query Parameters - **transaction_id** (string) - Required - The unique identifier of the transaction. ### Responses #### Success Response (200) - **id** (string) - Unique identifier for the object. - **mode** (EnvironmentMode) - String representing the environment. - **object** (string) - String representing the object's type. Objects of the same type share the same value. - **amount** (number) - The transaction amount in cents. 1000 = $10.00 - **amount_paid** (number) - The amount the customer paid in cents. 1000 = $10.00 - **discount_amount** (number) - The discount amount in cents. 1000 = $10.00 - **currency** (string) - Three-letter ISO currency code, in uppercase. Must be a supported currency. - **type** (TransactionType) - The type of transaction. payment(one time payments) and invoice(subscription) - **tax_country** (string) - The ISO alpha-2 country code where tax is collected. - **tax_amount** (number) - The sale tax amount in cents. 1000 = $10.00 - **status** (TransactionStatus) - Status of the transaction. - **refunded_amount** (number) - The amount that has been refunded in cents. 1000 = $10.00 - **order** (string) - The order associated with the transaction. - **subscription** (string) - The subscription associated with the transaction. - **customer** (string) - The customer associated with the transaction. - **description** (string) - The description of the transaction. - **period_start** (number) - Start period for the invoice as timestamp - **period_end** (number) - End period for the invoice as timestamp - **created_at** (number) - Creation date of the order as timestamp #### Error Response - **400** - Bad Request - Invalid input parameters - **401** - Unauthorized - Invalid or missing API key - **404** - Not Found - Resource does not exist ``` -------------------------------- ### Create Checkout with TypeScript SDK Source: https://docs.creem.io/api-reference/introduction Integrate checkout creation using the Creem TypeScript SDK. Ensure your API key and test mode configuration are correctly set. ```typescript import { createCreem } from 'creem_io'; const creem = createCreem({ apiKey: process.env.CREEM_API_KEY!, testMode: process.env.NODE_ENV !== 'production', }); const checkout = await creem.checkouts.create({ productId: 'prod_abc123', successUrl: 'https://yoursite.com/success', }); ``` -------------------------------- ### Duplicate Resource Error Response Source: https://docs.creem.io/api-reference/error-codes An example of a 400 Bad Request error response indicating an attempt to create a resource that already exists. ```json { "trace_id": "550e8400-e29b-41d4-a716-446655440000", "status": 400, "error": "Bad Request", "message": ["A resource with this identifier already exists"], "timestamp": 1706889600000 } ``` -------------------------------- ### Validation Error Response Source: https://docs.creem.io/api-reference/error-codes An example of a 400 Bad Request error response indicating validation failures, such as missing or malformed request parameters. ```json { "trace_id": "550e8400-e29b-41d4-a716-446655440000", "status": 400, "error": "Bad Request", "message": ["product_id must be a string", "success_url must be a valid URL"], "timestamp": 1706889600000 } ``` -------------------------------- ### Retrieve Product Source: https://docs.creem.io/api-reference/endpoint/get-product Retrieves product details by ID. You can view pricing, billing type, status, and product configuration. ```APIDOC ## GET /v1/products ### Description Retrieves product details by ID. View pricing, billing type, status, and product configuration. ### Method GET ### Endpoint /v1/products ### Parameters #### Query Parameters - **product_id** (string) - Required - The unique identifier of the product. ### Responses #### Success Response (200) - **id** (string) - Unique identifier for the object. - **mode** (EnvironmentMode) - The environment mode of the product. - **object** (string) - String representing the object's type. - **name** (string) - The name of the product. - **description** (string) - A brief description of the product. - **image_url** (string) - URL of the product image. - **features** (array) - Features of the product. - **price** (number) - The price of the product in cents. - **currency** (string) - Three-letter ISO currency code, in uppercase. - **billing_type** (ProductBillingType) - The billing type of the product. - **billing_period** (ProductBillingPeriod) - The billing period of the product. - **status** (ProductStatus) - The status of the product. - **tax_mode** (TaxMode) - The tax mode for the product. - **tax_category** (TaxCategory) - The tax category for the product. - **product_url** (string) - The product page URL for express checkout. - **default_success_url** (string) - The URL to redirect to after successful payment. - **custom_fields** (array) - Custom fields configured for the product. - **created_at** (string) - Creation date of the product. - **updated_at** (string) - Last updated date of the product. #### Error Response - **400** - Bad Request - Invalid input parameters - **401** - Unauthorized - Invalid or missing API key - **404** - Not Found - Resource does not exist ``` -------------------------------- ### Authentication Error Response Source: https://docs.creem.io/api-reference/error-codes An example of a 403 Forbidden error response, typically returned when an API key is invalid or lacks necessary permissions. ```json { "trace_id": "550e8400-e29b-41d4-a716-446655440000", "status": 403, "error": "Forbidden", "timestamp": 1706889600000 } ``` -------------------------------- ### LicenseInstanceEntity Schema Source: https://docs.creem.io/api-reference/endpoint/create-checkout Represents a license instance, including its ID, name, status, and creation date. ```APIDOC ## LicenseInstanceEntity Schema ### Description Represents an instance of a license key assigned to a customer or environment. ### Properties - **id** (string) - Unique identifier for the license instance. - **mode** (EnvironmentMode) - The environment mode (e.g., test, live). - **object** (string) - A string representing the object’s type. Example: license-instance - **name** (string) - The name of the license instance. Example: My Customer License Instance - **status** (string) - The status of the license instance. Enum: active, deactivated. Example: active - **created_at** (string) - The creation date of the license instance in ISO 8601 format. Example: '2023-09-13T00:00:00Z' ### Required Properties - id - mode - object - name - status - created_at ```