Price API

Autopay supports hour-based dynamic pricing to allow landlords to control their pricing schemas hour by hour based on the actual use. In addition, price API makes managing dynamic pricing even more accessible and more automated as the desired pricing schemas can be pushed to Autopay automatically.


Available resources

Access requirements


PUT - Update pricing

This method allows you to send a new price schema for a specified product.

Endpoint

PUT https://api.autopay.io/price/v1/product/{id}

Request parameters

  • The request body must be in JSON format and HTTP headers must include Content-Type: application/json.
  • The headers must include a valid access token.
  • The request path must include product id.

Parameter Type Mandatory Description
type string yes Pricing type. Possible values: DYNAMIC_PRICING
valid_from datetime (ISO 8601) no Time when this pricing becomes valid. Will become valid instantly when null
prices List of prices yes
type string yes Type of price. Multiple DYNAMIC and REGULAR prices can be used. Possible values:
  • DYNAMIC - price that has different values per hour (hourly amounts), supports only weekday restrictions
  • REGULAR - single price, supports all restrictions
  • ACCUMULATIVE_24H_MAX - price that is valid over multiple services (e.g. parkings) during a 24 hour period
period string no Period for price (e.g. "30 MINUTES", "1 HOUR"). Required for REGULAR. Required for DYNAMIC if price does not cover all 24 hours and all non-zero REGULAR prices. Supported periods: SECOND(S), MINUTE(S), HOUR(S), DAY(S)
amount decimal yes Price for a period.
hourly_amounts Map<number, decimal> no A map where the key is the hour (0-23) and the value is the price for that hour. Only for DYNAMIC price type
restrictions List of restrictions no Optional, can be used on both DYNAMIC and REGULAR prices. Multiple restrictions can be used only for REGULAR price.
type string yes Restriction type. Possible values:
  • WEEKDAYS - List of days when the price is valid
  • FROM_DURATION - Price becomes valid after the service duration is longer than the period
  • UNTIL_DURATION - Price is valid until the service duration is shorter than the period
restrict_to List of strings yes List of weekdays. ex ["MONDAY", "TUESDAY", "..."] for WEEKDAYS type, period (ex. "30 MINUTES", "1 HOUR") for FROM_DURATION and UNTIL_DURATION restriction types

Example request

This example includes:

  • Dynamic price that is valid from Monday to Friday. A different minute price is valid each hour from 9 to 17. The rest of the day has a minute price of 1.0
  • A regular price that defines the daily price. This will be used on days when dynamic price is not valid (weekends) or when the sum of hourly prices would be more expensive.
  • A regular price that makes weekends daily price free if the service (e.g. parking) is longer than 7 days.
  • An accumulative daily price. If the car uses the service multiple times in a 24 hour period, the price can never exceed 400.

{
    "type": "DYNAMIC_PRICING",
    "valid_from": "2023-12-20T11:52:16+0000",
    "prices": [
        {
            "type": "DYNAMIC",
            "restrictions": [
                {
                    "type":"WEEKDAYS",
                    "restrict_to": [
                        "MONDAY",
                        "TUESDAY",
                        "WEDNESDAY",
                        "THURSDAY",
                        "FRIDAY"
                    ]
                }
            ],
            "amount": 1.0,
            "period": "1 MINUTE",
            "hourly_amounts": {
                "9": 2.1,
                "10": 2.1,
                "11": 2.6,
                "12": 2.9,
                "13": 3.1,
                "14": 4.5,
                "15": 2.1,
                "16": 2.0
            }
        },
        {
            "type": "REGULAR",
            "amount": 300.0,
            "period": "24 HOURS"
        },
        {
            "type": "REGULAR",
            "amount": 0,
            "period": "24 HOURS",
            "restrictions": [
                {
                    "type":"WEEKDAYS",
                    "restrict_to": [
                        "SATURDAY",
                        "SUNDAY"
                    ]
                },
                {
                    "type":"FROM_DURATION",
                    "restrict_to": "7 DAYS"
                }
            ]
        },
        {
            "type": "ACCUMULATIVE_24H_MAX",
            "amount": 400.0
        }
    ]
}

Success response

HTTP Code: 204 OK


Example request

PUT https://api.autopay.io/price/v1/product/123456

Error messages

Parameter Type Description
error_id string Specific code of error. See below for possible values
message string Description of error
description string Optional value. Additional description of error.

Example error response

{
    "error_id": "authentication_error",
    "message": "No access token present in header!"
}

Possible error id-s

Error id Explanation
forbidden Unauthorized
internal_server_error Internal server error
missing_property A required property in request is missing
message_not_readable A problem with the request body
server_communication_error Error communication with server
invalid_accumulative_24h_max_price Only 'amount' should be sent with type ACCUMULATIVE_24H_MAX
invalid_regular_price Only 'amount' and 'period' should be sent with type REGULAR
invalid_dynamic_price 'amount', 'period' and 'hourly_amounts' should be sent with type DYNAMIC prices. 'restrictions' is optional.
invalid_weekdays Invalid values for weekdays. Allowed values: [MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY]
invalid_hours Invalid values for hours. Allowed values 0-23
invalid_period Invalid period. Should be a number, followed by a space, followed by [SECOND(S)|MINUTE(S)|HOUR(S)|DAY(S)]
invalid_restriction Invalid restriction type. Allowed values: [WEEKDAYS, FROM_DURATION, UNTIL_DURATION]