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

# Create Credit

> Create a credit with given parameters



## OpenAPI

````yaml https://api.getmeasure.com/api/v1/docs/api_spec.json post /companies/{company_id}/credits
openapi: 3.1.0
info:
  title: Measure API
  description: APIs to communicate with Measure
  version: 1.0.0
servers:
  - url: https://api.getmeasure.com/api/v1
security: []
paths:
  /companies/{company_id}/credits:
    post:
      tags:
        - Credits
      summary: Create Credit
      description: Create a credit with given parameters
      operationId: Create_Credit
      parameters:
        - name: company_id
          in: path
          description: 'The company ID with the prefix ''cmp_''. '
          required: true
          schema:
            description: 'The company ID with the prefix ''cmp_''. '
            type: string
        - name: Idempotency-Key
          in: header
          description: >-
            The idempotency key that will be used to ensure the request is only
            performed once
          schema:
            description: >-
              The idempotency key that will be used to ensure the request is
              only performed once
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestCreateCreditRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseCreditRepresentation'
      deprecated: false
      security:
        - apiKey:
            - ''
components:
  schemas:
    RequestCreateCreditRequest:
      properties:
        amount:
          $ref: '#/components/schemas/ModelAmount'
          description: The amount of the credit, if the type of credit is AMOUNT
        apply_to_open_invoices:
          $ref: '#/components/schemas/RequestApplyToOpenInvoicesParams'
        customer_id:
          description: The customer ID for the customer to whom the credit will be attached
          type: string
        expiration_date:
          description: The expiration date for the credit in RFC-3339 format
          format: date-time
          type:
            - 'null'
            - string
        item_id:
          description: The billable item ID for the type of unit credits
          type:
            - 'null'
            - string
        name:
          description: The name of the credit. This will show up in invoices
          type: string
        product_ids:
          description: >-
            Product IDs to restrict this credit to. If empty, credit applies to
            all products
          items:
            type: string
          type:
            - array
            - 'null'
        state:
          description: >-
            The state of the credit that can be one of ACTIVE, REVOKED, EXPIRED
            or CONSUMED
          enum:
            - ACTIVE
            - REVOKED
            - EXPIRED
            - CONSUMED
          type: string
        subscription_id:
          description: The specific subscription ID to which the credit is attached
          type:
            - 'null'
            - string
        type:
          description: The type of the credit that can be one of AMOUNT or UNITS
          enum:
            - AMOUNT
            - UNITS
          type: string
        units:
          description: The number of units of the credit, if the type of credit UNITS
          format: double
          type: number
      required:
        - name
        - type
        - customer_id
        - state
      type: object
    ResponseCreditRepresentation:
      properties:
        amount:
          $ref: '#/components/schemas/ModelAmount'
        coupon_id:
          type:
            - 'null'
            - string
        created_at:
          format: date-time
          type: string
        customer_id:
          type: string
        expiration_date:
          format: date-time
          type:
            - 'null'
            - string
        id:
          type: string
        import_created_at_ref:
          format: date-time
          type:
            - 'null'
            - string
        import_ref:
          type:
            - 'null'
            - string
        imported_from:
          type:
            - 'null'
            - string
        issued_amount:
          $ref: '#/components/schemas/ModelAmount'
        issued_units:
          format: double
          type: number
        item:
          $ref: '#/components/schemas/ResponseBillableItemRepresentation'
        item_id:
          type:
            - 'null'
            - string
        metric_record_id:
          type:
            - 'null'
            - string
        name:
          type: string
        one_time_billable_id:
          type:
            - 'null'
            - string
        proration_date:
          format: date-time
          type:
            - 'null'
            - string
        state:
          type: string
        subscription_id:
          type:
            - 'null'
            - string
        type:
          type: string
        units:
          format: double
          type: number
      type: object
    ModelAmount:
      description: The amount which has value in cents and a currency
      properties:
        currency:
          type: string
        value_in_cents:
          format: int64
          type: integer
      type: object
    RequestApplyToOpenInvoicesParams:
      properties:
        enable:
          type: boolean
        invoice_uuids:
          items:
            type: string
          type: array
      required:
        - enable
      type: object
    ResponseBillableItemRepresentation:
      properties:
        company_id:
          description: The company ID for the billable item
          type: string
        created_at:
          description: The date the billable item was created
          format: date-time
          type: string
        description:
          description: Any description attached to the billable item
          type: string
        display_type:
          description: >-
            The display type of the billable item which can be one of UNITS,
            AMOUNT, THOUSAND_UNITS, MILLION_UNITS
          type: string
        editable:
          description: Whether the billable item can be further edited
          type: boolean
        external_name:
          description: The public name of the billable item
          type: string
        id:
          description: The ID of the billable item in Measure
          type: string
        name:
          description: The name of the billable item
          type: string
        standard:
          description: >-
            Whether this is a standard billable item in Measure or a custom
            billable item
          type: boolean
        type:
          description: >-
            The type of the billable item which can be one of CUSTOM_USAGE or
            CUSTOM_OBJ, based on usage-based item or object-based item
          type: string
        updated_at:
          description: The date the billable item was last updated
          format: date-time
          type: string
      type: object
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````