API - Planyo Web Services - create_voucher

Estás aquí: Planyo » Ayuda » API » create_voucher

create_voucher

Description:

Use this function to create a new voucher. Vouchers can be limited to a metasite, to a single site, or to specific resources. Other settings correspond to the settings from the backend UI.

Input:

quantity int required
Maximum number of reservations which can use the voucher
voucher_code_prefix string required
Voucher code. Depending on the parameter unique_codes, this is the entire code or the prefix followed by digits. Voucher code can only include alphanumeric characters, dash and underscore characters
discount_value string required
Voucher discount. It can be expressed in percent (e.g. 20%) or as a fixed discount (e.g. 20.00)
reservation_start_time DateTime required
First day of validity (meaning, the time when a reservation using the voucher can be entered into the system)
reservation_end_time DateTime required
Last day of validity (after this date, reservations entered into the system can no longer use the voucher)
voucher_title string optional
Voucher description/title, can be left empty.
rental_start_time DateTime optional
If rental_start_time and rental_end_time are set, reservations using the voucher must have the rental duration between these two dates. E.g. this could be used for a stay during a specific holiday.
rental_end_time DateTime optional
If rental_start_time and rental_end_time are set, reservations using the voucher must have the rental duration between these two dates. E.g. this could be used for a stay during a specific holiday.
site_id int optional
Used only with metasite API keys. If used, the voucher will be usable only with the specified Planyo site ID
resources string optional
Comma-separated resource IDs for which the voucher can be used. If not set, the voucher will be usable for all resources of a site or metasite
non_combinable bool optional
If set to true, customers will not be able to combine this voucher with other vouchers
is_one_per_customer bool optional
If set to true, then a single customer cannot use this voucher more than once
include_products bool optional
If set to true, the voucher expressed in percent will also apply to additional products being reserved
unique_codes string optional
One of the following values: sequential, codes2, codes3, codes4, codes5, codes6, or not passed at all. If set, the voucher codes will have a numerical suffix at the end. For sequential, it will be simply the voucher number (e.g. ABC1, ABC2, ABC3 etc). If one of the codesX values, there will be an X-digit checksum at the end of the suffix. This is so that your customers cannot guess a second voucher code based on a voucher code given to them.
method string required
must be set to create_voucher
language string optional
by specifying a 2-letter (ISO 639-1) language code (all capital letters e.g. EN, DE, FR, ES, IT) you can change the language of the text values returned
api_key string required
your API key - Click here to get your key. If your API key uses a hash key, you must also include the parameters hash_key and hash_timestamp.

Output:

new_voucher_id int
ID of the new voucher
codes array
If unique_codes is set, this will include all the unique codes of this voucher

API playground:

Click here to test this function in the API playground.