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

# Create User Memory

> Create a user memory. This endpoint requires credits and meters the actual embedding work performed for the request. The response includes `credits.consumed` with the billed amount, or `null` if the billing write fails after the memory is successfully created.



## OpenAPI

````yaml post /user-memories
openapi: 3.0.3
info:
  version: 0.1.1
  title: Datagrid API
  description: Datagrid API
servers:
  - url: https://api.datagrid.com/v1
security:
  - BearerAuth: []
paths:
  /user-memories:
    post:
      tags:
        - Memory
      summary: Create User Memory
      description: >-
        Create a user memory. This endpoint requires credits and meters the
        actual embedding work performed for the request. The response includes
        `credits.consumed` with the billed amount, or `null` if the billing
        write fails after the memory is successfully created.
      operationId: Memory.createUserMemory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserMemoryRequest'
      responses:
        '201':
          description: Successfully created user memory
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateUserMemoryResponse'
          headers:
            X-Daily-Credit-Cap-Remaining:
              $ref: '#/components/headers/DailyCreditCapRemaining'
            X-Monthly-Credit-Cap-Remaining:
              $ref: '#/components/headers/MonthlyCreditCapRemaining'
        '402':
          description: >-
            Credit limit exceeded. Either the organization does not have enough
            credits to perform this operation, or it has reached the monthly
            credit cap set in Control Tower. Check your billing status, or wait
            for the cap to reset.
          headers:
            X-Daily-Credit-Cap-Remaining:
              $ref: '#/components/headers/DailyCreditCapRemaining'
            X-Monthly-Credit-Cap-Remaining:
              $ref: '#/components/headers/MonthlyCreditCapRemaining'
        '429':
          description: >-
            Rate limit exceeded. The request has been throttled because the rate
            limit for this endpoint has been reached. Check the `Retry-After`
            response header and retry after the specified number of seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
components:
  schemas:
    CreateUserMemoryRequest:
      type: object
      required:
        - agent_id
        - memory
      properties:
        agent_id:
          type: string
          description: The agent ID of the user memory.
        user_prompt:
          type: string
          description: The user prompt of the user memory.
          nullable: true
        memory:
          type: string
          description: The memory of the user memory.
        context:
          type: string
          description: The context of the user memory.
          nullable: true
    CreateUserMemoryResponse:
      allOf:
        - $ref: '#/components/schemas/UserMemory'
        - type: object
          properties:
            credits:
              nullable: true
              description: >-
                Credit consumption for this user-memory creation. `consumed`
                reflects the billed embedding work for the request. `null` when
                the billing write fails after the memory is successfully
                created.
              allOf:
                - $ref: '#/components/schemas/OperationCredits'
    RateLimitError:
      type: object
      description: >-
        Returned when the rate limit is exceeded. Rate limits are enforced per
        teamspace, endpoint path, and HTTP method over a 60-second sliding
        window. Each endpoint may have its own limit — check the
        X-RateLimit-Limit response header for the effective value.
      required:
        - error
        - message
        - retryable
        - status_code
      properties:
        status_code:
          type: integer
          description: The HTTP status code (429).
        statusCode:
          type: integer
          deprecated: true
          description: Deprecated. Use status_code instead.
        error:
          type: string
          enum:
            - rate_limit_exceeded
          description: The error code identifying this as a rate limit error.
        message:
          type: string
          description: A human-readable error message.
        mitigation:
          type: string
          description: Suggested action to resolve the error.
        retryable:
          type: boolean
          description: Whether the request can be retried after a delay.
        details:
          type: object
          properties:
            reason:
              type: string
              description: A detailed explanation of why the rate limit was exceeded.
    UserMemory:
      type: object
      required:
        - id
        - object
        - updated_at
        - created_at
        - user_prompt
        - context
        - agent_id
        - user_id
        - memory
      properties:
        object:
          type: string
          enum:
            - user_memory
          description: The object type, which is always `user_memory`.
        id:
          type: string
          description: The ID of the user memory.
        updated_at:
          type: string
          description: The updated at of the user memory.
        created_at:
          type: string
          description: The created at of the user memory.
        user_prompt:
          type: string
          description: The user prompt of the user memory.
        context:
          type: array
          items:
            type: string
          description: The context of the user memory.
        agent_id:
          type: string
          description: The agent ID of the user memory.
        user_id:
          type: string
          description: The user ID of the user memory.
        memory:
          type: array
          items:
            type: string
          description: The memory of the user memory.
    OperationCredits:
      type: object
      required:
        - consumed
      properties:
        consumed:
          type: number
          description: The number of credits consumed by the operation.
  headers:
    DailyCreditCapRemaining:
      description: >-
        Credits left before the account's daily credit cap (set in Control
        Tower) is reached, rounded up. `0` means the cap has been reached; the
        daily cap does not block requests. Present only when a daily cap is
        configured.
      schema:
        type: integer
        example: 600
    MonthlyCreditCapRemaining:
      description: >-
        Credits left before the account's monthly credit cap (set in Control
        Tower) is reached, rounded up. At `0`, credit-consuming requests return
        `402` until the next calendar month. Present only when a monthly cap is
        configured.
      schema:
        type: integer
        example: 15000
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

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