Create New Promotional Discount

The Payiano create discount endpoint serves as the foundation for businesses to introduce new promotions, allowing for the strategic launch of discounts aimed at driving sales and engaging customers. This endpoint is the starting point for crafting targeted promotional campaigns, enabling businesses to swiftly respond to market trends, seasonal demands, or competitive pressures. By facilitating the initiation of discount offers, the "Create" endpoint empowers companies to attract new customers, retain existing ones, and stimulate overall sales activity, laying the groundwork for a dynamic and adaptable marketing strategy.

This endpoint supports the customization of discounts to fit various business goals, from clearing inventory to promoting new product launches. It allows businesses to quickly deploy tailored promotions, ensuring that they can capitalize on opportunities as they arise. This level of agility is crucial in maintaining a competitive edge, enabling companies to react in real-time to changing market dynamics and customer preferences, thereby enhancing their ability to meet sales targets and improve customer satisfaction.

Note that once set, you can't change the value and value_type attributes. To update these, you'll need to create a new discount and archive the old one.
POST/discounts
Sandbox: https://api.payiano.dev/v1/discounts
Live: https://api.payiano.com/v1/discounts
Security
  • Authorization header with access token is required to access this endpoint: Bearer ACCESS-TOKEN
  • Your access token should be associated to this permission discounts_create
Request
Request body schema:
application/json
Query parameters:
includes
Type: array_of_enums|null
Possible values:
[
"discount.metadata" ]

A list of additional discount relations to return, if available. Feel free to send the relations you would like to return with every item. See Including Resources to better understand how this is working.

Request body:
name
required
Type: string
Min: 2
Max: 255

The attribute attribute represents a concise and descriptive title for the discount, intended to quickly convey the essence or purpose of the discount to administrators. This title is used for easy identification and reference within the system.

value
required
Type: decimal
Min: 0.01
Max: 9999999 when value_type is FLAT and 100 when the value_type is PERCENTAGE.

The discount amount value. The length includes the value, the decimal digit and the decimal value. The API accepts 2 digits like 50.53.

value_type
required
Type: enum
Possible values:
[
"PERCENTAGE", "FLAT" ]

The discount value type. This attribute allows systems to accurately calculate discounts according to the specified type, ensuring the correct deduction is applied to transactions.

is_active
Type: boolean
Default: true

This value indicates whether the discount is active or not. This flag can be used to control the discount's availability in runtime environments or listings without deleting or removing the discount from records. A true value means the discount is active and functioning, while a false value implies that the discount is deactivated or not in use.

reference_id
Type: string|null
Max: 50

It's a unique identifier assigned to each discount. It's primary role is to distinguish one discount from another, ensuring that each discount can be individually tracked and managed without any confusion. Please notice that duplicate values are not allowed and it's allowed to use alpha dash only [A-Za-z0-9-_]. The reference_id value is used to Identify Resource when you consume any discount endpoint with sending identify_by query parameter with value reference_id.

starts_at
Type: datetime|null

This attribute specifies the exact timestamp in UTC from which the discount becomes applicable. The starts at timestamp should be before the expires_at attribute.

expires_at
Type: datetime|null

This attribute defines the precise timestamp in UTC when the discount will no longer be valid.

description
Type: string|null
Min: 2
Max: 255

This attribute provides a brief summary or explanation of the discount, detailing its purpose, conditions, or how it can be applied. This narrative is intended to offer users or administrators clear insight into the discount's benefits and any applicable terms.. This value will not be shown to customers.

metadata
Type: object|null

The discount metadata model details. Metadata serves as a tool for keeping extra, organized details about a resource. For example, you can use it to store a user's preferences like prefered color, notes or any other data that aids in personalizing services, improving customer relations, or optimizing internal workflows. This information isn't utilized by Payiano – meaning it's not involved in authorizing or declining transactions and remains invisible to your users. Its value is entirely private for your internal use, and we ensure it remains confidential, not shared with any external parties.

info
Type: array_of_objects
Max: 50

This array consists of objects, each containing a key and a value. These pairs of key-value are structured in a way that's more suitable for programmatic access. You can add up to 50 objects.

key
required
Type: string
Min: 1
Max: 50

It's a unique identifier to avoid confusion or data overlap. The keys serve as identifiers for the corresponding values, making it easier to retrieve specific pieces of information as needed.

value
required
Type: string
Min: 1
Max: 255

The value is the actual data associated with that key. It could be a simple string, a number, a URL, or any other data format that conveys the necessary information.

list
Type: array_of_strings
Max: 50

The list attribute is particularly useful for scenarios where the data needs to be presented in a straightforward, unstructured format. It's ideal for quick overviews, simple data logging, or when the information does not require the more complex organization that nested JSON objects provide. Please notice that duplicate values are not allowed, you can add up to 50 item and the max list item length is 255 characters.

Response
201
Response schema:
application/json
Response body:
discount
Type: object

The discount model details.

id
Type: ulid
Length: 26

The unique ID assigned to each discount which is generated by our system using the ULID format. Each ID is precisely 26 characters long, ensuring a unique and consistent identifier for every discount. This ULID is automatically created by our system and is used to uniquely identify and track each discount in our database.

name
Type: string
Min: 2
Max: 255

