---
agentTools:
  projectIndex: https://copperx.readme.io/llms.txt
---

# Create a coupon

Creates a coupon

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "paths": {
    "/api/v1/coupons": {
      "post": {
        "operationId": "CouponController_create",
        "summary": "Create a coupon",
        "description": "Creates a coupon",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCouponDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CouponDto"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorDto"
                }
              }
            }
          }
        },
        "tags": [
          "Coupons"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    }
  },
  "info": {
    "title": "Copperx API",
    "description": "Copperx APIs allows you to access to manage payments, transactions and more in a simple way. Our APIs are easy to use and provide an intuitive APIs for developers to create powerful applications.",
    "version": "v0.0.0",
    "contact": {
      "name": "Copperx",
      "url": "https://t.me/+bVxXaalfhF8wMDFl",
      "email": "support@copperx.io"
    }
  },
  "servers": [
    {
      "url": "https://api.copperx.dev",
      "description": "Test"
    },
    {
      "url": "https://api.copperx.io",
      "description": "Production"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "type": "http"
      }
    },
    "schemas": {
      "ErrorDto": {
        "type": "object",
        "properties": {
          "message": {
            "type": "object"
          },
          "statusCode": {
            "type": "number"
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "message",
          "statusCode",
          "error"
        ]
      },
      "PromotionCodeSlimDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Promotion code id"
          },
          "organizationId": {
            "type": "string",
            "description": "Organization id"
          },
          "code": {
            "type": "string",
            "description": "The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer.",
            "maxLength": 20,
            "minLength": 2
          },
          "couponId": {
            "type": "string",
            "description": "Coupon id"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the promotion code is currently active. A promotion code is only active if the coupon is also enabled."
          },
          "expiredAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date at which the promotion code can no longer be redeemed. If the coupon has specified a redeems_by, then this value cannot be after the coupon’s redeems_by."
          },
          "maxRedemptions": {
            "type": "number",
            "example": 1,
            "description": "Maximum number of times this promotion code can be redeemed. If the coupon has specified a max_redemptions, then this value cannot be greater than the coupon’s max_redemptions."
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date at which the promotion code was created"
          },
          "metadata": {
            "type": "object",
            "description": "A set of key-value pairs that you can attach to an object. It can be useful for storing additional information about the object in a structured format."
          }
        },
        "required": [
          "id",
          "organizationId",
          "code",
          "couponId",
          "isActive"
        ]
      },
      "CouponStatus": {
        "type": "string",
        "enum": [
          "active",
          "expired",
          "disabled",
          "limit_reached"
        ]
      },
      "CouponDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Coupon id"
          },
          "organizationId": {
            "type": "string",
            "description": "Organization id"
          },
          "name": {
            "type": "string",
            "description": "Name of the coupon displayed to customers on for instance invoices or receipts."
          },
          "percentOff": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "example": 1,
            "description": "Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon."
          },
          "amountOff": {
            "format": "int64",
            "type": "integer",
            "example": "9223372036854775807",
            "description": "Fixed amount that will be taken off the subtotal of any invoices for this customer for the duration of the coupon.",
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "description": "Name of the currency displayed to customers on for instance invoices or receipts."
          },
          "maxRedemptions": {
            "type": "number",
            "example": 1,
            "description": "Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid."
          },
          "redeemBy": {
            "format": "date-time",
            "type": "string",
            "description": "Date after which the coupon can no longer be redeemed"
          },
          "isEnable": {
            "type": "boolean",
            "description": "Taking account of the above properties, whether this coupon can still be applied to a customer."
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Time at which this coupon was created."
          },
          "metadata": {
            "type": "object",
            "description": "A set of key-value pairs that you can attach to an object. It can be useful for storing additional information about the object in a structured format."
          },
          "isArchived": {
            "type": "boolean",
            "description": "Whether the coupon is archived."
          },
          "archivedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date at which the coupon was archived"
          },
          "promotionCodes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromotionCodeSlimDto"
            }
          },
          "status": {
            "description": "The status of the coupon.",
            "$ref": "#/components/schemas/CouponStatus"
          },
          "timesRedeemed": {
            "type": "number",
            "example": 1,
            "description": "Number of times this coupon has been applied."
          }
        },
        "required": [
          "id",
          "organizationId",
          "name",
          "isEnable",
          "isArchived",
          "promotionCodes",
          "status"
        ]
      },
      "PromotionCodeDataDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer.",
            "maxLength": 20,
            "minLength": 2
          },
          "expiredAt": {
            "format": "date-time",
            "type": "string",
            "description": "Date at which the promotion code can no longer be redeemed. If the coupon has specified a redeems_by, then this value cannot be after the coupon’s redeems_by."
          },
          "maxRedemptions": {
            "type": "number",
            "example": 1,
            "description": "Maximum number of times this promotion code can be redeemed. If the coupon has specified a max_redemptions, then this value cannot be greater than the coupon’s max_redemptions."
          },
          "metadata": {
            "type": "object",
            "description": "A set of key-value pairs that you can attach to an object. It can be useful for storing additional information about the object in a structured format."
          }
        },
        "required": [
          "code"
        ]
      },
      "CreatePromotionCodeItemsDto": {
        "type": "object",
        "properties": {
          "data": {
            "minItems": 1,
            "maxItems": 1,
            "description": "The line items to be used to create promotion code",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PromotionCodeDataDto"
            }
          }
        },
        "required": [
          "data"
        ]
      },
      "CreateCouponDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the coupon displayed to customers on for instance invoices or receipts."
          },
          "percentOff": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "example": 1,
            "description": "Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon."
          },
          "amountOff": {
            "format": "int64",
            "type": "integer",
            "example": "9223372036854775807",
            "description": "Fixed amount that will be taken off the subtotal of any invoices for this customer for the duration of the coupon.",
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "description": "Name of the currency displayed to customers on for instance invoices or receipts."
          },
          "maxRedemptions": {
            "type": "number",
            "example": 1,
            "description": "Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid."
          },
          "redeemBy": {
            "format": "date-time",
            "type": "string",
            "description": "Date after which the coupon can no longer be redeemed"
          },
          "metadata": {
            "type": "object",
            "description": "A set of key-value pairs that you can attach to an object. It can be useful for storing additional information about the object in a structured format."
          },
          "isEnable": {
            "type": "boolean",
            "description": "Taking account of the above properties, whether this coupon can still be applied to a customer."
          },
          "promotionCodeData": {
            "description": "The items to be used to create promotion code",
            "allOf": [
              {
                "$ref": "#/components/schemas/CreatePromotionCodeItemsDto"
              }
            ]
          }
        },
        "required": [
          "name",
          "promotionCodeData"
        ]
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 99,
      "1": 181,
      "2": 177,
      "3": 27,
      "4": 23,
      "5": 171,
      "6": 139,
      "7": 0,
      "8": 127,
      "9": 93,
      "10": 212,
      "11": 76
    }
  }
}
```