> ## Documentation index
> Fetch the complete documentation index at: https://context7.com/docs/llms.txt
> Ask it with GET https://context7.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://context7.com/docs/resources/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://context7.com/docs/feedback?path=/docs/api-reference/teamspace-libraries/set-automatic-refresh&helpful={true|false}&comment={comment}` records whether this page helped. The `comment` (URL-encoded, at most 500 characters) says what helped, or what was missing or wrong; a `helpful=false` rating needs it. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# Set automatic refresh

> Sets the teamspace's automatic refresh mode of one of its private libraries (Pro and Enterprise, including an active Enterprise trial; the library need not be claimed). On Pro at most 10 private libraries of a teamspace may have a mode other than `off`. `off` is always allowed, so a teamspace that dropped to Free can still turn it off. Each automatic refresh bills its parse tokens to the teamspace at $5 per 1M tokens, and runs only when the tracked branch has new documentation changes. Saving a mode again resumes a paused library.

`PUT /v2/teamspaces/{teamspaceId}/libraries/{owner}/{repo}/automatic-refresh`

## OpenAPI

````yaml https://context7.com/openapi.json put /v2/teamspaces/{teamspaceId}/libraries/{owner}/{repo}/automatic-refresh
openapi: 3.0.0
info:
  title: Context7 Public API
  description: The Context7 Public API provides programmatic access to library
    documentation and search functionality. Get up-to-date documentation and
    code examples for any library.
  version: 2.0.0
  contact:
    name: Context7 Support
    url: https://context7.com
    email: support@context7.com
servers:
  - url: https://context7.com/api
    description: Production server
tags:
  - name: Search
    description: Search for libraries in the Context7 database
  - name: Context
    description: Retrieve documentation context for queries
  - name: Ask
    description: Answer questions from a website registered with Context7 Ask
  - name: Refresh
    description: Refresh existing libraries to fetch latest documentation
  - name: Policies
    description: Manage teamspace access policies and filters
  - name: Add Library
    description: Submit new libraries for documentation processing
  - name: Metrics
    description: Retrieve usage metrics for libraries
  - name: Usage
    description: See member and teamspace API usage
  - name: Teamspaces
    description: Teamspaces the caller is a member of. The management API
      (`/v2/teamspaces/*`) accepts a Context7 API key, which reaches only its
      own teamspace and can make changes or read personal data only when it was
      created with write access (other keys can only read and get 403
      `write_access_required` on writes and on personal data), or an OAuth token
      issued for the Context7 Admin MCP server
      (`https://admin.mcp.context7.com/mcp`), which reaches every teamspace of
      the user. A browser session is not accepted.
  - name: Teamspace Admin
    description: Members, invitations, rules, library policies and requests, usage
      and the spending limit of a teamspace. Every API key can read rules,
      policies, usage and the spending limit. Changes, and reading members,
      invitations, the invite link and library requests (they name people), need
      an API key created with **Write access** ticked (other keys get 403
      `write_access_required`), or the Context7 Admin MCP sign-in.
  - name: Teamspace Libraries
    description: "A teamspace's libraries: its private sources and the libraries it
      has claimed. Add, refresh, configure, version, claim and remove them, and
      read their parse state and usage. A library id `/owner/repo` is two path
      segments. Every API key can read. Changes need an API key created with
      **Write access** ticked (other keys get 403 `write_access_required`), or
      the Context7 Admin MCP sign-in."
  - name: Docs7 Sites
    description: 'Docs7 documentation sites of a teamspace: settings, custom
      domains, deployments, previews and the Docs7 agents. Any member can read;
      owners and admins can change; developers can add a site, publish one added
      for the agents only, and rebuild. Sites deployed with the `docs7 deploy`
      CLI have `source: "local"`; operations marked GitHub-only answer 404 for
      them. Every API key can read, except feature requests and the GitHub
      account behind a build (personal data). Changes, and those reads, need an
      API key created with **Write access** ticked (other keys get 403
      `write_access_required`), or the Context7 Admin MCP sign-in.'
  - name: Docs7 Analytics
    description: "Traffic of one Docs7 site: visitors, AI crawlers, searches,
      assistant questions and page feedback. Docs7 Free reads the last 7 days,
      Docs7 Pro the last 90. Every API key can read the visitor, crawler and
      path reports. Searches, questions, conversations, feedback and the raw
      records (`explore`) are personal data and need an API key created with
      **Write access** ticked, or the Context7 Admin MCP sign-in."
  - name: Ask Sites
    description: "Manage a teamspace's Context7 Ask sites: add, verify, remove, and
      read their analytics and question log. Every API key can read the sites.
      Changes, and reading the analytics and question log (visitor questions),
      need an API key created with **Write access** ticked (other keys get 403
      `write_access_required`), or the Context7 Admin MCP sign-in."
