> ## Documentation Index
> Fetch the complete documentation index at: https://voucherify-pw-further-tests.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Random Code

> Create a generic (standalone) vouchers. You can choose to create a `GIFT_VOUCHER`, a `DISCOUNT_VOUCHER`, or a `LOYALTY_CARD`. 

When you create a new voucher, you can specify a type to create it.
Creating a new voucher will create a new generic (standalone) vouchers if no `campaign` name or `campaign_id` is provided. However, if an ID or name of a campaign with the `type` set to `STANDALONE` is provided, the voucher will be added to such campaign. In case of the loyalty card, a campaign name is required.

You can optionally use the `code` parameter to define a specific code or the `code_config` parameter to design rules for Voucherify API to create a random code. If neither of the two parameters are passed, then a random code is generated by the Voucherify API.

This method will return an error when trying to create a voucher that already exists.

>🚧 Standalone Vouchers and Campaigns
>
>In version [v20241004](https://support.voucherify.io/article/23-whats-new-in-voucherify#v20241004), generic (standalone) voucherss created through the Voucherify dashboard create a campaign for that voucher. However, vouchers created through the API do not have a campaign attached, so the values for `campaign` and `campaign_id` are `null`.
>
>Voucherify developers work on adding an optional feature to create a generic (standalone) vouchers campaign through the API.
>
>Follow the [Voucherify Release Notes](https://support.voucherify.io/article/23-whats-new-in-voucherify#v20241004) for more details about released features.

