List and Track Discounts

The Payiano list discounts endpoint offers a comprehensive view of all historical discounts, providing businesses with crucial insights into their promotional landscape. This endpoint allows for efficient management and assessment of discount campaigns, giving companies the ability to track the performance and impact of each discount over time. By aggregating all discount data, this endpoint facilitates strategic decision-making, enabling businesses to refine their promotional strategies based on past successes and areas for improvement.

GET/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_view
Request
Request body schema:
application/json
Query parameters:
page
Type: integer|null
Default: 1

The page number to be retrieved, for the list of discounts. So, a combination of page=1 and per_page=25 returns the first 25 discounts. A combination of page=2 and per_page=25 returns the next 25 discounts.

per_page
Type: integer|null
Default: 25
Possible values: [1 ... 200]

The maximum number of discounts to return in the response.

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.

Response
200
Response schema:
application/json
Response body:
total_pages
Type: integer

The total number of pages that are available for the discounts search criteria.

current_page
Type: integer

The current pagination page.

per_page
Type: integer

The amount of discounts items return per page.

total_items
Type: integer

The total number of discounts that match the search criteria.

items
Type: array_of_objects

The list of discounts that match the search criteria.

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