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

# Create a subscription grant

> 
Grants extra pre-committed units of one or more usage bricks on a live
subscription, at a price you set: a usage top-up. Grants never create an
order, never renew and never change the contracted price or the renewal
quantity.

## Billing
- One invoice is raised on the subscription today, with one one-time line per
  brick, and is listed by `GET /subscriptions/{subscription_id}/invoices`.
- A 0-cent grant gets a 0-cent invoice that is paid at once.
- With `charge_immediately`, the billed company's default card is charged now.
  If the invoice cannot be calculated at once, the grant is created PENDING
  and the invoice is charged when it is calculated. A buyer who turned
  auto-pay off is emailed the invoice instead, like any other invoice.

## Cover
Once active, the units cover usage that would otherwise be billed as overage,
committed units first, then grants, soonest expiry first. They carry into
renewals of the subscription until `expires_at`, and unused units lapse then.

## Duplicate requests
This endpoint has no idempotency key: each successful call creates and bills a
new grant. Clients must guard against sending the same grant twice, for
example after a timeout, by listing the subscription's grants before retrying.

## Errors
- 400 when the request can't be met. Nothing is created.
- 402 when `charge_immediately` was set and the charge was declined or needs
  the buyer to authenticate. The grant and its unpaid invoice are kept;
  `details` carries their ids.




## OpenAPI

````yaml https://api.salesbricks.com/api/v2/openapi.yaml post /subscriptions/{subscription_id}/grants
openapi: 3.0.3
info:
  title: Salesbricks REST API
  version: 2.0.0
  description: API reference for external integrations
servers:
  - url: https://api.salesbricks.com/api/v2
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Subscriptions
    description: >-
      Operations related to subscription management, including creation,
      updates, and retrieving subscription details. Subscriptions can be
      upgraded to add / remove add-ons by using the POST
      /subscriptions/{subscription_id}/upgrade endpoint and can be recasted for
      replacing the current agreement using the POST
      /subscriptions/{subscription_id}/recast endpoint
  - name: Subscription Milestones
    description: >-
      Operations for listing and completing milestone bricks — bricks billed
      when the work they cover is delivered rather than on the subscription's
      schedule. Completing one either raises a standalone invoice immediately or
      bills on the subscription's next scheduled invoice.
  - name: Customers
    description: >-
      Operations related to customer management, including creation, updates,
      and managing customer person objects.
  - name: Invoices
    description: Operations related to subscription's invoicing details.
  - name: Plans
    description: >-
      Operations related to listing and getting plan details including bricks in
      the plan.
  - name: Payment Methods
    description: Operations related to subscription's payment method.
paths:
  /subscriptions/{subscription_id}/grants:
    post:
      tags:
        - Subscription Grants
      summary: Create a subscription grant
      description: >

        Grants extra pre-committed units of one or more usage bricks on a live

        subscription, at a price you set: a usage top-up. Grants never create an

        order, never renew and never change the contracted price or the renewal

        quantity.


        ## Billing

        - One invoice is raised on the subscription today, with one one-time
        line per
          brick, and is listed by `GET /subscriptions/{subscription_id}/invoices`.
        - A 0-cent grant gets a 0-cent invoice that is paid at once.

        - With `charge_immediately`, the billed company's default card is
        charged now.
          If the invoice cannot be calculated at once, the grant is created PENDING
          and the invoice is charged when it is calculated. A buyer who turned
          auto-pay off is emailed the invoice instead, like any other invoice.

        ## Cover

        Once active, the units cover usage that would otherwise be billed as
        overage,

        committed units first, then grants, soonest expiry first. They carry
        into

        renewals of the subscription until `expires_at`, and unused units lapse
        then.


        ## Duplicate requests

        This endpoint has no idempotency key: each successful call creates and
        bills a

        new grant. Clients must guard against sending the same grant twice, for

        example after a timeout, by listing the subscription's grants before
        retrying.


        ## Errors

        - 400 when the request can't be met. Nothing is created.

        - 402 when `charge_immediately` was set and the charge was declined or
        needs
          the buyer to authenticate. The grant and its unpaid invoice are kept;
          `details` carries their ids.
      operationId: createSubscriptionGrant
      parameters:
        - in: path
          name: subscription_id
          schema:
            type: string
            pattern: ^([a-zA-Z\d\-]+)$
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GrantCreateInput'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/GrantCreateInput'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/GrantCreateInput'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Grant'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                BadRequestResponse:
                  value:
                    error:
                      code: ERR_BAD_REQUEST
                      message: >-
                        Brick Storage Hot is in the usage pool Storage GB. Top
                        up Storage GB instead.
                  summary: Bad Request Response
          description: ''
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GrantPaymentFailedResponse'
              examples:
                PaymentFailedResponse:
                  value:
                    error:
                      code: ERR_PAYMENT_FAILED
                      message: Your card was declined.
                      details:
                        grant_id: 0b9f7a0e-4c1e-4f55-9a43-3f6f1f7f1c11
                        invoice_id: 5d2c8c1a-77a4-4c39-9f5e-2f0c5b1e6a42
                  summary: Payment Failed Response
          description: ''
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                NotFoundResponse:
                  value:
                    error:
                      code: ERR_NOT_FOUND
                      message: >-
                        Subscription not found — no subscription matches the
                        given `subscription_id`.
                  summary: Not Found Response
          description: ''
