Skip to content

Create

/vouchers

Target audience: Developers

Create voucher

Introduction

This endpoint lets you create a voucher.

URI

Environment URI
Stage https://payway-api.stage.adeprimo.se/external/api/v1/vouchers
Production https://backend.worldoftulo.com/external/api/v1/vouchers

Requirements

Identity Scope
No /external/voucher/w

Parameters

Field Required Type Description
package_code Required String The package_code for which the voucher is valid.
Size range: ..50
expires_at Required DateTime Time of voucher expiration
days_of_access Required Integer This describes for how long the access should be granted by this voucher.
Size range: 1..9999

Curl Example

curl --request POST \
  --url https://payway-api.stage.adeprimo.se/external/api/v1/vouchers \
  --header 'accept: application/json' \
  --header 'authorization: Bearer token' \
  --header 'content-type: application/json' \
  --data '{
            :package_code => "adeprimo_paper",
            :expires_at => "2018-10-18T14:42:19Z",
            :days_of_access => 30
          }'

Response

Field Description
object The created voucher

Example Response

HTTP 200 Updated
{
  "item": [
      {
          "id": "5bc89acf1d41c8aa42000003",
          "organisation_id": "adeprimo",
          "package_code": "adeprimo_paper",
          "days_of_access": 30,
          "voucher_code": "1c53651b4fb61486c21c88f141935d07",
          "created_at": "2018-10-18T14:38:07Z",
          "expires_at": "2018-10-18T14:42:19Z",
          "redeemed_at": null
      }
  ]
}

Errors

Example error response

HTTP 400 Bad Request
{
    "code": "invalid_parameter",
    "field": "account_id",
    "message": "Parameter must match format (/^[a-f\d]{24}$/)"
}

HTTP 400 Bad Request

Name Type Description
invalid_parameter Object Validation error on any of the fields in the posted json
json_parser_error Object The request body could not be parsed as valid json
invalid_content_type_error Object The requests Content-Type header isn't set to application/json
unknown_parameter Object One or more of the fields in the posted json was not recognized

HTTP 404 Not Found

Name Type Description
not_found Object The package could not be found

HTTP 409 Conflict

Name Type Description
already_exist Object Indicates that a value that must be unique and already exists have been used. I.e. the campaign code is already taken
payment_option_already_exists Object There is already a duplicate payment option on the campaign
payment_option_cannot_transform Object The campaign cannot transform to normal package
no_transition_period Object One of the payment options does not have a transition period

HTTP 500 Internal Server Error

Name Type Description
internal_server_error Object Something unexpected happened server side