> ## 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 usage entry

> Submits a usage entry for a subscription's metered brick. Each entry must have a unique `transaction_id` to prevent duplicates. The usage will be associated with the specified subscription and brick, and will be reflected in the next billing cycle.



## OpenAPI

````yaml https://api.salesbricks.com/api/v2/openapi.yaml post /usage/
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
  - url: https://api.staging.salesbricks.com/api/v2
    description: Staging
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: 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:
  /usage/:
    post:
      tags:
        - Usage
      summary: Create a usage entry
      description: >-
        Submits a usage entry for a subscription's metered brick. Each entry
        must have a unique `transaction_id` to prevent duplicates. The usage
        will be associated with the specified subscription and brick, and will
        be reflected in the next billing cycle.
      operationId: createUsageEntry
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UsageEntryPost'
            examples:
              CreateUsageEntryRequest:
                value:
                  transaction_id: tx-12345-abc
                  subscription_id: 550e8400-e29b-41d4-a716-446655440000
                  brick_id: 660e8400-e29b-41d4-a716-446655440001
                  value: 150
                  properties:
                    region: us-west-2
                    tier: premium
                  time: '2024-01-15T10:30:00Z'
                summary: Create Usage Entry Request
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/UsageEntryPost'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/UsageEntryPost'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageEntryPostResponse'
              examples:
                SuccessResponse:
                  value:
                    message: Usage entry submitted successfully.
                  summary: Success Response
                SuccessResponseWithDeprecationWarning:
                  value:
                    message: Usage entry submitted successfully.
                    warnings:
                      - field: count
                        message: >-
                          This field is deprecated and will be removed on
                          2025-06-01. Use 'value' instead.
                        removal_date: '2025-06-01'
                        docs: https://docs.salesbricks.com/api-reference/usage/post
                  summary: Success Response with Deprecation Warning
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                BadRequestResponse:
                  value:
                    error:
                      code: ERR_BAD_REQUEST
                      message: >-
                        Bad request — the input payload is malformed, missing
                        required fields, or contains invalid data.
                  summary: Bad Request Response
          description: ''
components:
  schemas:
    UsageEntryPost:
      type: object
      description: Request serializer for creating a usage entry.
      properties:
        transaction_id:
          type: string
          description: >-
            A unique identifier for this usage entry. Used to prevent duplicate
            entries and for later updates/deletes.
          maxLength: 255
        subscription_id:
          type: string
          format: uuid
          description: The ID of the subscription this usage entry belongs to.
        brick_id:
          type: string
          format: uuid
          description: The ID of the metered brick this usage is for.
        value:
          type: string
          format: decimal
          pattern: ^-?\d{0,14}(?:\.\d{0,6})?$
          description: The usage value to record (e.g., number of API calls, GB used).
        count:
          type: string
          format: decimal
          pattern: ^-?\d{0,14}(?:\.\d{0,6})?$
          description: 'Deprecated: Use ''value'' instead.'
        properties:
          nullable: true
          description: >-
            Optional JSON object with additional properties for this usage
            entry.
        time:
          type: string
          format: date-time
          description: The timestamp when this usage occurred (ISO 8601 format).
      required:
        - brick_id
        - subscription_id
        - time
        - transaction_id
        - value
    UsageEntryPostResponse:
      type: object
      properties:
        message:
          type: string
          description: Success message indicating the usage entry was submitted.
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/UsageWarning'
          description: Optional list of warnings, such as deprecation notices.
      required:
        - message
    ErrorResponse:
      type: object
      description: >-
        Standardizes API error responses with a consistent structure containing
        error code and message.
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
    UsageWarning:
      type: object
      properties:
        field:
          type: string
          description: The field that triggered the warning.
        message:
          type: string
          description: Description of the warning.
        removal_date:
          type: string
          description: Date when the deprecated feature will be removed.
        docs:
          type: string
          format: uri
          description: Link to documentation for more information.
      required:
        - docs
        - field
        - message
        - removal_date
    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
        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.
      required:
        - code
        - message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-SALESBRICKS-KEY
      description: API key for authentication

````

## Related topics

- [Submit a usage entry](/api-reference/usage/post.md)
- [Update a usage entry](/api-reference/usage/patch.md)
- [Delete a usage entry](/api-reference/usage/delete.md)
