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

# Rebuild derived memories a delete left stale [Cloud-only]

> Regenerate the derived memories that deletes left stale.

A delete never spends LLM calls. Derived memories that only an LLM can regenerate (the user profile, session summaries, agent skills) are kept and marked stale instead: the delete response has `rebuild_required` and `targets`, and the profile has `stale`. This call starts one background job that regenerates them from the remaining memories. Nothing is regenerated until you call it, so batch your deletes first.

- Pass `user_id` (profile, session summaries) or `agent_id` (skills). `targets` narrows the rebuild; by default everything marked stale is rebuilt.
- `dry_run` reports what would be rebuilt (`estimated_episodes` sizes a profile rebuild) and spends nothing. `force` rebuilds the profile or skills even when nothing is marked; an owner with no profile yet has none to rebuild.
- One job per owner at a time: a second call returns the running job with `status: already_running`.
- The call is free; the extraction it runs is metered like any extraction, so it is refused with 429 once the account's usage quota is exhausted.

While a profile rebuild runs, the profile holds only its manually edited items plus what has been re-extracted so far, and `stale` stays `true` until the job finishes. Poll /api/v2/memory/rebuild/status with the returned `job_id`.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v2/memory/rebuild
openapi: 3.1.0
info:
  title: EverOS Cloud Memory API
  version: 2.0.0
  license:
    name: Apache-2.0
    identifier: Apache-2.0
  contact:
    name: EverMind AI
    email: service@evermind.ai
    url: https://github.com/EverMind-AI/everos-cloud-sdk-python
  description: >-
    Official Python client for the EverOS Cloud Memory API. Add, search,
    retrieve, and manage long-term memory for your AI applications over a typed
    interface (pydantic v2, with full type hints). Install and usage guides:
    https://github.com/EverMind-AI/everos-cloud-sdk-python
servers:
  - url: https://api.evermind.ai
    description: Production
security:
  - BearerAuth: []
paths:
  /api/v2/memory/rebuild:
    post:
      tags:
        - Memory
      summary: Rebuild derived memories a delete left stale [Cloud-only]
      description: >-
        Regenerate the derived memories that deletes left stale.


        A delete never spends LLM calls. Derived memories that only an LLM can
        regenerate (the user profile, session summaries, agent skills) are kept
        and marked stale instead: the delete response has `rebuild_required` and
        `targets`, and the profile has `stale`. This call starts one background
        job that regenerates them from the remaining memories. Nothing is
        regenerated until you call it, so batch your deletes first.


        - Pass `user_id` (profile, session summaries) or `agent_id` (skills).
        `targets` narrows the rebuild; by default everything marked stale is
        rebuilt.

        - `dry_run` reports what would be rebuilt (`estimated_episodes` sizes a
        profile rebuild) and spends nothing. `force` rebuilds the profile or
        skills even when nothing is marked; an owner with no profile yet has
        none to rebuild.

        - One job per owner at a time: a second call returns the running job
        with `status: already_running`.

        - The call is free; the extraction it runs is metered like any
        extraction, so it is refused with 429 once the account's usage quota is
        exhausted.


        While a profile rebuild runs, the profile holds only its manually edited
        items plus what has been re-extracted so far, and `stale` stays `true`
        until the job finishes. Poll /api/v2/memory/rebuild/status with the
        returned `job_id`.
      operationId: rebuildMemory
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RebuildInput'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessEnvelope_RebuildData_'
        '401':
          description: Missing or invalid bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '403':
          description: >-
            Authenticated but not permitted — either rejected by the auth
            service, or the account's memory API version does not match the
            interface version implied by the path (a v1 account calling an
            /api/v2 route).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: >-
            Rate limit exceeded, or the account's usage quota is exhausted: the
            rebuild's extraction is metered, so it is refused until the quota is
            topped up.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
        '503':
          description: >-
            The gateway could not reach the authentication service. Transient —
            retry with backoff.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
components:
  schemas:
    RebuildInput:
      properties:
        app_id:
          type: string
          maxLength: 128
          title: App Id
          default: default
        project_id:
          type: string
          maxLength: 128
          title: Project Id
          default: default
        user_id:
          anyOf:
            - type: string
              maxLength: 256
              minLength: 1
            - type: 'null'
          title: User Id
          description: The user whose profile / session summaries to rebuild
        agent_id:
          anyOf:
            - type: string
              maxLength: 256
              minLength: 1
            - type: 'null'
          title: Agent Id
          description: The agent whose skills to rebuild
        targets:
          anyOf:
            - items:
                type: string
                enum:
                  - profile
                  - session_summary
                  - skill
              type: array
            - type: 'null'
          title: Targets
          description: >-
            Subset to rebuild. Default: everything marked stale for this owner.
            user_id → profile, session_summary; agent_id → skill.
        force:
          type: boolean
          title: Force
          description: >-
            Rebuild the profile / every skill cluster even when nothing is
            marked stale. Session summaries are only rebuilt when marked.
          default: false
        dry_run:
          type: boolean
          title: Dry Run
          description: Report what would be rebuilt; start no job and spend nothing.
          default: false
      additionalProperties: false
      type: object
      title: RebuildInput
    SuccessEnvelope_RebuildData_:
      properties:
        request_id:
          type: string
          title: Request Id
          description: Request trace id (peer to data)
        data:
          $ref: '#/components/schemas/RebuildData'
          description: Endpoint-defined business result
      type: object
      required:
        - request_id
        - data
      title: SuccessEnvelope[RebuildData]
    GatewayError:
      type: object
      additionalProperties: true
      description: >-
        Gateway error body. NOTE: shape is not yet uniform across auth/quota/
        rate-limit paths — treat fields as best-effort. Commonly includes a
        `code`/`message` (flat) or an `error` object/string with a `message`.
      title: GatewayError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          description: One entry per field that failed validation.
      type: object
      title: HTTPValidationError
    RebuildData:
      properties:
        job_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Job Id
          description: >-
            Rebuild job id; null when no job was started (nothing_to_do,
            dry_run)
        status:
          type: string
          enum:
            - queued
            - already_running
            - nothing_to_do
            - dry_run
          title: Status
          description: >-
            queued: a job was started. already_running: the owner's running job
            is returned instead of starting another. nothing_to_do: nothing is
            marked stale (and force is false). dry_run: what would be rebuilt.
        targets:
          items:
            type: string
            enum:
              - profile
              - session_summary
              - skill
          type: array
          title: Targets
          description: What the job rebuilds (or would)
        estimated_episodes:
          type: integer
          title: Estimated Episodes
          description: Episodes a profile rebuild re-reads (a cost hint; 0 without profile)
          default: 0
      type: object
      required:
        - status
      title: RebuildData
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
          description: Path to the offending field, from the body root.
        msg:
          type: string
          title: Message
          description: What is wrong with it.
        type:
          type: string
          title: Error Type
          description: Machine-readable validation-error kind.
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'API key issued by EverOS, sent as `Authorization: Bearer <api_key>`.'

````

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