# Voucherify.PublicationsApi

All URIs are relative to *https://api.voucherify.io*

Method | HTTP request | Description
------------- | ------------- | -------------
[**createPublication**](PublicationsApi.md#createPublication) | **POST** /v1/publications | Create Publication
[**createPublication1**](PublicationsApi.md#createPublication1) | **GET** /v1/publications/create | Create Publication with GET
[**listPublications**](PublicationsApi.md#listPublications) | **GET** /v1/publications | List Publications



## createPublication

> PublicationsCreateResponseBody createPublication(publicationsCreateRequestBody, opts)

Create Publication

This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet.   &lt;Warning&gt; &lt;Badge color yellow&gt;Clearly define the source of the voucher&lt;/Badge&gt; You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. &lt;/Warning&gt; &lt;Warning&gt; &lt;Badge color yellow&gt;Publish multiple vouchers&lt;/Badge&gt; In case you want to publish multiple vouchers within a single publication, you need to specify the campaign name and number of vouchers you want to publish. &lt;/Warning&gt; &lt;Note&gt; &lt;Badge color blue&gt;Auto-update campaign&lt;/Badge&gt; In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. &lt;/Note&gt;

### Example

```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.PublicationsApi();
let publicationsCreateRequestBody = {"campaign":{"name":"campaign-name"},"customer":{"source_id":"source-id","Name":"Customer Name","email":"customer email"},"voucher":"voucher-code","metadata":{"key":"value"}}; // PublicationsCreateRequestBody | Specify the publication parameters.
let opts = {
  'joinOnce': true // Boolean | Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer.
};
apiInstance.createPublication(publicationsCreateRequestBody, opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters


Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **publicationsCreateRequestBody** | [**PublicationsCreateRequestBody**](PublicationsCreateRequestBody.md)| Specify the publication parameters. | 
 **joinOnce** | **Boolean**| Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. | [optional] 

### Return type

[**PublicationsCreateResponseBody**](PublicationsCreateResponseBody.md)

### Authorization

[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token), [X-Voucherify-OAuth](../README.md#X-Voucherify-OAuth)

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json


## createPublication1

> PublicationsCreateResponseBody createPublication1(customer, opts)

Create Publication with GET

This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet. &lt;Danger&gt; &lt;Badge color red&gt;Limited access&lt;/Badge&gt; Access to this endpoint is limited. This endpoint is designed for specific integrations and the API keys need to be configured to access this endpoint. Navigate to the **Dashboard** &amp;rarr; **Project Settings** &amp;rarr; **General** &amp;rarr; **Integration Keys** to set up a pair of API keys and use them to send the request. &lt;/Danger&gt; &lt;Warning&gt; &lt;Badge color yellow&gt;Clearly define the source of the voucher&lt;/Badge&gt; You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. &lt;/Warning&gt; &lt;Warning&gt; &lt;Badge color yellow&gt;Publish multiple vouchers&lt;/Badge&gt; This endpoint does not support the publishing of multiple vouchers from a single campaign. In case you want to publish multiple vouchers within a single publication, you need to use a [dedicated endpoint](/api-reference/publications/create-publication). &lt;/Warning&gt; &lt;Note&gt; &lt;Badge color blue&gt;Auto-update campaign&lt;/Badge&gt; In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. &lt;/Note&gt; # Example Request     &lt;Danger&gt; &lt;Badge color red&gt;Required&lt;/Badge&gt; Query param voucher OR campaign MUST be filled out. If you provide both, campaign param will be skipped. &lt;/Danger&gt;

### Example

```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.PublicationsApi();
let customer = new Voucherify.Customer(); // Customer | Contains information about the customer to whom the publication was directed. Use customer.id, customer.source_id, or both to identify the customer; at least one of them is required.
let opts = {
  'joinOnce': true, // Boolean | Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer.
  'voucher': "voucher_example", // String | Code of voucher being published.
  'campaign': new Voucherify.CreatePublicationCampaign(), // CreatePublicationCampaign | Create publication with campaign.
  'sourceId': "sourceId_example", // String | The merchants publication ID if it is different from the Voucherify publication ID. Its an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If source_id is provided only 1 voucher can be published per request.
  'metadata': {key: null} // Object | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format.
};
apiInstance.createPublication1(customer, opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters


Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **customer** | [**Customer**](.md)| Contains information about the customer to whom the publication was directed. Use customer.id, customer.source_id, or both to identify the customer; at least one of them is required. | 
 **joinOnce** | **Boolean**| Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. | [optional] 
 **voucher** | **String**| Code of voucher being published. | [optional] 
 **campaign** | [**CreatePublicationCampaign**](.md)| Create publication with campaign. | [optional] 
 **sourceId** | **String**| The merchants publication ID if it is different from the Voucherify publication ID. Its an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If source_id is provided only 1 voucher can be published per request. | [optional] 
 **metadata** | [**Object**](.md)| The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | [optional] 

### Return type

[**PublicationsCreateResponseBody**](PublicationsCreateResponseBody.md)

### Authorization

[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token), [X-Voucherify-OAuth](../README.md#X-Voucherify-OAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json


## listPublications

> PublicationsListResponseBody listPublications(opts)

List Publications

Retrieve a list of publications. To return a **particular** publication, you can use the source_id query parameter and provide the source_id of the publication you are looking for specifically. # Pagination &lt;Warning&gt; &lt;Badge color yellow&gt;Important!&lt;/Badge&gt; If you want to scroll through a huge set of records, it is recommended to use the [Exports API](/api-reference/exports/create-export). This API will return an error page_over_limit if you reach a page above 1000. &lt;/Warning&gt; # Filter Query The filters query parameter allows for joining multiple parameters with logical operators. The syntax looks as follows:  ## Examples  

### Example

```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.PublicationsApi();
let opts = {
  'limit': 56, // Number | Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items.
  'page': 56, // Number | Which page of results to return. The lowest value is 1.
  'order': new Voucherify.ParameterOrderListPublications(), // ParameterOrderListPublications | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order.
  'campaign': "campaign_example", // String | Filters by a given campaign name.
  'customer': "customer_example", // String | Filters by a unique customer ID.
  'voucher': "voucher_example", // String | Filters by a given voucher code.
  'result': new Voucherify.ParameterResultListPublications(), // ParameterResultListPublications | Filters by a publication result.
  'voucherType': new Voucherify.ParameterVoucherTypeListPublications(), // ParameterVoucherTypeListPublications | Filters by a voucher type.
  'isReferralCode': true, // Boolean | This filter works only for the true option. If set to true, the query returns only publications of codes from referral campaigns. 
  'filters': new Voucherify.ParameterFiltersListPublications(), // ParameterFiltersListPublications | Filters for listing publications.
  'sourceId': "sourceId_example" // String | Using this endpoint with a particular publication source_id, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular source_id.
};
apiInstance.listPublications(opts, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
});
```

### Parameters


Name | Type | Description  | Notes
------------- | ------------- | ------------- | -------------
 **limit** | **Number**| Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items. | [optional] 
 **page** | **Number**| Which page of results to return. The lowest value is 1. | [optional] 
 **order** | [**ParameterOrderListPublications**](.md)| Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] 
 **campaign** | **String**| Filters by a given campaign name. | [optional] 
 **customer** | **String**| Filters by a unique customer ID. | [optional] 
 **voucher** | **String**| Filters by a given voucher code. | [optional] 
 **result** | [**ParameterResultListPublications**](.md)| Filters by a publication result. | [optional] 
 **voucherType** | [**ParameterVoucherTypeListPublications**](.md)| Filters by a voucher type. | [optional] 
 **isReferralCode** | **Boolean**| This filter works only for the true option. If set to true, the query returns only publications of codes from referral campaigns.  | [optional] 
 **filters** | [**ParameterFiltersListPublications**](.md)| Filters for listing publications. | [optional] 
 **sourceId** | **String**| Using this endpoint with a particular publication source_id, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular source_id. | [optional] 

### Return type

[**PublicationsListResponseBody**](PublicationsListResponseBody.md)

### Authorization

[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token), [X-Voucherify-OAuth](../README.md#X-Voucherify-OAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

