### GET /v1/publications/create Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/ENDPOINTS-COVERAGE.md Create a publication using GET request parameters. This endpoint allows you to create a new publication with stackable discounts and promotional offers. ```APIDOC ## GET /v1/publications/create ### Description Create Publication with GET method. This endpoint allows creating a new publication using query parameters instead of a request body. ### Method GET ### Endpoint /v1/publications/create ### Parameters #### Query Parameters - **campaign_id** (string) - Required - The ID of the campaign for the publication - **customer_id** (string) - Optional - The ID of the customer to publish to - **channel** (string) - Optional - The channel through which the publication is distributed ### Response #### Success Response (200) - **id** (string) - Unique publication identifier - **object** (string) - Object type: "publication" - **created_at** (string) - Publication creation timestamp - **campaign_id** (string) - Associated campaign ID - **customer_id** (string) - Associated customer ID #### Response Example { "id": "pub_abc123xyz", "object": "publication", "created_at": "2024-01-15T10:30:00Z", "campaign_id": "camp_xyz789", "customer_id": "cust_123abc" } ``` -------------------------------- ### Initialize Voucherify SDK with API Key Authentication Source: https://context7.com/voucherifyio/voucherify-js-sdk/llms.txt Configure the Voucherify JavaScript SDK with server-side API Key authentication using Application ID and Secret Token. This setup enables full API access to all Voucherify endpoints for managing vouchers, campaigns, redemptions, and validations. The example initializes core API instances for vouchers, campaigns, redemptions, and validations operations. ```javascript const voucherifyClient = require('@voucherify/sdk'); // Configure API client with credentials const apiClient = new voucherifyClient.ApiClient(); apiClient.basePath = 'https://api.voucherify.io'; apiClient.authentications['X-App-Id'].apiKey = 'your-application-id'; apiClient.authentications['X-App-Token'].apiKey = 'your-secret-token'; // Initialize API instances const vouchersApi = new voucherifyClient.VouchersApi(apiClient); const campaignsApi = new voucherifyClient.CampaignsApi(apiClient); const redemptionsApi = new voucherifyClient.RedemptionsApi(apiClient); const validationsApi = new voucherifyClient.ValidationsApi(apiClient); console.log('SDK initialized successfully'); ``` -------------------------------- ### Get Reward Assignment with Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/RewardsApi.md Provides an example of how to retrieve a specific reward assignment using the Voucherify JavaScript SDK. It requires authentication setup and the rewardId and assignmentId as parameters. The function returns a RewardsAssignmentsGetResponseBody object on success. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.RewardsApi(); let rewardId = "rewardId_example"; // String | A unique reward ID. let assignmentId = "assignmentId_example"; // String | A unique reward assignment ID. apiInstance.getRewardAssignment(rewardId, assignmentId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### Create Voucherify Project using JavaScript SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ManagementApi.md This snippet demonstrates how to initialize the Voucherify client and create a new project. It requires API keys for authentication and an object defining the project details. The output indicates success or logs any errors encountered. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-Management-Token let X_Management_Token = defaultClient.authentications['X-Management-Token']; X_Management_Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X_Management_Token.apiKeyPrefix = 'Token'; // Configure API key authorization: X-Management-Id let X_Management_Id = defaultClient.authentications['X-Management-Id']; X_Management_Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X_Management_Id.apiKeyPrefix = 'Token'; let apiInstance = new Voucherify.ManagementApi(); let managementProjectsCreateRequestBody = new Voucherify.ManagementProjectsCreateRequestBody(); // ManagementProjectsCreateRequestBody | Define project details. apiInstance.createProject(managementProjectsCreateRequestBody, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### Get Campaign Details with JavaScript Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/CampaignsApi.md This example demonstrates how to retrieve details of a specific campaign using its ID or name with the Voucherify JavaScript SDK. It includes the necessary authentication setup and the function call to the `getCampaign` method. The result is logged to the console upon successful execution. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.CampaignsApi(); let campaignId = "campaignId_example"; // String | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. apiInstance.getCampaign(campaignId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### POST /management/v1/projects Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/README.md Create a new Voucherify project. This endpoint initializes a new project workspace with default configurations. ```APIDOC ## POST /management/v1/projects ### Description Create a new project. ### Method POST ### Endpoint /management/v1/projects #### Request Body - **name** (string) - Required - Project name - **description** (string) - Optional - Project description - **timezone** (string) - Optional - Project timezone (e.g., UTC, EST) - **currency** (string) - Optional - Default currency code (e.g., USD) ### Request Example { "name": "My Project", "description": "Marketing campaign project", "timezone": "UTC", "currency": "USD" } ### Response #### Success Response (200) - **id** (string) - Project identifier - **name** (string) - Project name - **description** (string) - Project description - **timezone** (string) - Project timezone - **currency** (string) - Default currency - **created_at** (string) - ISO 8601 timestamp of creation ``` -------------------------------- ### Voucherify Management API Initialization and Project Operations Source: https://context7.com/voucherifyio/voucherify-js-sdk/llms.txt Initializes the Voucherify Management API client and demonstrates creating a new project. It includes setting up API credentials, defining project properties, and handling the response. Dependencies include the '@voucherify/sdk' package. ```javascript const voucherifyClient = require('@voucherify/sdk'); // Configure Management API client const mgmtApiClient = new voucherifyClient.ApiClient(); mgmtApiClient.basePath = 'https://api.voucherify.io'; mgmtApiClient.authentications['X-Management-Id'].apiKey = 'your-management-id'; mgmtApiClient.authentications['X-Management-Token'].apiKey = 'your-management-token'; const managementApi = new voucherifyClient.ManagementApi(mgmtApiClient); // Create new project const projectRequest = new voucherifyClient.ManagementProjectsCreateRequestBody(); projectRequest.case_sensitive_codes = false; projectRequest.name = 'E-commerce Store Production'; projectRequest.description = 'Production environment for online store'; projectRequest.timezone = 'America/New_York'; projectRequest.currency = 'USD'; projectRequest.dial_code = '+1'; projectRequest.webhook_version = 'v2024-01-01'; projectRequest.api_version = 'v2018-08-01'; managementApi.createProject(projectRequest, (error, project) => { if (error) { console.error('Project creation failed:', error); return; } console.log('Project created:', project.id); console.log('Project name:', project.name); console.log('API version:', project.api_version); // List all projects managementApi.listProjects({ limit: 10 }, (error, projects) => { if (error) { console.error('Failed to list projects:', error); return; } console.log('Projects:', projects.data.map(p => p.name)); }); }); ``` -------------------------------- ### Retrieve Order by ID using Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/OrdersApi.md This example shows how to retrieve a specific order using its ID with the Voucherify JavaScript SDK. It covers authentication setup and the necessary parameters to call the get order endpoint. The function returns the order details upon successful retrieval. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.OrdersApi(); let orderId = "orderId_example"; apiInstance.getOrder(orderId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### Get Loyalty Member by Member ID using JavaScript Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/LoyaltiesApi.md This code example shows how to retrieve loyalty card details for a member using their unique member ID (voucher code) with the Voucherify JavaScript SDK. It includes setting up authentication via API keys or OAuth and making the GET request. Remember to substitute placeholder authentication details with your valid credentials. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.LoyaltiesApi(); let memberId = "memberId_example"; // String | Unique loyalty card code assigned to a particular customer. apiInstance.getMember(memberId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### Initialize and Use Voucherify JS SDK (Node.js) Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/README.md This snippet demonstrates how to initialize the Voucherify JS SDK in a Node.js environment. It shows how to configure authentication using API keys (X-App-Id and X-App-Token) and an OAuth token (X-Voucherify-OAuth). It also illustrates how to instantiate the CampaignsApi and make a request to list campaigns. Remember to replace placeholder keys with your actual Voucherify credentials and configure the correct basePath for your cluster. This example performs a read-only operation. ```javascript const Voucherify = require("@voucherify/sdk"); const defaultClient = Voucherify.ApiClient.instance; // Configure the server url defaultClient.basePath = "https://{cluster}.api.voucherify.io"; // Configure API key authorization: X-App-Id const XAppId = defaultClient.authentications["X-App-Id"]; XAppId.apiKey = "YOUR APP ID"; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix['X-App-Id'] = "Token" // Configure API key authorization: X-App-Token const XAppToken = defaultClient.authentications["X-App-Token"]; XAppToken.apiKey = "YOUR APP TOKEN"; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix['X-App-Token'] = "Token" // Configure OAuth2 access token for authorization: X-Voucherify-OAuth const XVoucherifyOAuth = defaultClient.authentications["X-Voucherify-OAuth"]; XVoucherifyOAuth.accessToken = ""; const api = new Voucherify.CampaignsApi(defaultClient); const callback = function (error, data, response) { if (error) { console.error(error); } else { console.log( "API called successfully. Returned data: " + JSON.stringify(data, null, 2), ); } }; api.listCampaigns(undefined, callback); ``` -------------------------------- ### Get Metadata Schema with Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ManagementApi.md This example shows how to retrieve a metadata schema using the Voucherify JavaScript SDK. It includes setting up API key authentication and requires project and metadata schema IDs as parameters. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-Management-Token let X_Management_Token = defaultClient.authentications['X-Management-Token']; X_Management_Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X_Management_Token.apiKeyPrefix = 'Token'; // Configure API key authorization: X-Management-Id let X_Management_Id = defaultClient.authentications['X-Management-Id']; X_Management_Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X_Management_Id.apiKeyPrefix = 'Token'; let apiInstance = new Voucherify.ManagementApi(); let projectId = "projectId_example"; // String | Provide the unique identifier of the project. let metadataSchemaId = "metadataSchemaId_example"; // String | Provide the unique identifier of the metadata schema. apiInstance.getMetadataSchema1(projectId, metadataSchemaId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### POST /projects Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ManagementApi.md Creates a new project. This endpoint allows you to set up a new project with details such as users, cluster, timezone, currency, and more. ```APIDOC ## POST /projects ### Description Creates a new project. You can add users, specify the cluster, timezone, currency, and other details. All owners are added to the project by default. ### Method POST ### Endpoint `/projects` ### Parameters #### Request Body - **managementProjectsCreateRequestBody** (ManagementProjectsCreateRequestBody) - Required - Defines the project details. ### Request Example ```javascript { "example": "request body" } ``` ### Response #### Success Response (200) - **managementProjectsCreateResponseBody** (ManagementProjectsCreateResponseBody) - The response body contains the newly created project details. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Authentication Setup Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ProductsApi.md Configure API authentication for the Voucherify JavaScript SDK using API keys or OAuth2 tokens. Three authentication methods are supported: X-App-Id, X-App-Token, and X-Voucherify-OAuth. ```APIDOC ## Authentication Configuration ### Description Set up authentication for the Voucherify JavaScript SDK using API keys or OAuth2 access tokens. ### Supported Authentication Methods #### 1. X-App-Id (API Key) Configuration: ```javascript let defaultClient = Voucherify.ApiClient.instance; let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Optional: Set a prefix for the API key (e.g., "Token") // X-App-Id.apiKeyPrefix = 'Token'; ``` #### 2. X-App-Token (API Key) Configuration: ```javascript let defaultClient = Voucherify.ApiClient.instance; let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Optional: Set a prefix for the API key (e.g., "Token") // X-App-Token.apiKeyPrefix = 'Token'; ``` #### 3. X-Voucherify-OAuth (OAuth2) Configuration: ```javascript let defaultClient = Voucherify.ApiClient.instance; let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; ``` ### Complete Setup Example ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Configure X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Configure OAuth2 let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; ``` ``` -------------------------------- ### Get Category by ID using Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/CategoriesApi.md Fetches a specific category from Voucherify using its unique ID. This example demonstrates authentication using API keys or OAuth tokens and handling the response or errors. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.CategoriesApi(); let categoryId = "categoryId_example"; // String | Unique category ID assigned by Voucherify. apiInstance.getCategory(categoryId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### Disable Campaign with Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/CampaignsApi.md Shows how to disable a campaign using the Voucherify JavaScript SDK, making its vouchers unredeemable. This example covers authentication setup (API key or OAuth) and the asynchronous call to the disable endpoint. It logs success or error messages. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.CampaignsApi(); let campaignId = "campaignId_example"; // String | The campaign ID or name of the campaign being disabled. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. apiInstance.disableCampaign(campaignId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### List Brands with Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ManagementApi.md This example shows how to list all brand configurations for a given project using the Voucherify JavaScript SDK. It requires setting up API key authentication and then calling the listBrands method with the project ID. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-Management-Token let X-Management-Token = defaultClient.authentications['X-Management-Token']; X-Management-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-Management-Token.apiKeyPrefix = 'Token'; // Configure API key authorization: X-Management-Id let X-Management-Id = defaultClient.authentications['X-Management-Id']; X-Management-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-Management-Id.apiKeyPrefix = 'Token'; let apiInstance = new Voucherify.ManagementApi(); let projectId = "projectId_example"; // String | Provide the unique identifier of the project. apiInstance.listBrands(projectId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### POST /v1/products Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/ENDPOINTS-COVERAGE.md Creates a new product in your catalog. Requires product details such as name, price, and optional metadata for categorization and tracking. ```APIDOC ## POST /v1/products ### Description Create a new product in your Voucherify catalog. ### Method POST ### Endpoint /v1/products ### Request Body - **name** (string) - Required - Product name - **price** (integer) - Optional - Product price in cents - **description** (string) - Optional - Product description - **attributes** (object) - Optional - Custom attributes for the product - **metadata** (object) - Optional - Additional metadata ### Request Example { "name": "Premium Widget", "price": 2999, "description": "High-quality premium widget", "attributes": ["color", "size"], "metadata": {"category": "electronics"} } ### Response #### Success Response (201) - **id** (string) - Unique product identifier - **name** (string) - Product name - **price** (integer) - Product price - **created_at** (string) - Creation timestamp #### Response Example { "id": "prod_123", "name": "Premium Widget", "price": 2999, "created_at": "2023-01-15T10:30:00Z" } ``` -------------------------------- ### Get Promotion Stack using Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/PromotionsApi.md This example demonstrates how to retrieve the details of a promotion stack, including its associated promotion tiers, using the Voucherify JavaScript SDK. It requires authentication and the campaign ID and stack ID as parameters. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.PromotionsApi(); let campaignId = "campaignId_example"; // String | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. let stackId = "stackId_example"; // String | Promotion stack ID. apiInstance.getPromotionStack(campaignId, stackId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### POST /management/projects Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ManagementApi.md Creates a new project in Voucherify. This endpoint initializes a new project with the specified details and returns the project configuration. ```APIDOC ## POST /management/projects ### Description Creates a new project in Voucherify with the specified project details. ### Method POST ### Endpoint /management/projects ### Request Body - **managementProjectsCreateRequestBody** (ManagementProjectsCreateRequestBody) - Required - Define project details. ### Request Example ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-Management-Token let X-Management-Token = defaultClient.authentications['X-Management-Token']; X-Management-Token.apiKey = 'YOUR API KEY'; // Configure API key authorization: X-Management-Id let X-Management-Id = defaultClient.authentications['X-Management-Id']; X-Management-Id.apiKey = 'YOUR API KEY'; let apiInstance = new Voucherify.ManagementApi(); let managementProjectsCreateRequestBody = new Voucherify.ManagementProjectsCreateRequestBody(); apiInstance.createProject(managementProjectsCreateRequestBody, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` ### Response #### Success Response (200) - **ManagementProjectsCreateResponseBody** (object) - Project creation response containing project details and configuration. ### Authorization - X-Management-Token - X-Management-Id ### HTTP Request Headers - **Content-Type**: application/json - **Accept**: application/json ``` -------------------------------- ### Get Reward Details using JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/LoyaltiesApi.md This JavaScript code demonstrates how to fetch detailed information about a reward assignment within a loyalty campaign using the Voucherify SDK. It includes setup for API key or OAuth authentication and calls the getRewardDetails method, logging any errors or the retrieved data. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.LoyaltiesApi(); let campaignId = "campaignId_example"; // String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. let assignmentId = "assignmentId_example"; // String | Unique reward assignment ID. apiInstance.getRewardDetails(campaignId, assignmentId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### Initialize Voucherify API Client with Authentication Source: https://context7.com/voucherifyio/voucherify-js-sdk/llms.txt Sets up the Voucherify API client with base path and authentication credentials. This is a prerequisite step that must be completed before making any API calls to the Voucherify service. ```javascript const voucherifyClient = require('@voucherify/sdk'); const apiClient = new voucherifyClient.ApiClient(); apiClient.basePath = 'https://api.voucherify.io'; apiClient.authentications['X-App-Id'].apiKey = 'your-application-id'; apiClient.authentications['X-App-Token'].apiKey = 'your-secret-token'; ``` -------------------------------- ### Get Reward Details with Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/RewardsApi.md Shows how to retrieve details of a specific reward using its ID with the Voucherify JavaScript SDK. It includes setup for API key or OAuth authentication and takes a rewardId as input. The function returns a Reward object upon success. ```javascript import Voucherify from 'voucherify'; let defaultClient = Voucherify.ApiClient.instance; // Configure API key authorization: X-App-Id let X-App-Id = defaultClient.authentications['X-App-Id']; X-App-Id.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Id.apiKeyPrefix = 'Token'; // Configure API key authorization: X-App-Token let X-App-Token = defaultClient.authentications['X-App-Token']; X-App-Token.apiKey = 'YOUR API KEY'; // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //X-App-Token.apiKeyPrefix = 'Token'; // Configure OAuth2 access token for authorization: X-Voucherify-OAuth let X-Voucherify-OAuth = defaultClient.authentications['X-Voucherify-OAuth']; X-Voucherify-OAuth.accessToken = 'YOUR ACCESS TOKEN'; let apiInstance = new Voucherify.RewardsApi(); let rewardId = "rewardId_example"; // String | A unique reward ID. apiInstance.getReward(rewardId, (error, data, response) => { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }); ``` -------------------------------- ### Get User Details using Voucherify JS SDK Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ManagementApi.md This example demonstrates how to retrieve details for a specific user within a project using the Voucherify JS SDK. It requires the 'voucherify' package and authenticated API credentials. The function takes projectId and userId as input to fetch user information. ```javascript // This is a placeholder for the actual code which is not fully provided in the input. // The function signature suggests it would be similar to other ManagementApi calls. // Example structure: // import Voucherify from 'voucherify'; // let apiInstance = new Voucherify.ManagementApi(); // let projectId = "projectId_example"; // let userId = "userId_example"; // apiInstance.getUser(projectId, userId, (error, data, response) => { // if (error) { // console.error(error); // } else { // console.log('API called successfully. Returned data: ' + data); // } // }); ``` -------------------------------- ### Create Project Source: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/docs/ManagementProjectsCreateResponseBody.md Creates a new project within the Voucherify platform. This endpoint allows for the comprehensive configuration of project settings, including identification, localization, security, and integration options. ```APIDOC ## POST /projects ### Description Creates a new project with specified configurations. ### Method POST ### Endpoint /projects ### Parameters #### Request Body - **id** (String) - Optional - Unique identifier of the project. - **name** (String) - Optional - The name of the project. - **description** (String) - Optional - A user-defined description of the project. - **timezone** (String) - Optional - The time zone in which the project is established (GMT or IANA format). - **currency** (String) - Optional - The 3-letter ISO 4217 currency code for the project. - **dialCode** (String) - Optional - The country dial code for the project (ITU country code). - **webhookVersion** (String) - Optional - The webhook version used in the project. Defaults to 'v2024-01-01'. Enum: `v2024-01-01`. - **clientTrustedDomains** (Array[String]) - Optional - An array of URL addresses that allow client requests. - **clientRedeemEnabled** (Boolean) - Optional - Enables client-side redemption. - **clientPublishEnabled** (Boolean) - Optional - Enables client-side publication. - **clientListVouchersEnabled** (Boolean) - Optional - Enables client-side listing of vouchers. - **clientCreateCustomerEnabled** (Boolean) - Optional - Enables client-side creation of customers. - **clientLoyaltyEventsEnabled** (Boolean) - Optional - Enables client-side events for loyalty and referral programs. - **clientSetVoucherExpirationDateEnabled** (Boolean) - Optional - Enables client-side setting of voucher expiration date. - **webhooksCalloutNotifications** (Object) - Optional - Configuration for webhook callout notifications. - **apiUsageNotifications** (Object) - Optional - Configuration for API usage notifications. - **clusterId** (String) - Optional - The identifier of the cluster where the project will be created. - **caseSensitiveCodes** (Boolean) - Optional - Determines if voucher codes are case-sensitive. - **apiVersion** (String) - Optional - The API version used in the project. Defaults to 'v2018-08-01'. Enum: `v2018-08-01`. - **isSandbox** (Boolean) - Optional - Determines if the project is a sandbox project. - **webhookToken** (String) - Optional - Webhook token used for authentication. - **serverSideKey** (Object) - Optional - Server-side key configuration. - **clientSideKey** (Object) - Optional - Client-side key configuration. ### Request Example ```json { "name": "My New Project", "description": "Project for testing new voucher features", "currency": "USD", "timezone": "America/New_York", "clientTrustedDomains": ["https://example.com"], "isSandbox": true } ``` ### Response #### Success Response (200) - **id** (String) - Unique identifier of the created project. - **name** (String) - The name of the project. - **description** (String) - A user-defined description of the project. - **timezone** (String) - The time zone of the project. - **currency** (String) - The currency used in the project. - **dialCode** (String) - The country dial code for the project. - **webhookVersion** (String) - The webhook version used in the project. - **clientTrustedDomains** (Array[String]) - An array of URL addresses that allow client requests. - **clientRedeemEnabled** (Boolean) - Enables client-side redemption. - **clientPublishEnabled** (Boolean) - Enables client-side publication. - **clientListVouchersEnabled** (Boolean) - Enables client-side listing of vouchers. - **clientCreateCustomerEnabled** (Boolean) - Enables client-side creation of customers. - **clientLoyaltyEventsEnabled** (Boolean) - Enables client-side events for loyalty and referral programs. - **clientSetVoucherExpirationDateEnabled** (Boolean) - Enables client-side setting of voucher expiration date. - **webhooksCalloutNotifications** (Object) - Webhook callout notifications configuration. - **apiUsageNotifications** (Object) - API usage notifications configuration. - **clusterId** (String) - The identifier of the cluster where the project was created. - **caseSensitiveCodes** (Boolean) - Indicates if voucher codes are case-sensitive. - **apiVersion** (String) - The API version used in the project. - **isSandbox** (Boolean) - Indicates if the project is a sandbox project. - **webhookToken** (String) - Webhook token used for authentication. - **serverSideKey** (Object) - Server-side key details. - **clientSideKey** (Object) - Client-side key details. #### Response Example ```json { "id": "proj_123abc", "name": "My New Project", "description": "Project for testing new voucher features", "currency": "USD", "timezone": "America/New_York", "clientTrustedDomains": ["https://example.com"], "isSandbox": true, "webhookVersion": "v2024-01-01", "clientRedeemEnabled": false, "clientPublishEnabled": false, "clientListVouchersEnabled": false, "clientCreateCustomerEnabled": false, "clientLoyaltyEventsEnabled": false, "clientSetVoucherExpirationDateEnabled": false, "apiVersion": "v2018-08-01" } ``` ``` -------------------------------- ### Create, Update, and List Products and SKUs with Voucherify JS SDK Source: https://context7.com/voucherifyio/voucherify-js-sdk/llms.txt This snippet shows how to initialize the Voucherify client, create a product, add SKU variants to it, list all SKUs for a product, and update the product details. It uses the ProductsApi and requires application ID and secret token for authentication. ```javascript const voucherifyClient = require('@voucherify/sdk'); const apiClient = new voucherifyClient.ApiClient(); apiClient.basePath = 'https://api.voucherify.io'; apiclient.authentications['X-App-Id'].apiKey = 'your-application-id'; apiClient.authentications['X-App-Token'].apiKey = 'your-secret-token'; const productsApi = new voucherifyClient.ProductsApi(apiClient); // Create product const productRequest = new voucherifyClient.ProductsCreateRequestBody(); productRequest.source_id = 'external_product_laptop'; productRequest.name = 'Gaming Laptop Pro'; productRequest.price = 150000; // $1500.00 in cents productRequest.attributes = ['electronics', 'computers', 'gaming']; productRequest.metadata = { category: 'Electronics', brand: 'TechCorp', warranty_months: 24, in_stock: true }; productsApi.createProduct(productRequest, (error, product) => { if (error) { console.error('Product creation failed:', error); return; } console.log('Product created:', product.id); console.log('Product name:', product.name); console.log('Product price:', product.price); // Create SKU variants const sku1Request = new voucherifyClient.ProductsSkusCreateRequestBody(); sku1Request.source_id = 'laptop_16gb_512ssd'; sku1Request.sku = 'LAPTOP-16-512'; sku1Request.price = 150000; sku1Request.attributes = { ram: '16GB', storage: '512GB SSD', color: 'Silver' }; sku1Request.metadata = { stock_level: 50, warehouse: 'US-EAST' }; productsApi.createSku(product.id, sku1Request, (error, sku1) => { if (error) { console.error('SKU creation failed:', error); return; } console.log('SKU created:', sku1.sku); console.log('SKU ID:', sku1.id); }); // Create second SKU variant const sku2Request = new voucherifyClient.ProductsSkusCreateRequestBody(); sku2Request.source_id = 'laptop_32gb_1tbssd'; sku2Request.sku = 'LAPTOP-32-1TB'; sku2Request.price = 200000; sku2Request.attributes = { ram: '32GB', storage: '1TB SSD', color: 'Black' }; productsApi.createSku(product.id, sku2Request, (error, sku2) => { if (error) { console.error('SKU creation failed:', error); return; } console.log('SKU created:', sku2.sku); }); // List all SKUs for product productsApi.listSKUsInProduct(product.id, { limit: 10 }, (error, skus) => { if (error) { console.error('Failed to list SKUs:', error); return; } console.log('Total SKUs:', skus.total); skus.skus.forEach((sku) => { console.log('SKU:', sku.sku, 'Price:', sku.price); }); }); // Update product const updateRequest = new voucherifyClient.ProductsUpdateRequestBody(); updateRequest.price = 140000; // Sale price updateRequest.metadata = { category: 'Electronics', brand: 'TechCorp', on_sale: true, sale_end_date: '2024-12-31' }; productsApi.updateProduct(product.id, updateRequest, (error, updated) => { if (error) { console.error('Product update failed:', error); return; } console.log('Product updated:', updated.price); }); }); ```