### Start Local Development Server Source: https://github.com/salable/node-sdk/blob/main/docs/README.md Starts a local development server for live preview. Changes are reflected without server restart. ```bash $ yarn start ``` -------------------------------- ### Get Subscription Customer Portal Link Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/get-customer-portal-link.md Initializes the Salable SDK and retrieves a subscription by its UUID. This is a prerequisite for getting the customer portal link. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const subscription = await salable.subscriptions.getOne('a2188e78-2490-408e-93f6-35f829d05b49'); ``` -------------------------------- ### Install Dependencies Source: https://github.com/salable/node-sdk/blob/main/docs/README.md Installs project dependencies using yarn. ```bash $ yarn ``` -------------------------------- ### Get Checkout Link with Customer Details Source: https://github.com/salable/node-sdk/blob/main/docs/docs/plans/get-checkout-link.md This example demonstrates how to generate a checkout link while also providing customer-specific details such as their email address. This can pre-fill information in the checkout process. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const checkoutLink = await salable.plans.getCheckoutLink('15914694-5ff1-40d7-8ccb-7acc00586508', { cancelUrl: 'https://example.com/cancel', successUrl: 'https://example.com/success', granteeId: 'userId-1', owner: 'orgId_1', customerEmail: 'person@company.com', }); ``` -------------------------------- ### Products — Get All Source: https://context7.com/salable/node-sdk/llms.txt Returns a cursor-paginated list of all products created by your Salable organization. ```APIDOC ## Products — Get All Returns a cursor-paginated list of all products created by your Salable organization. ### Method Signature `salable.products.getAll()` ``` -------------------------------- ### Get Checkout Link - Required Parameters Source: https://github.com/salable/node-sdk/blob/main/docs/docs/plans/get-checkout-link.md This code sample demonstrates how to get a checkout link using only the required parameters: planUuid, successUrl, cancelUrl, granteeId, and owner. ```APIDOC ## Get Checkout Link ### Description Returns the checkout link for a plan. This endpoint will only work for paid Plans. ### Method POST (inferred from SDK usage, actual HTTP method not specified) ### Endpoint `/plans/{planUuid}/checkout-link` (inferred from SDK usage, actual endpoint not specified) ### Parameters #### Path Parameters - **planUuid** (string) - Required - The `uuid` of the Plan to get the checkout link from. #### Request Body - **successUrl** (string) - Required - The URL to send users if they have successfully completed a purchase. - **cancelUrl** (string) - Required - The URL to send users to if the transaction fails. - **granteeId** (string) - Required - Value to use as granteeId on Plan. - **owner** (string) - Required - The ID of the entity who will own the subscription. Default is the value given to member. - **promoCode** (string) - Optional - Enables the promo code field in Stripe checkout. Cannot be used with promoCode. - **currency** (string) - Optional - Shortname of the currency to be used in the checkout. The currency must be added to the plan's product in Salable. If not specified, it defaults to the currency selected on the product. - **quantity** (string) - Optional - Only applicable for per seat plans. Set the amount of seats the customer pays for in the checkout. - **customerEmail** (string) - Optional - Pre fills email for checkout customer. - **automaticTax** (string) - Optional - Automatically calculate tax on checkout based on customers location and your Stripe settings. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const checkoutLink = await salable.plans.getCheckoutLink('1de11022-ef14-4e22-94e6-c5b0652e497f', { cancelUrl: 'https://example.com/cancel', successUrl: 'https://example.com/success', granteeId: 'userId-1', owner: 'orgId_1' }); ``` ### Response #### Success Response (200) - **checkoutLink** (string) - The generated checkout link. ``` -------------------------------- ### Get All Products with Node.js SDK Source: https://github.com/salable/node-sdk/blob/main/docs/docs/products/get-all.md Use this snippet to fetch all products. Ensure you have initialized the Salable SDK with your API key and version. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const products = await salable.products.getAll(); ``` -------------------------------- ### Get All Products Source: https://github.com/salable/node-sdk/blob/main/docs/docs/products/get-all.md This snippet demonstrates how to use the `products.getAll()` method from the Salable Node.js SDK to retrieve a list of all products. ```APIDOC ## Get All Products ### Description Returns a list of all the products created by your Salable organization. ### Method GET ### Endpoint /v3/products ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of products to return. - **offset** (integer) - Optional - The number of products to skip before returning results. ### Response #### Success Response (200) - **data** (array) - A list of Product Objects. ### Response Example ```json { "data": [ { "id": "prod_123", "name": "Example Product", "description": "This is an example product.", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ] } ``` ``` -------------------------------- ### Get All Features Source: https://github.com/salable/node-sdk/blob/main/docs/docs/features/get-all.md Fetches a list of features for a given product with support for pagination and sorting. ```APIDOC ## Get All Features ### Description Returns a list of features with cursor based pagination. ### Method POST ### Endpoint /v3/features/all ### Parameters #### Query Parameters - **productUuid** (string) - Required - The product to retrieve features for. - **cursor** (string) - Optional - Cursor value, used for pagination. - **take** (number) - Optional - The number of features to fetch. Default: `20`. - **sort** (string) - Optional - Sort order, can be `asc` or `desc`. Default `asc`. ### Request Example ```json { "productUuid": "431b0c60-a145-4ae4-a7e6-391761b018ba", "cursor": "some_cursor_value", "take": 50, "sort": "desc" } ``` ### Response #### Success Response (200) - **data** (array) - A list of feature objects. - **meta** (object) - Pagination metadata, including the next cursor if available. #### Response Example ```json { "data": [ { "uuid": "feature-uuid-1", "name": "Feature Name 1", "description": "Description of Feature 1" }, { "uuid": "feature-uuid-2", "name": "Feature Name 2", "description": "Description of Feature 2" } ], "meta": { "nextCursor": "next_cursor_value" } } ``` ``` -------------------------------- ### Features - Get All Source: https://context7.com/salable/node-sdk/llms.txt Retrieves a cursor-paginated list of features for a given product. ```APIDOC ## Features — Get All `salable.features.getAll(options)` — Returns a cursor-paginated list of features for a given product. The `productUuid` parameter is required. ### Parameters #### Query Parameters - **productUuid** (string) - Required - The UUID of the product. - **sort** (string) - Optional - The sorting order ('asc' or 'desc'). - **take** (number) - Optional - The number of features to retrieve per page. ### Request Example ```typescript const features = await salable.features.getAll({ productUuid: '431b0c60-a145-4ae4-a7e6-391761b018ba', sort: 'asc', take: 50, }); ``` ### Response #### Success Response (200) - **first** (string) - The cursor for the first item. - **last** (string) - The cursor for the last item. - **data** (array) - An array of feature objects. - **slug** (string) - The slug of the feature. - **valueType** (string) - The type of the feature's value. ``` -------------------------------- ### Get Checkout Link - With Customer Email Source: https://github.com/salable/node-sdk/blob/main/docs/docs/plans/get-checkout-link.md This code sample shows how to get a checkout link including the customer's email address for pre-filling the checkout form. ```APIDOC ## Get Checkout Link with Customer Email ### Description Returns the checkout link for a plan, pre-filling the customer's email. ### Method POST (inferred from SDK usage, actual HTTP method not specified) ### Endpoint `/plans/{planUuid}/checkout-link` (inferred from SDK usage, actual endpoint not specified) ### Parameters #### Path Parameters - **planUuid** (string) - Required - The `uuid` of the Plan to get the checkout link from. #### Request Body - **successUrl** (string) - Required - The URL to send users if they have successfully completed a purchase. - **cancelUrl** (string) - Required - The URL to send users to if the transaction fails. - **granteeId** (string) - Required - Value to use as granteeId on Plan. - **owner** (string) - Required - The ID of the entity who will own the subscription. Default is the value given to member. - **customerEmail** (string) - Optional - Pre fills email for checkout customer. - **promoCode** (string) - Optional - Enables the promo code field in Stripe checkout. Cannot be used with promoCode. - **currency** (string) - Optional - Shortname of the currency to be used in the checkout. The currency must be added to the plan's product in Salable. If not specified, it defaults to the currency selected on the product. - **quantity** (string) - Optional - Only applicable for per seat plans. Set the amount of seats the customer pays for in the checkout. - **automaticTax** (string) - Optional - Automatically calculate tax on checkout based on customers location and your Stripe settings. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const checkoutLink = await salable.plans.getCheckoutLink('15914694-5ff1-40d7-8ccb-7acc00586508', { cancelUrl: 'https://example.com/cancel', successUrl: 'https://example.com/success', granteeId: 'userId-1', owner: 'orgId_1', customerEmail: 'person@company.com' }); ``` ### Response #### Success Response (200) - **checkoutLink** (string) - The generated checkout link. ``` -------------------------------- ### Plans — Get All Source: https://context7.com/salable/node-sdk/llms.txt Returns a cursor-paginated list of all plans in your organization, with optional filtering by product and archived status. ```APIDOC ## Plans — Get All Returns a cursor-paginated list of all plans in your organization, with optional filtering by product and archived status. ### Method Signature `salable.plans.getAll(options?)` ### Parameters - **options** (object) - Optional - Filtering and pagination options. - **productUuid** (string) - Optional - Filter plans by a specific product. - **archived** (boolean) - Optional - Include or exclude archived plans. - **sort** (string) - Optional - Sorting order ('asc' or 'desc'). - **take** (number) - Optional - Number of plans to retrieve per page. ``` -------------------------------- ### Get One Product Source: https://context7.com/salable/node-sdk/llms.txt Returns the details of a single product. Related entities such as 'features' and 'plans' can be optionally expanded. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const product = await salable.products.getOne( '3fe29048-28bf-461c-8498-c42c3572359c', { expand: ['features', 'plans'] } ); console.log(product.name); // 'My SaaS Product' console.log(product.plans.length); // 3 (expanded) console.log(product.features[0].slug); // 'storage-limit' (expanded) ``` -------------------------------- ### Get All Products Source: https://context7.com/salable/node-sdk/llms.txt Returns a cursor-paginated list of all products created by your Salable organization. The result includes pagination metadata and an array of product data. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const products = await salable.products.getAll(); // products = { first: 'prod-id-1', last: 'prod-id-n', data: [...] } products.data.forEach((p) => console.log(p.uuid, p.name)); ``` -------------------------------- ### Products — Get One Source: https://context7.com/salable/node-sdk/llms.txt Returns the details of a single product, with optional expansion of related `features` and `plans`. ```APIDOC ## Products — Get One Returns the details of a single product, with optional expansion of related `features` and `plans`. ### Method Signature `salable.products.getOne(productUuid, options?)` ### Parameters - **productUuid** (string) - Required - The unique identifier for the product. - **options** (object) - Optional - Expansion options. - **expand** (array of strings) - Optional - Related entities to expand (e.g., `['features', 'plans']`). ``` -------------------------------- ### Get All Features Source: https://context7.com/salable/node-sdk/llms.txt Fetches a cursor-paginated list of features for a given product. Requires a productUuid and supports sorting and pagination. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const features = await salable.features.getAll({ productUuid: '431b0c60-a145-4ae4-a7e6-391761b018ba', sort: 'asc', take: 50, }); // features = { first: 'feat-id-1', last: 'feat-id-n', data: [...] } features.data.forEach((f) => console.log(f.slug, f.valueType)); ``` -------------------------------- ### Get All Subscriptions - Node.js SDK Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/get-all.md Use this snippet to fetch all subscriptions. Ensure you have initialized the Salable SDK with your API key and version. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const subscription = await salable.subscriptions.getAll(); ``` -------------------------------- ### Get All Subscriptions Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/get-all.md Fetches a list of all subscriptions. You can filter, sort, and paginate the results using the options object. ```APIDOC ## Get All Subscriptions ### Description Returns a list of all the subscriptions created by your Salable organization. ### Method `subscriptions.getAll(options?: GetSubscriptionOptions)` ### Parameters #### options _Type:_ `GetSubscriptionOptions` | Option | Type | Description | Required | |-------------|--------|-------------------------------------------------------------------------|----------| | status | string | The status of the subscription, e.g. "ACTIVE" "CANCELED" | ❌ | | email | string | The email of who purchased the subscription | ❌ | | owner | string | The owner of the subscription | ❌ | | cursor | string | Cursor value, used for pagination | ❌ | | take | number | The number of subscriptions to fetch. Default: `20` | ❌ | | productUuid | string | Filter subscriptions by product | ❌ | | planUuid | string | Filter subscriptions by plan | ❌ | | sort | string | Sorts by expiryDate field. Default (`'asc'`). Enum: `'asc'` \| `'desc'` | ❌ | ### Return Type See [Subscription Object](https://docs.salable.app/api/v3#tag/Subscriptions/operation/getSubscriptions) for details on the subscription object structure. ``` -------------------------------- ### Get All Plans Source: https://context7.com/salable/node-sdk/llms.txt Returns a cursor-paginated list of all plans. Optional filtering by product and archived status is available. Use 'sort' and 'take' for pagination and ordering. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); // Get all active (non-archived) plans for a specific product const plans = await salable.plans.getAll({ productUuid: '431b0c60-a145-4ae4-a7e6-391761b018ba', archived: false, sort: 'asc', take: 20, }); // plans = { first: 'plan-id-1', last: 'plan-id-20', data: [...] } ``` -------------------------------- ### Get One Plan Source: https://context7.com/salable/node-sdk/llms.txt Returns the details of a single plan. Related entities like 'product', 'features', and 'currencies' can be optionally expanded. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const plan = await salable.plans.getOne( 'f965551b-5070-48df-b3aa-944c7ff876e0', { expand: ['product', 'features', 'currencies'] } ); console.log(plan.name); // 'Pro Plan' console.log(plan.product.name); // 'My SaaS Product' (expanded) console.log(plan.features[0].slug); // 'advanced-analytics' (expanded) ``` -------------------------------- ### Get All Usage Records Source: https://github.com/salable/node-sdk/blob/main/docs/docs/usage/get-records.md Initializes the Salable SDK and fetches all usage records for a given grantee ID. Ensure you replace '{{API_KEY}}' with your actual API key. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const records = await salable.usage.getAllUsageRecords({ granteeId: 'grantee_1' }); ``` -------------------------------- ### Plans — Get One Source: https://context7.com/salable/node-sdk/llms.txt Returns the details of a single plan, with optional expansion of related entities such as `product`, `features`, and `currencies`. ```APIDOC ## Plans — Get One Returns the details of a single plan, with optional expansion of related entities such as `product`, `features`, and `currencies`. ### Method Signature `salable.plans.getOne(planUuid, options?)` ### Parameters - **planUuid** (string) - Required - The unique identifier for the plan. - **options** (object) - Optional - Expansion options. - **expand** (array of strings) - Optional - Related entities to expand (e.g., `['product', 'features', 'currencies']`). ``` -------------------------------- ### Get Subscription Customer Portal Link Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/get-customer-portal-link.md This snippet demonstrates how to fetch the customer portal link for a subscription using its UUID. ```APIDOC ## Get Subscription Customer Portal Link ### Description Returns the customer portal link for a subscription. ### Method GET ### Endpoint /subscriptions/{subscriptionUuid}/portal-link ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The UUID of the subscription to be returned. ### Response #### Success Response (200) - **url** (string) - The URL to the customer portal for the subscription. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const portalLink = await salable.subscriptions.getCustomerPortalLink('a2188e78-2490-408e-93f6-35f829d05b49'); ``` ### Response Example ```json { "url": "https://app.salable.app/portal/subscriptions/a2188e78-2490-408e-93f6-35f829d05b49" } ``` ``` -------------------------------- ### Get Invoices for a Subscription Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/get-invoices.md This snippet demonstrates how to use the `getInvoices` method from the Salable Node.js SDK to retrieve all invoices for a given subscription. ```APIDOC ## Get Subscription Invoices ### Description Returns a list of invoices for a subscription. ### Method ```typescript salable.subscriptions.getInvoices(subscriptionUuid: string, options?: GetAllInvoicesOptions) ``` ### Parameters #### subscriptionUuid (_required_) _Type:_ `string` The UUID of the subscription. #### options _Type:_ `GetAllInvoicesOptions` | Option | Type | Description | Required | |----------|--------|--------------------------|----------| | cursor | string | Cursor value, for pagination | ❌ | | take | number | Number of subscriptions to fetch. Default: `10` | ❌ | ### Return Type See API documentation on [Subscription Invoice Object](https://docs.salable.app/api/v3#tag/Subscriptions/operation/getSubscriptionInvoices) ``` -------------------------------- ### Get Product by UUID Source: https://github.com/salable/node-sdk/blob/main/docs/docs/products/get-one.md This code snippet demonstrates how to retrieve a single product's details by providing its unique identifier (UUID) and optional expansion parameters. ```APIDOC ## Get Product by UUID ### Description Retrieves the details of a single product using its UUID. ### Method `GET` (Implicit, SDK method) ### Endpoint (Not directly exposed in SDK, abstracted by SDK method) ### Parameters #### Path Parameters - **productUuid** (string) - Required - The UUID of the Product to be returned. #### Query Parameters - **options.expand** (string[]) - Optional - Specify which properties to expand. e.g. `{ expand: ['features', 'plans'] }` ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const product = await salable.products.getOne('3fe29048-28bf-461c-8498-c42c3572359c'); ``` ### Response #### Success Response (200) - **Product Object** - See [Product Object](https://docs.salable.app/api/v3#tag/Products/operation/getProductByUuid) for details. #### Response Example (Refer to external API documentation for detailed response structure) ``` -------------------------------- ### Get Payment Method for Subscription Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/get-payment-method.md This code sample demonstrates how to use the `getPaymentMethod` function from the Salable Node.js SDK to retrieve the payment method of a subscription. ```APIDOC ## Get Payment Method for Subscription ### Description Retrieves the payment method associated with a specific subscription. ### Method `salable.subscriptions.getPaymentMethod(subscriptionUuid: string)` ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The UUID of the subscription for which to retrieve the payment method. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('YOUR_API_KEY', 'v3'); try { const paymentMethod = await salable.subscriptions.getPaymentMethod('07b3b494-a8f0-44f7-b051-add30c8c6002'); console.log('Payment Method:', paymentMethod); } catch (error) { console.error('Error fetching payment method:', error); } ``` ### Response #### Success Response (200) Returns a Subscription Payment Method Object. For details, refer to the [Subscription Payment Method Object documentation](https://docs.salable.app/api/v3#tag/Subscriptions/operation/getSubscriptionPaymentMethod). #### Error Response - **404 Not Found**: If the subscription with the provided UUID does not exist. - **401 Unauthorized**: If the API key is invalid or missing. - **500 Internal Server Error**: If there was an issue on the server. ``` -------------------------------- ### Subscriptions - Get All Source: https://context7.com/salable/node-sdk/llms.txt Returns a cursor-paginated list of all subscriptions in your Salable organization, with optional filters for status, owner, plan, product, and sort order. ```APIDOC ## Subscriptions — Get All `salable.subscriptions.getAll(options?)` — Returns a cursor-paginated list of all subscriptions in your Salable organization, with optional filters for status, owner, plan, product, and sort order. ### Parameters #### Query Parameters - **status** (string) - Optional - Filter by subscription status (e.g., 'ACTIVE', 'TRIALING', 'PAST_DUE'). - **owner** (string) - Optional - Filter by owner ID. - **planUuid** (string) - Optional - Filter by plan UUID. - **productUuid** (string) - Optional - Filter by product UUID. - **take** (integer) - Optional - The number of subscriptions to return per page. - **sort** (string) - Optional - The sort order for the results ('asc' or 'desc'). - **cursor** (string) - Optional - A cursor for fetching the next page of results. ### Response #### Success Response (200) - **first** (string) - Optional - Cursor for the first item on the page. - **last** (string) - Optional - Cursor for the last item on the page. - **data** (array) - An array of subscription objects. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); // Fetch active subscriptions for a specific product, paginated const result = await salable.subscriptions.getAll({ status: 'ACTIVE', productUuid: '7827727d-6fa9-46e6-b865-172ccda6f5a4', take: 20, sort: 'desc', }); // Cursor-based pagination // result = { first: 'sub-id-1', last: 'sub-id-20', data: [...] } if (result.last) { const nextPage = await salable.subscriptions.getAll({ status: 'ACTIVE', productUuid: '7827727d-6fa9-46e6-b865-172ccda6f5a4', take: 20, cursor: result.last, }); } ``` ``` -------------------------------- ### Get a specific pricing table Source: https://github.com/salable/node-sdk/blob/main/docs/docs/pricing-tables/get-one.md This code sample demonstrates how to retrieve a single pricing table by its UUID, along with optional grantee ID and currency. ```APIDOC ## Get One Pricing Table Returns all necessary data on a display a pricing table. ### Method ``` POST ``` ### Endpoint ``` /v3/pricing-tables/{pricingTableUuid} ``` ### Parameters #### Path Parameters - **pricingTableUuid** (string) - Required - The `uuid` of the Pricing Table to build #### Query Parameters - **granteeId** (string) - Optional - The unique identifier for the grantee - **currency** (string) - Optional - Uses the currency short name e.g. USD, defaults to the default currency on the Product which the Plan is linked to ### Request Example ```json { "example": "import { initSalable } from '@salable/node-sdk';\n\nconst salable = initSalable('{{API_KEY}}', 'v3');\n\nconst pricingTable = await salable.pricingTables.getOne('0c0ee2b7-2f3b-436b-8b4e-b21d0ddbf2a9', {\n granteeId: 'grantee_1',\n currency: 'USD'\n});" } ``` ### Response #### Success Response (200) - **pricingTable** (object) - Contains the pricing table data #### Response Example ```json { "example": "// Response structure depends on the pricing table configuration. Refer to API documentation for details." } ``` ``` -------------------------------- ### Paginated Response Structure Source: https://github.com/salable/node-sdk/blob/main/README.md Example of a paginated response structure for 'getAll' endpoints, featuring cursor-based pagination with 'first', 'last', and 'data' fields. ```json { "first": "item-id-1", "last": "item-id-3", "data": [ { "id": "item-id-1" }, { "id": "item-id-2" }, { "id": "item-id-3" } ] } ``` -------------------------------- ### Pricing Tables - Get One Source: https://context7.com/salable/node-sdk/llms.txt Retrieves all data for a specific saved pricing table configuration, optionally including grantee context and currency override. ```APIDOC ## Pricing Tables — Get One `salable.pricingTables.getOne(pricingTableUuid, options?)` — Returns all the data needed to render a specific saved pricing table configuration, with optional grantee context and currency override. ### Parameters #### Path Parameters - **pricingTableUuid** (string) - Required - The UUID of the pricing table to retrieve. #### Query Parameters - **granteeId** (string) - Optional - The ID of the grantee for context. - **currency** (string) - Optional - The currency code to override the default. ### Request Example ```typescript const pricingTable = await salable.pricingTables.getOne( '0c0ee2b7-2f3b-436b-8b4e-b21d0ddbf2a9', { granteeId: 'grantee_1', currency: 'USD', } ); ``` ### Response #### Success Response (200) - **plans** (array) - An array of plan objects. - **name** (string) - The name of the plan. - **price** (number) - The price of the plan in cents. - **isSubscribed** (boolean) - Whether the grantee is subscribed to the plan. ``` -------------------------------- ### Get Subscription Update Payment Link Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/get-payment-link.md This snippet demonstrates how to use the `getPortalLink` method from the Salable Node SDK to fetch an update payment link for a given subscription. ```APIDOC ## Get Subscription Update Payment Link ### Description Returns the update payment link for a specific subscription. ### Method `salable.subscriptions.getPortalLink(subscriptionUuid)` ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The UUID of the subscription. ### Return Type - **Subscription Payment Link Object** - See [Subscription Payment Link Object](https://docs.salable.app/api/v3#tag/Subscriptions/operation/getSubscriptionUpdatePaymentLink) for details. ``` -------------------------------- ### Salable API Versioning Example Source: https://github.com/salable/node-sdk/blob/main/README.md Demonstrates initializing the SDK with different API versions and highlights method availability based on the selected version. Note that 'licenses.check' is available in 'v2' but deprecated in 'v3'. ```typescript import { initSalable } from '@salable/node-sdk'; const salableV2 = initSalable('your_api_key', 'v2'); const salableV3 = initSalable('your_api_key', 'v3'); // "licenses.check" method is supported in this version and will work await salableV2.licenses.check(); // This will error as all "licenses" methods has been deprecated in 'v3' await salableV3.licenses.check(); // Will error with: "Property 'licenses' does not exist ..." ``` -------------------------------- ### Get a single plan by UUID Source: https://github.com/salable/node-sdk/blob/main/docs/docs/plans/get-one.md Fetches the details of a specific plan using its UUID. You can also expand related resources like 'product', 'features', and 'currencies' in the response. ```APIDOC ## Get One Plan ### Description Returns the details of a single plan. ### Method `GET` (Implicit via SDK method) ### Endpoint `/plans/{planUuid}` (Conceptual, SDK abstracts this) ### Parameters #### Path Parameters - **planUuid** (string) - Required - The `uuid` of the Plan to be returned. #### Query Parameters - **expand** (string[]) - Optional - Specify which properties to expand. e.g. `{ expand: ['product'] }` ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const plan = await salable.plans.getOne('f965551b-5070-48df-b3aa-944c7ff876e0', { expand: ['product', 'features', 'currencies'] }); ``` ### Response #### Success Response (200) - **plan object** - Details of the plan, potentially including expanded related resources. #### Response Example (See Salable API documentation for detailed plan object structure) ``` -------------------------------- ### Get All Plans with Node.js SDK Source: https://github.com/salable/node-sdk/blob/main/docs/docs/plans/get-all.md Initialize the Salable SDK and fetch a list of all plans. Ensure you replace '{{API_KEY}}' with your actual API key. This method supports cursor-based pagination. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const plans = await salable.plans.getAll(); ``` -------------------------------- ### Get One Product Details Source: https://github.com/salable/node-sdk/blob/main/docs/docs/products/get-one.md Initialize the Salable SDK and retrieve a product by its UUID. Ensure you replace '{{API_KEY}}' with your actual API key. The `expand` option can be used to include related data like features or plans. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); const product = await salable.products.getOne('3fe29048-28bf-461c-8498-c42c3572359c'); ``` -------------------------------- ### Create Subscription Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/create.md This code sample demonstrates how to create a new subscription using the Salable Node.js SDK. It initializes the SDK with an API key and version, then calls the `create` method on the subscriptions object with the necessary parameters. ```APIDOC ## Create Subscription ### Description Creates a new subscription for a given plan and owner. ### Method `subscriptions.create(data: CreateSubscriptionInput)` ### Parameters #### Data (required) Type: `CreateSubscriptionInput` | Option | Type | Description | |-------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | planUuid | string | The ID of the plan the subscription will belong to. | | granteeId | string | The ID of the entity who will be assigned to the license. If the plan is per seat and the minimum seat count is above one the granteeId will be assigned to the first license. The rest of the licenses will be unassigned. | | owner | string | The ID of the entity own the subscription. | | cancelAtPeriodEnd | boolean | If true the subscription will cancel after the expiry date has past. If false the subscription will renew. | | expiryDate | string | Overrides the plan default plan interval and length for the first cycle. | | status | string | The status of the create subscription. Allowed values are "ACTIVE" and "TRIALING". | ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); await salable.subscriptions.create({ planUuid: '41192f3a-fcfd-46e2-83db-0fd6a288ad5f', owner: 'orgId_1234', granteeId: 'userId_1', }); ``` ### Return Type Refer to the [Subscription Create](https://docs.salable.app/api/v3#tag/Subscriptions/operation/createSubscripion) API documentation for details on the return type. ``` -------------------------------- ### Build Static Website Source: https://github.com/salable/node-sdk/blob/main/docs/README.md Generates static website content for hosting. ```bash $ yarn build ``` -------------------------------- ### Subscriptions - Get Invoices Source: https://context7.com/salable/node-sdk/llms.txt Returns a cursor-paginated list of invoices for a subscription. ```APIDOC ## Subscriptions — Get Invoices `salable.subscriptions.getInvoices(subscriptionUuid, options?)` — Returns a cursor-paginated list of invoices for a subscription. ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The UUID of the subscription whose invoices to retrieve. #### Query Parameters - **take** (integer) - Optional - The number of invoices to return per page. Defaults to 10. - **cursor** (string) - Optional - A cursor for fetching the next page of results. ### Response #### Success Response (200) - **first** (string) - Optional - Cursor for the first item on the page. - **last** (string) - Optional - Cursor for the last item on the page. - **data** (array) - An array of invoice objects. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const invoices = await salable.subscriptions.getInvoices( '5fa0fbfa-5fbf-4fee-b286-ed1cb25379f9', { take: 10 } ); // invoices = { first: 'inv-id-1', last: 'inv-id-10', data: [...] } if (invoices.last) { const nextPage = await salable.subscriptions.getInvoices( '5fa0fbfa-5fbf-4fee-b286-ed1cb25379f9', { take: 10, cursor: invoices.last } ); } ``` ``` -------------------------------- ### Deploy Website (SSH) Source: https://github.com/salable/node-sdk/blob/main/docs/README.md Builds and deploys the website using SSH. Assumes SSH is configured for deployment. ```bash $ USE_SSH=true yarn deploy ``` -------------------------------- ### Events - Get One Source: https://context7.com/salable/node-sdk/llms.txt Retrieves a single Salable platform event by UUID. ```APIDOC ## Events — Get One `salable.events.getOne(eventUuid)` — Returns a single Salable platform event by UUID (e.g. webhook events for subscription state changes). ### Parameters #### Path Parameters - **eventUuid** (string) - Required - The UUID of the event to retrieve. ### Request Example ```typescript const event = await salable.events.getOne( '431b0c60-a145-4ae4-a7e6-391761b018ba' ); ``` ### Response #### Success Response (200) - **type** (string) - The type of the event (e.g., 'subscription.activated'). - **createdAt** (string) - The ISO date string when the event was created. - **data** (object) - The event payload object. ``` -------------------------------- ### Create Subscription with Node.js SDK Source: https://github.com/salable/node-sdk/blob/main/docs/docs/subscriptions/create.md Use this snippet to create a subscription for a given plan and owner. Ensure you have initialized the Salable SDK with your API key. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); await salable.subscriptions.create({ planUuid: '41192f3a-fcfd-46e2-83db-0fd6a288ad5f', owner: 'orgId_1234', granteeId: 'userId_1', }); ``` -------------------------------- ### Initialize Salable SDK with API Version Source: https://github.com/salable/node-sdk/blob/main/README.md Instantiate the SDK by providing your API key and the desired Salable API version. The API version is a required argument for instantiation. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); ``` -------------------------------- ### Get Payment Method Source: https://context7.com/salable/node-sdk/llms.txt Retrieves the payment method associated with a specific subscription. ```APIDOC ## Subscriptions — Get Payment Method `salable.subscriptions.getPaymentMethod(subscriptionUuid)` — Returns the payment method used to pay for a subscription. ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The unique identifier for the subscription. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const paymentMethod = await salable.subscriptions.getPaymentMethod( '07b3b494-a8f0-44f7-b051-add30c8c6002' ); console.log(paymentMethod.brand); console.log(paymentMethod.last4); ``` ### Response #### Success Response (200) - **brand** (string) - The brand of the payment method (e.g., 'visa'). - **last4** (string) - The last four digits of the payment method number. ``` -------------------------------- ### Get Cancel Subscription Link Source: https://context7.com/salable/node-sdk/llms.txt Generates a hosted link where a customer can cancel their subscription. ```APIDOC ## Subscriptions — Get Cancel Subscription Link `salable.subscriptions.getCancelSubscriptionLink(subscriptionUuid)` — Returns a hosted link where the customer can cancel their subscription. ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The unique identifier for the subscription. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const cancelLink = await salable.subscriptions.getCancelSubscriptionLink( 'ecc6868e-3ba5-4f10-b955-5dd46beb9602' ); console.log(cancelLink.url); ``` ### Response #### Success Response (200) - **url** (string) - The URL for canceling the subscription. ``` -------------------------------- ### SDK Initialization Source: https://context7.com/salable/node-sdk/llms.txt Initializes the Salable SDK client with an API key and the desired Salable API version ('v2' or 'v3'). Supports test mode with a 'test_' prefixed API key. ```APIDOC ## Initialization `initSalable(apiKey, version)` — Initialize the SDK client with an API key and Salable API version. ```typescript import { initSalable } from '@salable/node-sdk'; // Initialize for API v3 (latest, recommended) const salable = initSalable('your_api_key', 'v3'); // Initialize for API v2 (legacy support) const salableV2 = initSalable('your_api_key', 'v2'); // Test mode: use a test_ prefixed API key const salableTest = initSalable('test_your_api_key', 'v3'); ``` ``` -------------------------------- ### Get Seats Source: https://context7.com/salable/node-sdk/llms.txt Retrieves a paginated list of seats for a per-seat subscription, excluding canceled seats. ```APIDOC ## Subscriptions — Get Seats `salable.subscriptions.getSeats(subscriptionUuid, options?)` — Returns a cursor-paginated list of seats on a per-seat subscription. Seats with status `CANCELED` are excluded. ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The unique identifier for the subscription. #### Query Parameters - **options** (object) - Optional - Configuration for pagination. - **take** (number) - Optional - The number of seats to retrieve per page. Defaults to 20. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const seats = await salable.subscriptions.getSeats( '0dfc9ce9-4dfd-4b20-bfe6-57eacbe45389', { take: 20 } ); const assignedSeats = seats.data.filter((s) => s.granteeId !== null); console.log(`Assigned: ${assignedSeats.length} / ${seats.data.length}`); ``` ### Response #### Success Response (200) - **first** (string) - The ID of the first seat in the current page. - **last** (string) - The ID of the last seat in the current page. - **data** (array) - An array of seat objects. - **granteeId** (string | null) - The ID of the user assigned to the seat, or null if unassigned. ``` -------------------------------- ### Get Customer Portal Link Source: https://context7.com/salable/node-sdk/llms.txt Provides a link to the customer self-service portal for managing a subscription. ```APIDOC ## Subscriptions — Get Customer Portal Link `salable.subscriptions.getCustomerPortalLink(subscriptionUuid)` — Returns the customer self-service portal link for a subscription. ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The unique identifier for the subscription. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const portal = await salable.subscriptions.getCustomerPortalLink( 'a2188e78-2490-408e-93f6-35f829d05b49' ); console.log(portal.url); ``` ### Response #### Success Response (200) - **url** (string) - The URL for the customer self-service portal. ``` -------------------------------- ### Initialize Salable Node SDK with API Key and Version Source: https://github.com/salable/node-sdk/blob/main/docs/docs/overview.md Initialize the Salable SDK with your API key and optionally specify the API version. Use a test API key (prefixed with 'test_') for test mode. ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('{{API_KEY}}', 'v3'); ``` -------------------------------- ### Get Portal Link Source: https://context7.com/salable/node-sdk/llms.txt Generates a link for customers to update their payment details for a specific subscription. ```APIDOC ## Subscriptions — Get Portal Link `salable.subscriptions.getPortalLink(subscriptionUuid)` — Returns the Stripe update payment link for a specific subscription. ### Parameters #### Path Parameters - **subscriptionUuid** (string) - Required - The unique identifier for the subscription. ### Request Example ```typescript import { initSalable } from '@salable/node-sdk'; const salable = initSalable('your_api_key', 'v3'); const link = await salable.subscriptions.getPortalLink( '4264d425-697c-4b65-b189-0e747050bfff' ); console.log(link.url); ``` ### Response #### Success Response (200) - **url** (string) - The URL to redirect the user to update their payment details. ```