paths:
  /v2/teamspaces/{teamspaceId}/libraries/{owner}/{repo}/automatic-refresh:
    put:
      tags:
        - Teamspace Libraries
      summary: Set automatic refresh
      description: Sets the teamspace's automatic refresh mode of one of its private
        libraries (Pro and Enterprise, including an active Enterprise trial; the
        library need not be claimed). On Pro at most 10 private libraries of a
        teamspace may have a mode other than `off`. `off` is always allowed, so
        a teamspace that dropped to Free can still turn it off. Each automatic
        refresh bills its parse tokens to the teamspace at $5 per 1M tokens, and
        runs only when the tracked branch has new documentation changes. Saving
        a mode again resumes a paused library.
      operationId: updateTeamspaceLibraryAutomaticRefresh
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TeamspaceLibraryAutomaticRefreshUpdate"
            example:
              mode: push
      responses:
        "200":
          description: The saved mode and the run state
          content:
            application/json:
              schema:
                type: object
                required:
                  - automaticRefresh
                properties:
                  automaticRefresh:
                    $ref: "#/components/schemas/TeamspaceLibraryAutomaticRefresh"
        "400":
          description: An invalid mode (`validation_error`), a library that is not one of
            the teamspace's private sources (`not_private_library`), or a
            repository that is not on github.com
            (`automatic_refresh_unsupported`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              example:
                error: automatic_refresh_unsupported
                message: Automatic refresh supports private repositories on github.com only.
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "403":
          description: "The caller cannot access the teamspace or its role is too low
            (`forbidden`), the API key cannot write (`write_access_required`), a
            mode was turned on in a teamspace whose plan has no automatic
            refresh: Free or a personal project (`plan_required`), or an 11th
            library was turned on in a Pro teamspace
            (`automatic_refresh_limit_reached`)"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              examples:
                planRequired:
                  value:
                    error: plan_required
                    message: Automatic refresh is available on the Pro and Enterprise plans.
                limitReached:
                  value:
                    error: automatic_refresh_limit_reached
                    message: Your plan allows automatic refresh for 10 private libraries per
                      teamspace. Turn it off for another library, or upgrade to
                      Enterprise.
        "404":
          description: The teamspace has no library with this id (neither claimed nor one
            of its private sources)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              example:
                error: library_not_found
                message: This teamspace has no library with this id.
        "409":
          description: The Context7 GitHub App is not installed on the repository
            (`github_app_not_installed`), or the caller's GitHub account cannot
            reach it through that installation (`github_access_required`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
              example:
                error: github_access_required
                message: Give your GitHub account and the Context7 GitHub App access to this
                  repository, then try again.
        "500":
          $ref: "#/components/responses/InternalServerError"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: "Get your API key at
        [context7.com/dashboard](https://context7.com/dashboard). Treat your API
        key like a password and store it securely. Every key can read the
        management API (`/v2/teamspaces/*`), except personal data: member and
        invitation emails, library requesters, visitor questions, Docs7 reader
        searches, conversations, feedback and feature requests, and the GitHub
        account behind a build. To read those or make changes there, the key
        must be created with **Write access** ticked; other keys get 403
        `write_access_required`. A teamspace can limit API keys to owners and
        admins, or turn them off for OAuth only; a key that its teamspace's
        policy refuses gets 403 `api_key_admins_only` or `api_keys_disabled`."
  schemas:
    Error:
      type: object
      description: Standard error response
      properties:
        error:
          type: string
          description: Error code identifier
        message:
          type: string
          description: Human-readable error message
      required:
        - error
        - message
    TeamspaceLibraryAutomaticRefresh:
      type: object
      description: "The teamspace's automatic refresh of one of its private libraries.
        Pro and Enterprise teamspaces (Enterprise: the plan or an active
        Enterprise trial); on Free every mode acts as `off`. Private github.com
        repositories only. The run state is the library's, shared by every
        teamspace that has it; a library several teamspaces track runs under the
        most permissive tier among the teamspaces whose setting is on for the
        trigger."
      required:
        - mode
        - supported
        - planAllowed
        - tier
        - overPlanLimit
        - lastRunAt
        - lastOutcome
        - failures
        - pausedReason
        - nextAllowedAt
        - estimate
      properties:
        mode:
          type: string
          enum:
            - off
            - weekly
            - daily
            - hourly
            - push
          description: "`push`: after a push to the branch the library tracks, a few
            minutes later so a burst makes one refresh. `weekly`, `daily`,
            `hourly`: on that schedule, when the branch has a new commit."
        supported:
          type: boolean
          description: The library is a private github.com repository.
        planAllowed:
          type: boolean
          description: "The teamspace's plan has automatic refresh: Pro, or Enterprise
            (the plan or an active Enterprise trial)."
        tier:
          type: string
          enum:
            - pro
            - enterprise
          nullable: true
          description: "The teamspace's automatic refresh limits. `enterprise`: at least
            30 minutes between automatic starts, 48 starts per library and UTC
            day, no library cap. `pro`: at least 3 hours, 6 a day, at most 10
            libraries with a mode other than `off`. Null on Free."
        overPlanLimit:
          type: boolean
          description: The mode is on, but the teamspace has more libraries on than its
            plan allows (a teamspace that moved from Enterprise to Pro keeps
            every mode) and this one is past the cap, so it does not run. The
            cap keeps the libraries turned on first. Turn others off or upgrade
            to Enterprise.
        lastRunAt:
          type: string
          format: date-time
          nullable: true
          description: When the last automatic refresh started.
        lastOutcome:
          type: string
          enum:
            - queued
            - succeeded
            - failed
          nullable: true
          description: The end of the last automatic refresh; `queued` while it runs.
        failures:
          type: integer
          description: Failed automatic refreshes in a row. The next waits 15 minutes, 1
            hour, then 6 hours; the fourth failure pauses automatic refresh.
        pausedReason:
          type: string
          enum:
            - repeated_failures
            - no_access
          nullable: true
          description: Automatic refresh is paused. Save the mode again to resume it.
        nextAllowedAt:
          type: string
          format: date-time
          nullable: true
          description: "The earliest next automatic start under this teamspace's tier: 30
            minutes (Enterprise) or 3 hours (Pro) after the last one, and after
            a failure's wait. A push before it waits for it."
        estimate:
          $ref: "#/components/schemas/AutomaticRefreshEstimate"
    AutomaticRefreshEstimate:
      type: object
      description: What automatic refresh of this library may cost. Parse tokens of
        private libraries are billed to the teamspace. A refresh runs, and is
        billed, only when the tracked branch has new documentation changes (an
        unchanged commit is skipped with no tokens), so the monthly figures are
        upper bounds, usually far above the real cost.
      required:
        - typicalTokens
        - typicalUsd
        - basis
        - recordedRuns
        - usdPerMillionTokens
        - modes
      properties:
        typicalTokens:
          type: integer
          description: Parse tokens of a typical refresh of this library.
        typicalUsd:
          type: number
          description: The typical refresh's cost in US dollars.
        basis:
          type: string
          enum:
            - history
            - recent_runs
            - similar_libraries
          description: "`history`: the median of the library's recorded parses (at least 3
            of its newest 10). `recent_runs`: the library's newest recorded
            parse, when 1 or 2 are recorded (a first parse reads every page, so
            refreshes usually cost less). `similar_libraries`: a typical refresh
            of other private libraries (183,000 tokens), when none is recorded."
        recordedRuns:
          type: integer
          description: How many of the library's parses were recorded (the newest 10 are
            kept for 90 days).
        usdPerMillionTokens:
          type: number
          description: The parse token price in US dollars per 1M tokens.
        modes:
          type: object
          description: The upper bound of each mode on the teamspace's tier (Pro's limits
            on Free).
          required:
            - weekly
            - daily
            - hourly
            - push
          properties:
            weekly:
              $ref: "#/components/schemas/AutomaticRefreshModeEstimate"
            daily:
              $ref: "#/components/schemas/AutomaticRefreshModeEstimate"
            hourly:
              $ref: "#/components/schemas/AutomaticRefreshModeEstimate"
            push:
              $ref: "#/components/schemas/AutomaticRefreshModeEstimate"
      example:
        typicalTokens: 183000
        typicalUsd: 0.92
        basis: similar_libraries
        recordedRuns: 0
        usdPerMillionTokens: 5
        modes:
          weekly:
            maxRunsPerMonth: 4.3
            upperMonthlyUsd: 3.93
          daily:
            maxRunsPerMonth: 30
            upperMonthlyUsd: 27.45
          hourly:
            maxRunsPerMonth: 180
            upperMonthlyUsd: 164.7
          push:
            maxRunsPerMonth: 180
            upperMonthlyUsd: 164.7
    AutomaticRefreshModeEstimate:
      type: object
      required:
        - maxRunsPerMonth
        - upperMonthlyUsd
      properties:
        maxRunsPerMonth:
          type: number
          description: "The most automatic refreshes the mode can start in a month on the
            teamspace's tier: weekly 4.3, daily 30, hourly 720 on Enterprise and
            180 on Pro, push 1,440 on Enterprise and 180 on Pro."
        upperMonthlyUsd:
          type: number
          description: "`maxRunsPerMonth` refreshes at the typical cost, in US dollars."
    TeamspaceLibraryAutomaticRefreshUpdate:
      type: object
      description: Sets the teamspace's automatic refresh mode of one of its private
        libraries. Owners and admins of a Pro or Enterprise teamspace; on Pro at
        most 10 libraries may be on. Turning it on also needs the caller's
        GitHub account and the Context7 GitHub App installation to reach the
        repository. Saving a mode again resumes a paused library.
      required:
        - mode
      properties:
        mode:
          type: string
          enum:
            - off
            - weekly
            - daily
            - hourly
            - push
  responses:
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: internal_error
            message: An error occurred while processing your request
    UnauthorizedError:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: invalid_api_key
            message: Invalid API key. Please check your API key. API keys should start with
              'ctx7sk' prefix.
````