components:
  schemas:
    GrantCreateInput:
      type: object
      description: Input serializer for creating a grant.
      properties:
        lines:
          type: array
          items:
            $ref: '#/components/schemas/GrantLineInput'
          description: One line per brick. A brick may appear only once.
        activates:
          enum:
            - ON_PAYMENT
            - ON_ISSUE
          type: string
          x-spec-enum-id: 039ee25b13d3a027
          description: >-
            When the units start to cover overage: `ON_ISSUE` when the invoice
            is issued, `ON_PAYMENT` when it is paid with settled money. Once
            active, a grant stays active: a refund does not undo it.


            * `ON_PAYMENT` - On payment

            * `ON_ISSUE` - On issue
        expires_at:
          type: string
          format: date
          description: >-
            The last day the units cover usage. A date (YYYY-MM-DD) in the
            subscription's time zone. Can't be before `effective_at`; the same
            day covers the usage period that ends that day.
        effective_at:
          type: string
          format: date
          description: >-
            The first day the units cover usage. They cover every usage period
            that ends on or after it, so a grant added mid-period covers the
            whole period. A date (YYYY-MM-DD) in the subscription's time zone.
            Defaults to today; can't be before today, or after the last day of
            the subscription's last usage period.
        charge_immediately:
          type: boolean
          default: false
          description: >-
            Charge the billed company's default card now. Requires an enabled
            Stripe integration and a default card, checked before anything is
            created. A declined charge, or one that needs the buyer to
            authenticate, answers 402 and keeps the grant and its unpaid
            invoice: pay it with `POST /invoices/{invoice_id}/pay` or void the
            grant.
      required:
        - activates
        - expires_at
        - lines
    Grant:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ID of the grant.
        grant_type:
          enum:
            - TOP_UP
            - ROLLOVER
          type: string
          x-spec-enum-id: e5380c0e8c5d3e7a
          description: >-
            What granted the units. `TOP_UP`: units sold on their own invoice.
            `ROLLOVER`: unused committed units rolled over when a commitment
            period ended, not charged for. More types will be added, so treat an
            unknown value as a grant you can read but not act on.


            * `TOP_UP` - Top-up

            * `ROLLOVER` - Rollover
        subscription_id:
          type: string
          format: uuid
          description: The subscription the grant is on.
        status:
          enum:
            - PENDING
            - ACTIVE
            - EXPIRED
            - VOIDED
          type: string
          x-spec-enum-id: c82743c7c6d79bf1
          description: >-
            `VOIDED` when it or its invoice is voided; else `EXPIRED` when it is
            active and every line has expired; else `ACTIVE` once its units
            cover usage; else `PENDING`.


            * `PENDING` - Pending

            * `ACTIVE` - Active

            * `EXPIRED` - Expired

            * `VOIDED` - Voided
        activates:
          enum:
            - ON_PAYMENT
            - ON_ISSUE
          type: string
          x-spec-enum-id: 039ee25b13d3a027
          nullable: true
          description: >-
            When the units start to cover overage. Null for a `ROLLOVER`, which
            covers overage as it is created.


            * `ON_PAYMENT` - On payment

            * `ON_ISSUE` - On issue
        effective_at:
          type: string
          format: date
          description: >-
            The first day the units cover usage. A date (YYYY-MM-DD) in the
            subscription's time zone.
        activated_at:
          type: string
          format: date-time
          nullable: true
          description: When the grant became active.
        voided_at:
          type: string
          format: date-time
          nullable: true
          description: When it or its invoice was voided. Null unless `status` is `VOIDED`.
        created_at:
          type: string
          format: date-time
          description: When the grant was created.
        invoice:
          allOf:
            - $ref: '#/components/schemas/GrantInvoice'
          nullable: true
          description: The invoice that bills the grant. Null for a `ROLLOVER`.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/GrantLine'
          description: One line per brick.
      required:
        - activated_at
        - activates
        - created_at
        - effective_at
        - grant_type
        - id
        - invoice
        - lines
        - status
        - subscription_id
        - voided_at
    ErrorResponse:
      type: object
      description: >-
        Standardizes API error responses with a consistent structure containing
        error code and message.
      properties:
        error:
          allOf:
            - $ref: '#/components/schemas/Error'
          description: The error that caused the request to fail
      required:
        - error
    GrantPaymentFailedResponse:
      type: object
      properties:
        error:
          allOf:
            - $ref: '#/components/schemas/GrantPaymentFailedError'
          description: The charge that failed when `charge_immediately` was set
      required:
        - error
    GrantLineInput:
      type: object
      properties:
        brick_id:
          type: string
          format: uuid
          description: >-
            The pre-commitment brick to add units to. For a usage pool, the pool
            brick, not one of its members.
        quantity:
          type: string
          format: decimal
          pattern: ^-?\d{0,14}(?:\.\d{0,6})?$
          description: Units to add, in the brick's own units. Must be more than 0.
        unit_price:
          type: string
          format: decimal
          pattern: ^-?\d{0,14}(?:\.\d{0,6})?$
          description: >-
            Price per unit in cents, with up to 6 decimal places. 0 for free
            units. The line amount is quantity × unit_price, rounded half-even
            to whole cents. No discount applies.
      required:
        - brick_id
        - quantity
        - unit_price
    GrantInvoice:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ID of the grant's invoice.
        number:
          type: string
          description: The invoice number.
        status:
          type: string
          description: The invoice status.
        grand_total:
          type: integer
          nullable: true
          description: Total due in cents. Null until the invoice is calculated.
        currency:
          type: string
          description: The invoice currency.
        payment_url:
          type: string
          format: uri
          nullable: true
          description: >-
            Link to the page where your customer pays this invoice online. Null
            when you have no Stripe account that can take payments connected, or
            the invoice has not been issued.
      required:
        - currency
        - grand_total
        - id
        - number
        - payment_url
        - status
    GrantLine:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ID of the line.
        brick_id:
          type: string
          format: uuid
          description: The brick the units are for.
        brick_name:
          type: string
          description: Name of the brick.
        quantity:
          type: number
          format: double
          maximum: 100000000000000
          minimum: -100000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          description: Units granted.
        unit_price:
          type: string
          format: decimal
          pattern: ^-?\d{0,14}(?:\.\d{0,6})?$
          description: >-
            Price per unit in cents, as a decimal string with 6 decimal places
            (e.g. "4.000000"), as usage tier prices are.
        expires_at:
          type: string
          format: date
          description: >-
            The last day the units cover usage. A date (YYYY-MM-DD) in the
            subscription's time zone.
        used:
          type: number
          format: double
          maximum: 100000000000000
          minimum: -100000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          description: >-
            Units used on issued usage invoices. Overage covered in the open
            period, whose invoice is not issued yet, is not counted.
        remaining:
          type: number
          format: double
          maximum: 100000000000000
          minimum: -100000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          description: quantity − used. 0 once the grant is voided.
      required:
        - brick_id
        - brick_name
        - expires_at
        - id
        - quantity
        - remaining
        - unit_price
        - used
    Error:
      type: object
      description: >-
        Represents individual error details with a standardized code and
        descriptive message.
      properties:
        code:
          enum:
            - ERR_NOT_FOUND
            - ERR_BAD_REQUEST
            - ERR_SERVER_ERROR
          type: string
          x-spec-enum-id: dc5a5d6feae1b697
          description: >-
            Error code indicating the type of error: NOT_FOUND for missing
            resources, BAD_REQUEST for invalid input, SERVER_ERROR for internal
            server issues


            * `ERR_NOT_FOUND` - ERR_NOT_FOUND

            * `ERR_BAD_REQUEST` - ERR_BAD_REQUEST

            * `ERR_SERVER_ERROR` - ERR_SERVER_ERROR
        message:
          type: string
          description: Human-readable explanation of the error
        error_id:
          type: string
          format: uuid
          description: >-
            Correlation handle for SERVER_ERROR responses — quote this when
            contacting support; it joins to the structured server log line for
            the failure. Not present on 4xx responses.
        details:
          description: >-
            Optional detail on what was wrong with the request; its shape
            depends on the endpoint. Validation errors send either a list of
            "field: message" strings or an object keyed by field name, nested
            under `fields` or at the top level.
      required:
        - code
        - message
    GrantPaymentFailedError:
      type: object
      properties:
        code:
          enum:
            - ERR_PAYMENT_FAILED
          type: string
          x-spec-enum-id: 0efe35c50e4f23d0
          description: |-
            The charge was declined or needs the buyer to authenticate.

            * `ERR_PAYMENT_FAILED` - ERR_PAYMENT_FAILED
        message:
          type: string
          description: Human-readable explanation of the error
        details:
          allOf:
            - $ref: '#/components/schemas/GrantPaymentFailedDetails'
          description: >-
            The kept grant and its unpaid invoice: pay the invoice, or void the
            grant.
      required:
        - code
        - details
        - message
    GrantPaymentFailedDetails:
      type: object
      properties:
        grant_id:
          type: string
          format: uuid
          description: The grant, kept PENDING until its invoice is paid.
        invoice_id:
          type: string
          format: uuid
          description: The grant's unpaid invoice.
      required:
        - grant_id
        - invoice_id
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-SALESBRICKS-KEY
      description: API key for authentication

````

## Related topics

- [Create a subscription](https://docs.salesbricks.com/api-reference/subscriptions/create-a-subscription.md)
- [Retrieve a subscription grant](https://docs.salesbricks.com/api-reference/subscription-grants/retrieve-a-subscription-grant.md)
- [Void a subscription grant](https://docs.salesbricks.com/api-reference/subscription-grants/void-a-subscription-grant.md)


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