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

# Create a usage module

> Create a metered-product setup. Both objects must already exist in this workspace. **Requires scope:** `usage:write`.



## OpenAPI

````yaml /openapi-v1.json post /v1/usage-modules
openapi: 3.1.0
info:
  title: Custral API
  version: v1
  description: >-
    The curated, versioned, API-key-authenticated public REST surface (`/v1`).
    Every endpoint here is what the official SDKs (`@custral/sdk`) and the MCP
    server are built on. Authenticate with a secret API key (`sk_…`) created in
    **Settings → Applications**.
  contact:
    name: Custral Support
    email: hello@custral.com
    url: https://custral.com
  license:
    name: Proprietary
    url: https://custral.com
servers:
  - url: https://api.custral.com
    description: Production
security:
  - ApiKey: []
tags:
  - name: Identity
    description: Introspect the calling API key.
  - name: Records
    description: Create, list, retrieve, and update records on any object.
  - name: Objects
    description: Read the object (table) schema of your workspace.
  - name: Conversations
    description: View, manage, and ingest conversations and their messages.
  - name: MCP
    description: Introspect the Model Context Protocol tool surface for a key.
  - name: Documents
    description: Read record notes / page documents as markdown.
paths:
  /v1/usage-modules:
    post:
      tags:
        - Usage modules
      summary: Create a usage module
      description: >-
        Create a metered-product setup. Both objects must already exist in this
        workspace. **Requires scope:** `usage:write`.
      operationId: createUsageModule
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUsageModuleBody'
      responses:
        '200':
          description: The created usage module.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/UsageModule'
                  reqId:
                    $ref: '#/components/schemas/RequestId'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    CreateUsageModuleBody:
      type: object
      required:
        - name
        - productObjectId
        - customerObjectId
      properties:
        name:
          type: string
          example: Compression
        productObjectId:
          type: string
          example: obj_3Ab9xK2mQ7
        customerObjectId:
          type: string
          example: obj_5Bc0xJ1kP4
        productIdentifierPropertyId:
          type: string
        customerIdentifierPropertyId:
          type: string
    UsageModule:
      type: object
      description: >-
        A metered-product setup: the object holding what you sell, joined to the
        object holding who consumes it.
      properties:
        id:
          type: string
          example: umod_3Ab9xK2mQ7
        name:
          type:
            - string
            - 'null'
          example: Compression
        productObjectId:
          type:
            - string
            - 'null'
          description: The object (`obj_…`) holding the things being sold.
          example: obj_3Ab9xK2mQ7
        customerObjectId:
          type:
            - string
            - 'null'
          description: The object (`obj_…`) holding the consumers.
          example: obj_5Bc0xJ1kP4
        productIdentifierPropertyId:
          type:
            - string
            - 'null'
          description: Optional property an external system identifies products by.
        customerIdentifierPropertyId:
          type:
            - string
            - 'null'
          description: Optional property an external system identifies customers by.
        createdAt:
          type:
            - string
            - 'null'
          format: date-time
    RequestId:
      type: string
      description: >-
        A per-request id (`req_…`). Quote it to support when reporting a
        problem.
      example: req_2a1f9c8e7b6d5
    Error:
      type: object
      description: >-
        The failure envelope. Every error carries a machine-readable `code` and
        the `reqId` of the failing request.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: insufficient_scope
          required:
            - code
        reqId:
          $ref: '#/components/schemas/RequestId'
      required:
        - error
  responses:
    Unauthorized:
      description: >-
        The API key is missing, unknown, inactive, or expired (`code:
        invalid_api_key`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_api_key
            reqId: req_2a1f9c8e7b6d5
    Forbidden:
      description: >-
        The key lacks the scope this endpoint requires (`code:
        insufficient_scope`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: insufficient_scope
            reqId: req_2a1f9c8e7b6d5
    NotFound:
      description: 'The object or record was not found (`code: not_found`).'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: not_found
            reqId: req_2a1f9c8e7b6d5
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: sk_...
      description: >-
        A Custral **secret** API key (`sk_…`), created in Settings →
        Applications. Sent as `Authorization: Bearer sk_…`. The `X-Api-Key:
        sk_…` header is also accepted and takes precedence. Never expose a
        secret key in a browser.

````

## Related topics

- [Usage tracking](/bi/reporting/usage.md)
- [Retrieve a usage module](/api-reference/usage-modules/retrieve-a-usage-module.md)
- [The Usage module object](/dev/api-reference/usage-modules.md)
- [List usage modules](/api-reference/usage-modules/list-usage-modules.md)
- [Usage](/data/properties/complex/usage.md)
