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

# Add Feature to Subscription

> Add a feature to a subscription. For toggle features, this is idempotent. For usage credit features, amounts accumulate. Optionally grant credits immediately for the current billing period.



## OpenAPI

````yaml https://app.flowglad.com/api/openapi post /api/v1/subscriptions/{id}/add-feature
openapi: 3.1.0
info:
  title: Flowglad API
  version: 0.0.1
servers:
  - url: https://app.flowglad.com
security: []
externalDocs:
  url: https://docs.flowglad.com
paths:
  /api/v1/subscriptions/{id}/add-feature:
    post:
      tags:
        - Subscriptions
      summary: Add Feature to Subscription
      description: >-
        Add a feature to a subscription. For toggle features, this is
        idempotent. For usage credit features, amounts accumulate. Optionally
        grant credits immediately for the current billing period.
      operationId: subscriptions-addFeatureToSubscription
      parameters:
        - in: path
          name: id
          schema:
            description: The subscription ID
            type: string
          required: true
          description: The subscription ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                featureId:
                  description: >-
                    The feature ID to add. Exactly one of featureId or
                    featureSlug must be provided.
                  type: string
                featureSlug:
                  description: >-
                    The feature slug to add. The feature will be resolved from
                    the subscription pricing model. Exactly one of featureId or
                    featureSlug must be provided.
                  type: string
                grantCreditsImmediately:
                  description: >-
                    If true and the feature is a usage credit grant, credits
                    will be granted immediately for the current billing period
                  default: false
                  type: boolean
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddFeatureToSubscriptionOutput'
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '401':
          description: Authorization not provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.UNAUTHORIZED'
        '403':
          description: Insufficient access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.FORBIDDEN'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AddFeatureToSubscriptionOutput:
      type: object
      properties:
        subscriptionItemFeature:
          $ref: '#/components/schemas/SubscriptionItemFeaturesClientSelectSchema'
      required:
        - subscriptionItemFeature
      additionalProperties: false
    error.BAD_REQUEST:
      title: Invalid input data error (400)
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Invalid input data
          type: string
        code:
          description: The error code
          example: BAD_REQUEST
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    error.UNAUTHORIZED:
      title: Authorization not provided error (401)
      description: The error information
      example:
        code: UNAUTHORIZED
        message: Authorization not provided
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Authorization not provided
          type: string
        code:
          description: The error code
          example: UNAUTHORIZED
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    error.FORBIDDEN:
      title: Insufficient access error (403)
      description: The error information
      example:
        code: FORBIDDEN
        message: Insufficient access
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Insufficient access
          type: string
        code:
          description: The error code
          example: FORBIDDEN
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    error.INTERNAL_SERVER_ERROR:
      title: Internal server error error (500)
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Internal server error
          type: string
        code:
          description: The error code
          example: INTERNAL_SERVER_ERROR
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    SubscriptionItemFeaturesClientSelectSchema:
      oneOf:
        - $ref: '#/components/schemas/ToggleSubscriptionItemFeatureRecord'
        - $ref: '#/components/schemas/UsageCreditGrantSubscriptionItemFeatureRecord'
        - $ref: '#/components/schemas/ResourceSubscriptionItemFeatureRecord'
      type: object
      discriminator:
        propertyName: type
        mapping:
          toggle:
            $ref: '#/components/schemas/ToggleSubscriptionItemFeatureRecord'
          usage_credit_grant:
            $ref: '#/components/schemas/UsageCreditGrantSubscriptionItemFeatureRecord'
          resource:
            $ref: '#/components/schemas/ResourceSubscriptionItemFeatureRecord'
    ToggleSubscriptionItemFeatureRecord:
      type: object
      properties:
        id:
          type: string
        createdAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        updatedAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        livemode:
          type: boolean
        subscriptionItemId:
          type: string
        featureId:
          type: string
        productFeatureId:
          anyOf:
            - type: string
            - type: 'null'
        type:
          type: string
          const: toggle
        amount:
          type: 'null'
          const: null
        usageMeterId:
          type: 'null'
          const: null
        renewalFrequency:
          type: 'null'
          const: null
        expiredAt:
          anyOf:
            - description: Epoch milliseconds.
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        detachedAt:
          anyOf:
            - description: Epoch milliseconds.
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        detachedReason:
          anyOf:
            - type: string
            - type: 'null'
        manuallyCreated:
          type: boolean
        pricingModelId:
          type: string
        resourceId:
          type: 'null'
          const: null
        name:
          type: string
        slug:
          type: string
      required:
        - id
        - createdAt
        - updatedAt
        - livemode
        - subscriptionItemId
        - featureId
        - type
        - manuallyCreated
        - pricingModelId
        - name
        - slug
      additionalProperties: false
    UsageCreditGrantSubscriptionItemFeatureRecord:
      type: object
      properties:
        id:
          type: string
        createdAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        updatedAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        livemode:
          type: boolean
        subscriptionItemId:
          type: string
        featureId:
          type: string
        productFeatureId:
          anyOf:
            - type: string
            - type: 'null'
        type:
          type: string
          const: usage_credit_grant
        amount:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        usageMeterId:
          type: string
        renewalFrequency:
          type: string
          enum:
            - once
            - every_billing_period
        expiredAt:
          anyOf:
            - description: Epoch milliseconds.
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        detachedAt:
          anyOf:
            - description: Epoch milliseconds.
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        detachedReason:
          anyOf:
            - type: string
            - type: 'null'
        manuallyCreated:
          type: boolean
        pricingModelId:
          type: string
        resourceId:
          type: 'null'
          const: null
        name:
          type: string
        slug:
          type: string
      required:
        - id
        - createdAt
        - updatedAt
        - livemode
        - subscriptionItemId
        - featureId
        - type
        - amount
        - usageMeterId
        - renewalFrequency
        - manuallyCreated
        - pricingModelId
        - name
        - slug
      additionalProperties: false
    ResourceSubscriptionItemFeatureRecord:
      type: object
      properties:
        id:
          type: string
        createdAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        updatedAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        livemode:
          type: boolean
        subscriptionItemId:
          type: string
        featureId:
          type: string
        productFeatureId:
          anyOf:
            - type: string
            - type: 'null'
        type:
          type: string
          const: resource
        amount:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        usageMeterId:
          type: 'null'
          const: null
        renewalFrequency:
          type: 'null'
          const: null
        expiredAt:
          anyOf:
            - description: Epoch milliseconds.
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        detachedAt:
          anyOf:
            - description: Epoch milliseconds.
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        detachedReason:
          anyOf:
            - type: string
            - type: 'null'
        manuallyCreated:
          type: boolean
        pricingModelId:
          type: string
        resourceId:
          type: string
        name:
          type: string
        slug:
          type: string
      required:
        - id
        - createdAt
        - updatedAt
        - livemode
        - subscriptionItemId
        - featureId
        - type
        - amount
        - manuallyCreated
        - pricingModelId
        - resourceId
        - name
        - slug
      additionalProperties: false
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````