Save a coupon

POST /V1/coupons

Save a coupon.

Body

  • coupon object Required

    Interface CouponInterface

    Hide coupon attributes Show coupon attributes object
    • coupon_id integer

      Coupon id

    • rule_id integer Required

      The id of the rule associated with the coupon

    • code string

      Coupon code

    • usage_limit integer

      Usage limit

    • usage_per_customer integer

      Usage limit per customer

    • times_used integer Required

      The number of times the coupon has been used

    • expiration_date string

      Expiration date

    • is_primary boolean Required

      The coupon is primary coupon for the rule that it's associated with

    • created_at string

      When the coupon is created

    • type integer

      Of coupon

    • extension_attributes object

      ExtensionInterface class for @see \Magento\SalesRule\Api\Data\CouponInterface

Responses

  • 200

    200 Success.

    Hide response attributes Show response attributes object
    • coupon_id integer

      Coupon id

    • rule_id integer Required

      The id of the rule associated with the coupon

    • code string

      Coupon code

    • usage_limit integer

      Usage limit

    • usage_per_customer integer

      Usage limit per customer

    • times_used integer Required

      The number of times the coupon has been used

    • expiration_date string

      Expiration date

    • is_primary boolean Required

      The coupon is primary coupon for the rule that it's associated with

    • created_at string

      When the coupon is created

    • type integer

      Of coupon

    • extension_attributes object

      ExtensionInterface class for @see \Magento\SalesRule\Api\Data\CouponInterface

  • 401

    401 Unauthorized

    Hide response attributes Show response attributes object
    • message string Required

      Error message

    • errors array[object]

      Error details

      Error details

      Hide errors attributes Show errors attributes object
      • message string

        Error message

      • parameters array[object]

        Error parameters item

        Error parameters item

        Hide parameters attributes Show parameters attributes object
        • resources string

          ACL resource

        • fieldName string

          Missing or invalid field name

        • fieldValue string

          Incorrect field value

    • code integer

      Error code

    • parameters array[object]

      Error parameters item

      Error parameters item

      Hide parameters attributes Show parameters attributes object
      • resources string

        ACL resource

      • fieldName string

        Missing or invalid field name

      • fieldValue string

        Incorrect field value

    • trace string

      Stack trace

  • 400

    400 Bad Request

    Hide response attributes Show response attributes object
    • message string Required

      Error message

    • errors array[object]

      Error details

      Error details

      Hide errors attributes Show errors attributes object
      • message string

        Error message

      • parameters array[object]

        Error parameters item

        Error parameters item

        Hide parameters attributes Show parameters attributes object
        • resources string

          ACL resource

        • fieldName string

          Missing or invalid field name

        • fieldValue string

          Incorrect field value

    • code integer

      Error code

    • parameters array[object]

      Error parameters item

      Error parameters item

      Hide parameters attributes Show parameters attributes object
      • resources string

        ACL resource

      • fieldName string

        Missing or invalid field name

      • fieldValue string

        Incorrect field value

    • trace string

      Stack trace

  • 500

    Internal Server error

    Hide response attributes Show response attributes object
    • message string Required

      Error message

    • errors array[object]

      Error details

      Error details

      Hide errors attributes Show errors attributes object
      • message string

        Error message

      • parameters array[object]

        Error parameters item

        Error parameters item

        Hide parameters attributes Show parameters attributes object
        • resources string

          ACL resource

        • fieldName string

          Missing or invalid field name

        • fieldValue string

          Incorrect field value

    • code integer

      Error code

    • parameters array[object]

      Error parameters item

      Error parameters item

      Hide parameters attributes Show parameters attributes object
      • resources string

        ACL resource

      • fieldName string

        Missing or invalid field name

      • fieldValue string

        Incorrect field value

    • trace string

      Stack trace

  • default

    Unexpected error

    Hide response attributes Show response attributes object
    • message string Required

      Error message

    • errors array[object]

      Error details

      Error details

      Hide errors attributes Show errors attributes object
      • message string

        Error message

      • parameters array[object]

        Error parameters item

        Error parameters item

        Hide parameters attributes Show parameters attributes object
        • resources string

          ACL resource

        • fieldName string

          Missing or invalid field name

        • fieldValue string

          Incorrect field value

    • code integer

      Error code

    • parameters array[object]

      Error parameters item

      Error parameters item

      Hide parameters attributes Show parameters attributes object
      • resources string

        ACL resource

      • fieldName string

        Missing or invalid field name

      • fieldValue string

        Incorrect field value

    • trace string

      Stack trace

POST /V1/coupons
curl \
 --request POST 'https://magento2.winkelstraat.mac/rest/all/V1/coupons' \
 --data '{"coupon":{"coupon_id":42,"rule_id":42,"code":"string","usage_limit":42,"usage_per_customer":42,"times_used":42,"expiration_date":"string","is_primary":true,"created_at":"string","type":42,"extension_attributes":{}}}'
Request examples
{
  "coupon": {
    "coupon_id": 42,
    "rule_id": 42,
    "code": "string",
    "usage_limit": 42,
    "usage_per_customer": 42,
    "times_used": 42,
    "expiration_date": "string",
    "is_primary": true,
    "created_at": "string",
    "type": 42,
    "extension_attributes": {}
  }
}
Response examples (200)
{
  "coupon_id": 42,
  "rule_id": 42,
  "code": "string",
  "usage_limit": 42,
  "usage_per_customer": 42,
  "times_used": 42,
  "expiration_date": "string",
  "is_primary": true,
  "created_at": "string",
  "type": 42,
  "extension_attributes": {}
}
Response examples (401)
{
  "message": "string",
  "errors": [
    {
      "message": "string",
      "parameters": [
        {
          "resources": "string",
          "fieldName": "string",
          "fieldValue": "string"
        }
      ]
    }
  ],
  "code": 42,
  "parameters": [
    {
      "resources": "string",
      "fieldName": "string",
      "fieldValue": "string"
    }
  ],
  "trace": "string"
}
Response examples (400)
{
  "message": "string",
  "errors": [
    {
      "message": "string",
      "parameters": [
        {
          "resources": "string",
          "fieldName": "string",
          "fieldValue": "string"
        }
      ]
    }
  ],
  "code": 42,
  "parameters": [
    {
      "resources": "string",
      "fieldName": "string",
      "fieldValue": "string"
    }
  ],
  "trace": "string"
}
Response examples (500)
{
  "message": "string",
  "errors": [
    {
      "message": "string",
      "parameters": [
        {
          "resources": "string",
          "fieldName": "string",
          "fieldValue": "string"
        }
      ]
    }
  ],
  "code": 42,
  "parameters": [
    {
      "resources": "string",
      "fieldName": "string",
      "fieldValue": "string"
    }
  ],
  "trace": "string"
}
Response examples (default)
{
  "message": "string",
  "errors": [
    {
      "message": "string",
      "parameters": [
        {
          "resources": "string",
          "fieldName": "string",
          "fieldValue": "string"
        }
      ]
    }
  ],
  "code": 42,
  "parameters": [
    {
      "resources": "string",
      "fieldName": "string",
      "fieldValue": "string"
    }
  ],
  "trace": "string"
}