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

# Create a Store Credit

> Creates a Store Credit



## OpenAPI

````yaml /api-reference/platform.yaml post /api/v2/platform/store_credits
openapi: 3.0.3
info:
  title: Platform API
  contact:
    name: Vendo Connect Inc.
    url: https://getvendo.com
    email: sales@getvendo.com
  description: Spree Platform API
  version: v2
servers:
  - url: http://{defaultHost}
    variables:
      defaultHost:
        default: localhost:3000
security: []
tags:
  - name: Addresses
  - name: Adjustments
  - name: Classifications
  - name: Countries
  - name: CMS Pages
  - name: CMS Sections
  - name: Digital Assets
  - name: Digital Links
  - name: Line Items
  - name: Menus
  - name: Menu Items
  - name: Option Types
  - name: Option Values
  - name: Orders
  - name: Payments
  - name: Payment Methods
  - name: Products
  - name: Promotions
  - name: Promotion Actions
  - name: Promotion Categories
  - name: Promotion Rules
  - name: Roles
  - name: Shipments
  - name: Shipping Categories
  - name: Shipping Methods
  - name: States
  - name: Stock Items
  - name: Stock Locations
  - name: Store Credit Categories
  - name: Store Credit Types
  - name: Store Credits
  - name: Tax Categories
  - name: Tax Rates
  - name: Taxons
  - name: Taxonomies
  - name: Users
  - name: Variants
  - name: Vendors
  - name: Webhook Events
  - name: Webhook Subscribers
  - name: Wishlists
  - name: Wished Items
  - name: Zones
paths:
  /api/v2/platform/store_credits:
    post:
      tags:
        - Store Credits
      summary: Create a Store Credit
      description: Creates a Store Credit
      operationId: create-store-credit
      parameters:
        - name: include
          in: query
          description: >-
            Select which associated resources you would like to fetch, see: <a
            href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>
          example: user,created_by,category,credit_type
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_store_credit_params'
      responses:
        '201':
          description: Record created
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    data:
                      id: '6'
                      type: store_credit
                      attributes:
                        amount: '150.0'
                        amount_used: '0.0'
                        memo: null
                        deleted_at: null
                        currency: USD
                        amount_authorized: '0.0'
                        originator_type: null
                        created_at: '2022-11-08T19:35:39.272Z'
                        updated_at: '2022-11-08T19:35:39.272Z'
                        public_metadata: {}
                        private_metadata: {}
                        display_amount: $150.00
                        display_amount_used: $0.00
                      relationships:
                        user:
                          data:
                            id: '113'
                            type: user
                        created_by:
                          data:
                            id: '114'
                            type: user
                        store_credit_category:
                          data:
                            id: '18'
                            type: store_credit_category
                        store_credit_type:
                          data:
                            id: '18'
                            type: store_credit_type
                        store_credit_events:
                          data:
                            - id: '7'
                              type: store_credit_event
              schema:
                $ref: '#/components/schemas/resource'
        '422':
          description: Invalid request
          content:
            application/vnd.api+json:
              examples:
                Example:
                  value:
                    error: >-
                      User can't be blank, Category can't be blank, Created by
                      can't be blank, Currency can't be blank, Amount must be
                      greater than 0, Amount used Cannot be greater than
                      amount., and Amount authorized Exceeds total credits.
                    errors:
                      user:
                        - can't be blank
                      category:
                        - can't be blank
                      created_by:
                        - can't be blank
                      currency:
                        - can't be blank
                      amount:
                        - must be greater than 0
                      amount_used:
                        - Cannot be greater than amount.
                      amount_authorized:
                        - Exceeds total credits.
              schema:
                $ref: '#/components/schemas/validation_errors'
      security:
        - bearer_auth: []
components:
  schemas:
    create_store_credit_params:
      type: object
      properties:
        store_credit:
          type: object
          required:
            - user_id
            - category_id
            - type_id
            - created_by_id
            - currency
            - store_id
            - amount
          properties:
            user_id:
              type: string
              example: '2'
            category_id:
              type: string
              example: '4'
            created_by_id:
              type: string
              example: '5'
            amount:
              type: number
              example: 25
            amount_used:
              type: number
              example: 10
            memo:
              type: string
              example: This credit was given as a refund
            currency:
              type: string
              example: USD
            amount_authorized:
              type: number
              example: 15.5
            originator_id:
              type: string
              example: '3'
            originator_type:
              type: string
              example: Refund
            type_id:
              type: string
              example: '1'
            store_id:
              type: string
              example: '2'
            public_metadata:
              type: object
            private_metadata:
              type: object
      required:
        - store_credit
      x-internal: false
    resource:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/resource_properties'
      required:
        - data
      x-internal: false
    validation_errors:
      type: object
      properties:
        error:
          type: string
        errors:
          type: object
      required:
        - error
        - errors
      x-internal: false
    resource_properties:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
        attributes:
          type: object
        relationships:
          type: object
      required:
        - id
        - type
        - attributes
      x-internal: false
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer

````