The attribute attribute represents a concise and descriptive title for the discount, intended to quickly convey the essence or purpose of the discount to administrators. This title is used for easy identification and reference within the system.

value
Type: decimal
Min: 0.01
Max: 9999999 when value_type is FLAT and 100 when the value_type is PERCENTAGE.

The discount amount value. The length includes the value, the decimal digit and the decimal value. The API accepts 2 digits like 50.53.

value_type
Type: enum
Possible values:
[
"PERCENTAGE", "FLAT" ]

The discount value type. This attribute allows systems to accurately calculate discounts according to the specified type, ensuring the correct deduction is applied to transactions.

is_active
Type: boolean
Default: true

This value indicates whether the discount is active or not. This flag can be used to control the discount's availability in runtime environments or listings without deleting or removing the discount from records. A true value means the discount is active and functioning, while a false value implies that the discount is deactivated or not in use.

reference_id
Type: string|null
Max: 50

It's a unique identifier assigned to each discount. It's primary role is to distinguish one discount from another, ensuring that each discount can be individually tracked and managed without any confusion. Please notice that duplicate values are not allowed and it's allowed to use alpha dash only [A-Za-z0-9-_]. The reference_id value is used to Identify Resource when you consume any discount endpoint with sending identify_by query parameter with value reference_id.

starts_at
Type: datetime|null

This attribute specifies the exact timestamp in UTC from which the discount becomes applicable. The starts at timestamp should be before the expires_at attribute. This attribute can be formatted as an ISO 8601 string or a UNIX timestamp in milliseconds, depending on the preferred datetime format specified in the request header (e.g., 2024-08-04T14:22:01Z or 1722572118554). By default, the format is UNIX timestamp in milliseconds.

expires_at
Type: datetime|null

This attribute defines the precise timestamp in UTC when the discount will no longer be valid. This attribute can be formatted as an ISO 8601 string or a UNIX timestamp in milliseconds, depending on the preferred datetime format specified in the request header (e.g., 2024-08-04T14:22:01Z or 1722572118554). By default, the format is UNIX timestamp in milliseconds.

description
Type: string|null
Min: 2
Max: 255

This attribute provides a brief summary or explanation of the discount, detailing its purpose, conditions, or how it can be applied. This narrative is intended to offer users or administrators clear insight into the discount's benefits and any applicable terms.. This value will not be shown to customers.

is_expired
Type: boolean

This attribute indicates whether the discount is expired or not.

is_started
Type: boolean

This attribute indicates whether the discount is started or not.

metadata
Type: object|null

The discount metadata model details. Metadata serves as a tool for keeping extra, organized details about a resource. For example, you can use it to store a user's preferences like prefered color, notes or any other data that aids in personalizing services, improving customer relations, or optimizing internal workflows. This information isn't utilized by Payiano – meaning it's not involved in authorizing or declining transactions and remains invisible to your users. Its value is entirely private for your internal use, and we ensure it remains confidential, not shared with any external parties.

info
Type: array_of_objects
Max: 50

This array consists of objects, each containing a key and a value. These pairs of key-value are structured in a way that's more suitable for programmatic access. You can add up to 50 objects.

key
Type: string
Min: 1
Max: 50

It's a unique identifier to avoid confusion or data overlap. The keys serve as identifiers for the corresponding values, making it easier to retrieve specific pieces of information as needed.

value
Type: string
Min: 1
Max: 255

The value is the actual data associated with that key. It could be a simple string, a number, a URL, or any other data format that conveys the necessary information.

list
Type: array_of_strings
Max: 50

The list attribute is particularly useful for scenarios where the data needs to be presented in a straightforward, unstructured format. It's ideal for quick overviews, simple data logging, or when the information does not require the more complex organization that nested JSON objects provide. Please notice that duplicate values are not allowed, you can add up to 50 item and the max list item length is 255 characters.

created_at
Type: datetime

The created datetime of the discount. This attribute can be formatted as an ISO 8601 string or a UNIX timestamp in milliseconds, depending on the preferred datetime format specified in the request header (e.g., 2024-08-04T14:22:01Z or 1722572118554). By default, the format is UNIX timestamp in milliseconds.

updated_at
Type: datetime

The updated datetime of the discount. This attribute can be formatted as an ISO 8601 string or a UNIX timestamp in milliseconds, depending on the preferred datetime format specified in the request header (e.g., 2024-08-04T14:22:01Z or 1722572118554). By default, the format is UNIX timestamp in milliseconds.

Response sample:
1
{
2
"discount": {
3 "id": "01hsyngn0bxgmx5yg8jq3vda4y", 4 "name": "Black Friday discount", 5 "value": 50, 6 "value_type": "FLAT", 7 "is_active": true, 8 "reference_id": "dfa01948-b4f2-3055-8847-2a2fbae0c514", 9 "starts_at": "1722572118554", 10 "expires_at": "1722572118554", 11 "description": "The black Friday discount", 12 "is_expired": false, 13 "is_started": false, 14
"metadata": {
15
"info": [
16
{
17 "key": "Company name", 18 "value": "Pyngy" 19 } 20 ], 21
"list": [
22 "Cairo, Nasr City, 7th District, Building 12 floor 5" 23 ] 24 }, 25 "created_at": "1722572118554", 26 "updated_at": "1722572118554" 27 } 28}