> ## 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 promocode

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



## OpenAPI

````yaml /assets/openapi.json post /discounts/v1/promocodes
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/v1/promocodes:
    post:
      tags:
        - Discounts
      summary: Create a promocode
      description: 'Create a promocode. <h3>OAuth</h3>Required scopes: <code>invoices</code>'
      operationId: createPromocode
      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/createPromocode'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  promocode:
                    $ref: '#/components/schemas/promocode'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
      security:
        - BasicAuth: []
        - OAuth2:
            - invoices
components:
  requestBodies:
    createPromocode:
      content:
        application/json:
          schema:
            type: object
            properties:
              promocode:
                type: object
                properties:
                  code:
                    type: string
                    minLength: 1
                    description: Promocode string.
                  couponRef:
                    type: string
                    format: uuid
                    description: ID of the coupon this promocode applies to.
                  expiration:
                    type: object
                    properties:
                      date:
                        description: Expiration date. Required when expiration is enabled.
                        type: string
                      enabled:
                        type: boolean
                        description: Whether the promocode has an expiration date.
                    required:
                      - enabled
                    description: Promocode expiration settings.
                  limitByFirstPurchase:
                    type: boolean
                    description: Whether the promocode is limited to first-time purchases.
                  limitedRedemption:
                    type: object
                    properties:
                      enabled:
                        type: boolean
                        description: Whether redemption limits are enabled.
                      value:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                        description: Maximum redemption count.
                    required:
                      - enabled
                      - value
                    description: Redemption limits for the promocode.
                required:
                  - code
                  - couponRef
                  - expiration
                  - limitByFirstPurchase
                  - limitedRedemption
                description: Promocode to create.
            required:
              - promocode
      required: true
  schemas:
    promocode:
      type: object
      properties:
        archiveDate:
          description: ISO timestamp of when the promocode was archived.
          type: string
          format: date-time
        code:
          type: string
          description: Promocode string.
        couponRef:
          type: string
          format: uuid
          description: ID of the coupon this promocode applies to.
        createDate:
          type: string
          format: date-time
          description: ISO timestamp of when the promocode was created.
        expiration:
          type: object
          properties:
            date:
              description: ISO timestamp when the promocode expires.
              type: string
              format: date-time
            enabled:
              type: boolean
              description: Whether the promocode has an expiration date.
          required:
            - enabled
          additionalProperties: false
          description: Promocode expiration settings.
        id:
          type: string
          format: uuid
          description: Unique identifier of the promocode.
        limitByFirstPurchase:
          type: boolean
          description: Whether the promocode is limited to first-time purchases.
        limitedRedemption:
          type: object
          properties:
            enabled:
              type: boolean
              description: Whether redemption limits are enabled.
            usage:
              type: number
              description: Current redemption count.
            value:
              type: number
              description: Maximum redemption count.
          required:
            - enabled
            - usage
            - value
          additionalProperties: false
          description: Redemption limits for the promocode.
        locationRef:
          type: string
          format: uuid
          description: ID of the location this promocode belongs to.
        networkRef:
          type: string
          format: uuid
          description: ID of the network this promocode belongs to.
      required:
        - code
        - couponRef
        - createDate
        - expiration
        - id
        - limitByFirstPurchase
        - limitedRedemption
        - locationRef
        - networkRef
      additionalProperties: false
    responseError:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
  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 contracts, credit notes, discounts and invoices
            invoices: Read and write contract, credit notes, discounts and 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

````