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

# Create a coupon

> Create a coupon. <h3>OAuth</h3>Required scopes: <code>invoices</code>



## OpenAPI

````yaml /assets/openapi.json post /discounts/coupons/v1
openapi: 3.0.2
info:
  title: Spacebring
  version: 1.0.0
  termsOfService: https://www.spacebring.com/terms
servers:
  - url: https://api.spacebring.com
security: []
paths:
  /discounts/coupons/v1:
    post:
      tags:
        - Discounts
      summary: Create a coupon
      description: 'Create a coupon. <h3>OAuth</h3>Required scopes: <code>invoices</code>'
      operationId: createCoupon
      parameters:
        - in: header
          name: spacebring-network-id
          schema:
            type: string
            format: uuid
          required: false
          description: >-
            The id of the network. Required when using bearer token
            authentication
      requestBody:
        $ref: '#/components/requestBodies/createCoupon'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  coupon:
                    $ref: '#/components/schemas/coupon'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
      security:
        - BasicAuth: []
        - OAuth2:
            - invoices
components:
  requestBodies:
    createCoupon:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              coupon:
                type: object
                properties:
                  amountOff:
                    type: number
                    minimum: 0
                    exclusiveMinimum: true
                    description: >-
                      Fixed discount amount. Either amountOff or percentOff is
                      required, but not both
                  duration:
                    type: string
                    enum:
                      - forever
                      - once
                      - repeating
                    description: Required when productTypes includes subscriptionItems
                  durationInMonths:
                    type: integer
                    minimum: 1
                    description: Required when duration is repeating
                  enabledForCredits:
                    type: boolean
                    description: Required when percentOff is provided
                  limitedItems:
                    type: object
                    properties:
                      enabled:
                        type: boolean
                      values:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              format: uuid
                    required:
                      - enabled
                      - values
                  limitedRedemption:
                    type: object
                    properties:
                      enabled:
                        type: boolean
                      value:
                        type: number
                    required:
                      - enabled
                      - value
                  locationRef:
                    type: string
                    format: uuid
                  percentOff:
                    type: number
                    minimum: 0
                    exclusiveMinimum: true
                    maximum: 100
                    description: >-
                      Percentage discount. Either amountOff or percentOff is
                      required, but not both
                  productTypes:
                    type: array
                    minItems: 1
                    items:
                      type: string
                      enum:
                        - roomBookings
                        - hotDeskBookings
                        - dedicatedDeskBookings
                        - parkingBookings
                        - equipmentBookings
                        - eventTickets
                        - shopProducts
                        - packages
                        - subscriptionItems
                    description: >-
                      Which product categories the coupon applies to. At least
                      one value is required.
                required:
                  - limitedItems
                  - limitedRedemption
                  - locationRef
                  - productTypes
            required:
              - coupon
  schemas:
    coupon:
      type: object
      properties:
        amountOff:
          type: number
          nullable: true
        createDate:
          $ref: '#/components/schemas/dateSchema'
        currencyCode:
          nullable: true
          type: string
        deleteDate:
          $ref: '#/components/schemas/dateSchema'
        duration:
          type: string
          enum:
            - forever
            - once
            - repeating
          nullable: true
        durationInMonths:
          type: integer
          nullable: true
        enabledForCredits:
          type: boolean
          nullable: true
        id:
          type: string
          format: uuid
        limitedItems:
          type: object
          properties:
            enabled:
              type: boolean
            values:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  title:
                    type: string
        limitedRedemption:
          type: object
          properties:
            enabled:
              type: boolean
            usage:
              type: integer
            value:
              type: integer
        locationRef:
          type: string
          format: uuid
        networkRef:
          type: string
          format: uuid
        percentOff:
          type: number
          nullable: true
        productTypes:
          type: array
          items:
            type: string
            enum:
              - roomBookings
              - hotDeskBookings
              - dedicatedDeskBookings
              - parkingBookings
              - equipmentBookings
              - eventTickets
              - shopProducts
              - packages
              - subscriptionItems
        type:
          type: string
          enum:
            - creditPackages
            - desks
            - equipment
            - events
            - products
            - rooms
            - subscriptionItems
          deprecated: true
    responseError:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
    dateSchema:
      format: date-time
      type: string
      description: The date and time in ISO 8601 format, e.g. 2021-05-21T10:00:00Z
  securitySchemes:
    BasicAuth:
      type: http
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/api-reference/authentication#basic-authentication)
        for how to authorize your requests
      scheme: basic
    OAuth2:
      type: oauth2
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/api-reference/authentication#oauth2)
        for how to authorize your requests
      flows:
        authorizationCode:
          authorizationUrl: https://api.spacebring.com/oauth2/authorize
          tokenUrl: https://api.spacebring.com/oauth2/token
          refreshUrl: https://api.spacebring.com/oauth2/token
          scopes:
            benefits.readonly: Read benefits and applications
            benefits: Read and write benefits and applications
            community.readonly: Read community companies and memberships
            community: Read and write community companies and memberships
            events.readonly: Read events and tickets
            events: Read and write events and tickets
            feed.readonly: Read feed posts
            feed: Read and write feed posts
            invoices.readonly: Read invoices
            invoices: Read and write invoices
            locations.readonly: Read locations
            locations: Read and write locations
            plans.readonly: Read plans
            plans: Read and write plans
            resources.readonly: Read resources and bookings
            resources: Read and write resources and bookings
            subscriptions.readonly: Read subscriptions
            subscriptions: Read and write subscriptions
            shop.readonly: Read products and orders
            shop: Read and write products and orders
            support.readonly: Read support tickets
            support: Read and write support tickets
            transactions.readonly: Read transactions
            transactions: Read and write transactions
            visitors.readonly: Read visitors
            visitors: Read and write visitors

````