> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salesive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a coupon

> Create a new discount coupon for the store. Requires the WRITE_DISCOUNTS scope.

Creates a coupon; the code is uppercased automatically and must be unique within the store. The owning store and user are set server-side — never send a shop id.


## OpenAPI

````yaml POST /coupons
openapi: 3.1.0
info:
  title: Salesive Apps API — Discounts & Blogs
  version: 1.0.0
  description: >-
    Read and manage the store's discount coupons and blog posts from an
    installed third-party app. Every endpoint authenticates with an
    installed-app access token (prefix `app_`) and requires a specific OAuth
    scope. The target store is bound to the token server-side from the
    installation — never send a shop id.
servers:
  - url: https://api.salesive.com/api/v1
    description: Production
security:
  - AppToken: []
paths:
  /coupons:
    post:
      tags:
        - Coupons
      summary: Create a coupon
      description: >-
        Creates a new discount coupon for the store. The code is uppercased
        automatically and must be unique within the store. The owning store and
        user are set server-side from the app installation — never send a shop
        id. Requires the `WRITE_DISCOUNTS` scope.
      operationId: createCoupon
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CouponCreate'
            example:
              code: SUMMER20
              type: percentage
              discount: 20
              usageLimit: 100
              usagePerUser: 1
              minimumOrderAmount: 5000
              startDate: '2026-06-01T00:00:00.000Z'
              endDate: '2026-08-31T23:59:59.000Z'
              active: true
      responses:
        '201':
          description: The created coupon.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/EnvelopeBase'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/Coupon'
              example:
                status: 201
                success: true
                message: Coupon created successfully
                data:
                  _id: 66b1f2a9c4d5e6f7a8b9c0d1
                  code: SUMMER20
                  user: 66a0e1b2c3d4e5f6a7b8c9d0
                  shop: 66a0d1c2b3a4958677564738
                  type: percentage
                  discount: 20
                  usageLimit: 100
                  usageCount: 0
                  usagePerUser: 1
                  minimumOrderAmount: 5000
                  startDate: '2026-06-01T00:00:00.000Z'
                  endDate: '2026-08-31T23:59:59.000Z'
                  active: true
                  createdAt: '2026-06-28T12:00:00.000Z'
                  updatedAt: '2026-06-28T12:00:00.000Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    CouponCreate:
      type: object
      description: Fields accepted when creating a coupon.
      required:
        - code
        - type
        - discount
        - startDate
        - endDate
      properties:
        code:
          type: string
          description: >-
            Coupon code (alphanumeric only). Stored uppercase; must be unique
            within the store.
        type:
          type: string
          enum:
            - fixed
            - percentage
          description: 'Discount type: `fixed` or `percentage`.'
        discount:
          type: number
          exclusiveMinimum: 0
          description: >-
            Discount amount. For `percentage` this is a percent value; for
            `fixed` it is an amount. Must be greater than 0.
        usageLimit:
          type: integer
          minimum: 1
          default: 1
          description: >-
            Maximum total redemptions across all customers. Minimum 1. Defaults
            to 1.
        usagePerUser:
          type: integer
          minimum: 1
          default: 1
          description: Maximum redemptions per customer. Minimum 1. Defaults to 1.
        minimumOrderAmount:
          type: number
          minimum: 0
          default: 0
          description: >-
            Minimum order subtotal required to apply the coupon. Cannot be
            negative. Defaults to 0.
        startDate:
          type: string
          format: date-time
          description: Date the coupon becomes valid (ISO 8601).
        endDate:
          type: string
          format: date-time
          description: Date the coupon expires (ISO 8601). Must be on or after startDate.
        active:
          type: boolean
          default: true
          description: Whether the coupon is active. Defaults to true.
    EnvelopeBase:
      type: object
      description: >-
        Standard Salesive response envelope. The operation-specific payload is
        carried in `data`.
      required:
        - status
        - success
        - message
      properties:
        status:
          type: integer
          description: HTTP status code, echoed in the body.
        success:
          type: boolean
          description: Whether the request succeeded.
        message:
          type: string
          description: Human-readable result message.
    Coupon:
      type: object
      description: A store-scoped discount coupon.
      properties:
        _id:
          type: string
        code:
          type: string
          description: Coupon code, stored uppercase. Unique within the store.
        user:
          type: string
          description: Id of the user who owns the coupon (set server-side).
        shop:
          type: string
          description: The store id (bound server-side).
        type:
          type: string
          enum:
            - fixed
            - percentage
          description: Discount type.
        discount:
          type: number
          description: >-
            Discount amount; a percent value for `percentage`, an amount for
            `fixed`.
        usageLimit:
          type: integer
          description: Maximum total redemptions across all customers.
        usageCount:
          type: integer
          description: Number of times the coupon has been redeemed.
        usagePerUser:
          type: integer
          description: Maximum redemptions per customer.
        minimumOrderAmount:
          type: number
          description: Minimum order subtotal required to apply the coupon.
        startDate:
          type: string
          format: date-time
          description: Date the coupon becomes valid.
        endDate:
          type: string
          format: date-time
          description: Date the coupon expires.
        active:
          type: boolean
          description: Whether the coupon is active.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    Envelope:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          properties:
            data:
              description: Operation-specific payload (object, array, or null).
  responses:
    Unauthorized:
      description: Missing or invalid app access token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 401
            success: false
            message: Authentication required
            data: null
    Forbidden:
      description: The app token is missing the OAuth scope required for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 403
            success: false
            message: Insufficient scope
            data: null
  securitySchemes:
    AppToken:
      type: http
      scheme: bearer
      description: >-
        Installed-app access token (prefix app_), issued by the OAuth install
        flow. The store is bound to the token server-side — never send a shop
        id.

````