> ## 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 credit transaction

> Create a credits transaction. <h3>OAuth</h3>Required scopes: <code>transactions</code>



## OpenAPI

````yaml /assets/openapi.json post /transactions/credits/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:
  /transactions/credits/v1:
    post:
      tags:
        - Transactions
      summary: Create a credit transaction
      description: >-
        Create a credits transaction. <h3>OAuth</h3>Required scopes:
        <code>transactions</code>
      operationId: createCreditsTransaction
      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/createCreditsTransaction'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createCreditsTransaction'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
      security:
        - BasicAuth: []
        - OAuth2:
            - transactions
components:
  requestBodies:
    createCreditsTransaction:
      content:
        application/json:
          schema:
            type: object
            properties:
              transaction:
                type: object
                properties:
                  amount:
                    type: number
                    description: Credits amount. Must be greater than zero.
                  companyRef:
                    deprecated: true
                    description: Deprecated. Use customerRef instead.
                    type: string
                    format: uuid
                  customerRef:
                    description: >-
                      The company or membership id to charge or transfer credits
                      to or from.
                    type: string
                    format: uuid
                  description:
                    description: Description of the transaction.
                    type: string
                  expirationDate:
                    description: Expiration date for expiring credits.
                    type: string
                  locationRef:
                    type: string
                    format: uuid
                    description: The location id where to create the transaction.
                  membershipRef:
                    deprecated: true
                    description: Deprecated. Use customerRef instead.
                    type: string
                    format: uuid
                  type:
                    type: string
                    enum:
                      - adminAllocation
                      - adminCharge
                      - chargeExpiringCredits
                      - chargePermanentCredits
                      - transferExpiringCredits
                      - transferPermanentCredits
                    description: >-
                      Transaction type. chargeExpiringCredits,
                      chargePermanentCredits, transferExpiringCredits, and
                      transferPermanentCredits are deprecated; use adminCharge
                      or adminAllocation instead.
                required:
                  - amount
                  - locationRef
                  - type
                description: Credits transaction to create.
            required:
              - transaction
      required: true
  schemas:
    createCreditsTransaction:
      type: object
      properties:
        transaction:
          type: object
          properties:
            amount:
              type: number
              description: Total credits amount (absolute sum of expiring and permanent).
            amounts:
              type: array
              items:
                type: object
                properties:
                  amount:
                    type: number
                    description: Amount deducted from this balance bucket.
                  expirationDate:
                    description: Expiration date for expiring balances.
                    type: string
                    format: date-time
                  subscriptionRef:
                    description: Subscription associated with expiring balances.
                    type: string
                    format: uuid
                  type:
                    type: string
                    enum:
                      - expiring
                      - permanent
                    description: Balance bucket type.
                required:
                  - amount
                  - type
                additionalProperties: false
              description: Per-bucket amounts for charge transactions.
            booking:
              deprecated: true
              description: Deprecated. Use product instead.
              type: object
              properties:
                endDate:
                  description: Booking end date.
                  type: string
                  format: date-time
                id:
                  type: string
                  format: uuid
                  description: Booking id.
                resource:
                  type: object
                  properties:
                    id:
                      type: string
                      format: uuid
                      description: Resource id.
                    title:
                      type: string
                      description: Resource title.
                  required:
                    - id
                    - title
                  additionalProperties: false
                  description: Booked resource.
                startDate:
                  description: Booking start date.
                  type: string
                  format: date-time
              required:
                - id
                - resource
              additionalProperties: false
            company:
              deprecated: true
              description: Deprecated. Use customer instead.
              type: object
              properties:
                createDate:
                  type: string
                  format: date-time
                  description: ISO timestamp of company creation.
                id:
                  type: string
                  format: uuid
                  description: Company id.
                locationRef:
                  type: string
                  format: uuid
                  description: Location id.
                logo:
                  description: Company logo.
                  type: object
                  properties:
                    key:
                      type: string
                      description: Storage key of the company logo.
                    url:
                      type: string
                      description: Public URL of the company logo.
                  required:
                    - key
                    - url
                  additionalProperties: false
                metadata:
                  description: Company metadata.
                  type: object
                  additionalProperties: {}
                notes:
                  description: Internal notes.
                  type: string
                publicLogoUrl:
                  description: Public logo URL derived from the company website.
                  type: string
                subscriptionRef:
                  nullable: true
                  description: Primary subscription id.
                  type: string
                  format: uuid
                title:
                  description: Company name.
                  type: string
              required:
                - createDate
                - id
                - locationRef
                - subscriptionRef
                - title
              additionalProperties: false
            companyRef:
              deprecated: true
              description: Deprecated. Use customer instead.
              type: string
              format: uuid
            createDate:
              type: string
              format: date-time
              description: ISO timestamp of when the transaction was created.
            customer:
              type: object
              properties:
                id:
                  type: string
                  format: uuid
                  description: ID of the company or membership.
                logo:
                  description: Company logo.
                  type: object
                  properties:
                    key:
                      type: string
                    url:
                      type: string
                  required:
                    - key
                    - url
                  additionalProperties: false
                publicLogoUrl:
                  description: Public logo URL derived from the company website.
                  type: string
                title:
                  description: Company name.
                  type: string
                type:
                  type: string
                  enum:
                    - company
                    - user
                  description: Whether the customer is a company or a user.
                user:
                  description: User details for membership customers.
                  type: object
                  properties:
                    about:
                      nullable: true
                      type: string
                    email:
                      nullable: true
                      type: string
                    id:
                      type: string
                      format: uuid
                    name:
                      nullable: true
                      type: string
                    phoneNumber:
                      nullable: true
                      type: string
                    photoUrl:
                      nullable: true
                      type: string
                    surname:
                      nullable: true
                      type: string
                  required:
                    - id
                  additionalProperties: false
              required:
                - id
                - type
              additionalProperties: false
              description: Customer associated with this transaction.
            customerRefCreatedBy:
              description: >-
                ID of the customer the user who created the transaction belongs
                to.
              type: string
              format: uuid
            description:
              description: Transaction description.
              type: string
            discounts:
              description: Discounts applied to the transaction.
              type: array
              items:
                type: object
                properties:
                  coupon:
                    type: object
                    properties:
                      amountOff:
                        description: Fixed amount discount.
                        type: number
                      currencyCode:
                        description: Currency of the fixed amount discount.
                        type: string
                      id:
                        description: Coupon id.
                        type: string
                      percentOff:
                        description: Percentage discount.
                        type: number
                      productTypes:
                        description: Product types the coupon applies to.
                        type: array
                        items:
                          type: string
                      type:
                        description: Coupon type.
                        type: string
                    required:
                      - id
                      - type
                    additionalProperties: false
                    description: Applied coupon.
                  promocode:
                    description: Promocode the coupon was applied with.
                    type: object
                    properties:
                      code:
                        type: string
                        description: Promocode.
                      expiration:
                        description: Promocode expiration date.
                        type: string
                      id:
                        type: string
                        format: uuid
                        description: Promocode id.
                      limitByFirstPurchase:
                        description: >-
                          Whether the promocode is limited to the first
                          purchase.
                        type: boolean
                    required:
                      - code
                      - id
                    additionalProperties: false
                  subscriptionId:
                    description: ID of the subscription this discount is associated with.
                    type: string
                    format: uuid
                required:
                  - coupon
                additionalProperties: false
            endingBalance:
              description: >-
                Total credits balance of the customer right after the
                transaction. Not returned for transactions created before the
                field was introduced, or for the expiration of credits that
                lapsed on their expiration date.
              type: number
            expiringAmount:
              deprecated: true
              description: Deprecated. Use amounts instead.
              type: number
            id:
              type: string
              format: uuid
              description: Unique identifier of the transaction.
            locationRef:
              type: string
              format: uuid
              description: ID of the organization (location).
            membershipRef:
              deprecated: true
              description: Deprecated. Use customer instead.
              type: string
              format: uuid
            membershipRefCreator:
              deprecated: true
              description: Deprecated. Use customerRefCreatedBy instead.
              type: string
              format: uuid
            networkRef:
              type: string
              format: uuid
              description: ID of the network.
            order:
              deprecated: true
              description: Deprecated. Use product instead.
              type: object
              properties:
                id:
                  type: string
                  format: uuid
                  description: Order id.
                items:
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: Order item id.
                      product:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                            description: Product id.
                          option:
                            description: Product option.
                            type: object
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: Product option id.
                              title:
                                type: string
                                description: Product option title.
                            required:
                              - id
                              - title
                            additionalProperties: false
                          title:
                            type: string
                            description: Product title.
                        required:
                          - id
                          - title
                        additionalProperties: false
                        description: Ordered product.
                      quantity:
                        type: number
                        description: Quantity of units.
                    required:
                      - id
                      - product
                      - quantity
                    additionalProperties: false
                  description: Order items.
              required:
                - id
                - items
              additionalProperties: false
            permanentAmount:
              deprecated: true
              description: Deprecated. Use amounts instead.
              type: number
            product:
              description: Product details.
              type: object
              properties:
                bookingRef:
                  description: ID of the associated booking.
                  type: string
                  format: uuid
                eventTicketRef:
                  description: ID of the associated event ticket.
                  type: string
                  format: uuid
                orderRef:
                  description: ID of the associated order.
                  type: string
                  format: uuid
                title:
                  type: string
                  description: Display title of the product.
                type:
                  description: Product type.
                  type: string
                  enum:
                    - booking
                    - eventTicket
                    - order
              additionalProperties: false
            refund:
              deprecated: true
              description: Deprecated.
              type: object
              properties:
                amount:
                  type: number
                  description: Refunded amount.
                createDate:
                  type: string
                  format: date-time
                  description: Refund creation timestamp.
              required:
                - amount
                - createDate
              additionalProperties: false
            status:
              type: string
              description: Transaction status.
            ticket:
              deprecated: true
              description: Deprecated. Use product instead.
              type: object
              properties:
                createDate:
                  description: Ticket creation timestamp.
                  type: string
                  format: date-time
                event:
                  description: Event details.
                  type: object
                  properties:
                    endDate:
                      description: Event end date.
                      type: string
                      format: date-time
                    id:
                      type: string
                      format: uuid
                      description: Event id.
                    startDate:
                      description: Event start date.
                      type: string
                      format: date-time
                    title:
                      type: string
                      description: Event title.
                  required:
                    - id
                    - title
                  additionalProperties: false
                id:
                  type: string
                  format: uuid
                  description: Ticket id.
                quantity:
                  type: number
                  description: Number of tickets.
              required:
                - id
                - quantity
              additionalProperties: false
            type:
              type: string
              enum:
                - adminAllocation
                - adminCharge
                - booking
                - eventTicket
                - expiration
                - order
                - purchaseAllocation
                - refund
                - subscriptionAllocation
                - subscriptionExpiration
              description: Credits transaction type.
            userCreatedBy:
              description: User who created the transaction.
              type: object
              properties:
                about:
                  nullable: true
                  type: string
                email:
                  nullable: true
                  type: string
                id:
                  type: string
                  format: uuid
                name:
                  nullable: true
                  type: string
                phoneNumber:
                  nullable: true
                  type: string
                photoUrl:
                  nullable: true
                  type: string
                surname:
                  nullable: true
                  type: string
              required:
                - id
              additionalProperties: false
            userCreator:
              deprecated: true
              description: Deprecated. Use userCreatedBy instead.
              type: object
              properties:
                about:
                  nullable: true
                  type: string
                email:
                  nullable: true
                  type: string
                id:
                  type: string
                  format: uuid
                name:
                  nullable: true
                  type: string
                phoneNumber:
                  nullable: true
                  type: string
                photoUrl:
                  nullable: true
                  type: string
                surname:
                  nullable: true
                  type: string
              required:
                - id
              additionalProperties: false
            userOwner:
              deprecated: true
              description: Deprecated. Use customer.user instead.
              type: object
              properties:
                about:
                  nullable: true
                  type: string
                email:
                  nullable: true
                  type: string
                id:
                  type: string
                  format: uuid
                name:
                  nullable: true
                  type: string
                phoneNumber:
                  nullable: true
                  type: string
                photoUrl:
                  nullable: true
                  type: string
                surname:
                  nullable: true
                  type: string
              required:
                - id
              additionalProperties: false
            userRefCreator:
              deprecated: true
              description: Deprecated. Use userCreatedBy instead.
              type: string
              format: uuid
            userRefOwner:
              deprecated: true
              description: Deprecated. Use customer.user instead.
              type: string
              format: uuid
          required:
            - amount
            - amounts
            - createDate
            - customer
            - id
            - locationRef
            - networkRef
            - status
            - type
          additionalProperties: false
          description: The created credits transaction.
      required:
        - transaction
      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/developer/api/authentication#basic-authentication)
        for how to authorize your requests
      scheme: basic
    OAuth2:
      type: oauth2
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/developer/api/authentication#oauth2)
        for how to authorize your requests
      flows:
        authorizationCode:
          authorizationUrl: https://oauth2.spacebring.com/api/oauth2/authorize
          tokenUrl: https://oauth2.spacebring.com/api/oauth2/token
          refreshUrl: https://oauth2.spacebring.com/api/oauth2/token
          scopes:
            benefits.readonly: Read benefits and applications
            benefits: Read and write benefits and applications
            campaigns.readonly: Read campaigns
            campaigns: Read and write campaigns
            checkIns.readonly: Read check-ins
            checkIns: Read and write check-ins
            community.readonly: Read community companies and memberships
            community: Read and write community companies and memberships
            deliveries.readonly: Read deliveries
            deliveries: Read and write deliveries
            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

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.