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

# Restore an archived custom agent

> Restores an archived custom agent, as Restore does on the Agents page. It returns to listManagedAgents with its schedule off; turn the schedule back on with setAgentSchedule. Restoring an agent that is not archived changes nothing. Built-in agents are never archived (400, reason built_in_agent). A custom agent outside this project returns 404. The OAuth member, or the member who created the API key, must belong to the project and hold the manage permission; otherwise 403. Requires the agents.write scope.



## OpenAPI

````yaml /openapi.json post /projects/{projectId}/agents/{agentKey}/restore
openapi: 3.1.0
info:
  title: DevTune API
  version: 2.0.0
  description: >-
    API for programmatic access to your AI visibility data, webhook
    subscriptions, and automation workflows. Use this API to integrate DevTune
    data into CI/CD pipelines, BI tools, AI agents, and operational systems.
servers:
  - url: https://devtune.ai/api/v2
    description: Production
security:
  - bearerAuth: []
paths:
  /projects/{projectId}/agents/{agentKey}/restore:
    post:
      summary: Restore an archived custom agent
      description: >-
        Restores an archived custom agent, as Restore does on the Agents page.
        It returns to listManagedAgents with its schedule off; turn the schedule
        back on with setAgentSchedule. Restoring an agent that is not archived
        changes nothing. Built-in agents are never archived (400, reason
        built_in_agent). A custom agent outside this project returns 404. The
        OAuth member, or the member who created the API key, must belong to the
        project and hold the manage permission; otherwise 403. Requires the
        agents.write scope.
      operationId: restoreCustomAgent
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: agentKey
          in: path
          required: true
          description: A custom agent key that was archived.
          schema:
            type: string
      responses:
        '200':
          description: The restored agent
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/CustomAgentArchiveWrite'
                  meta:
                    $ref: '#/components/schemas/Meta'
                required:
                  - data
                  - meta
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '429':
          $ref: '#/components/responses/RateLimitExceededError'
      security:
        - bearerAuth: []
        - oauthBearer: []
components:
  schemas:
    CustomAgentArchiveWrite:
      type: object
      additionalProperties: false
      required:
        - agent
      properties:
        agent:
          type: object
          additionalProperties: false
          required:
            - agentKey
            - displayName
            - description
            - instructions
            - modelId
            - quickActions
            - toolAllowlist
            - outputArtifactType
            - workflowKey
            - isCustom
            - scheduling
            - archivedAt
          properties:
            agentKey:
              type: string
            displayName:
              type: string
            description:
              type: string
            instructions:
              type: string
            modelId:
              type: string
            quickActions:
              type: array
              items:
                type: string
            toolAllowlist:
              type: array
              items:
                type: string
            outputArtifactType:
              type: string
              enum:
                - action
                - brief
                - report
            workflowKey:
              type: string
            isCustom:
              type: boolean
              enum:
                - true
            scheduling:
              $ref: '#/components/schemas/AgentScheduleState'
            archivedAt:
              type: string
              format: date-time
              nullable: true
              description: When the agent was archived; null once it is restored.
    Meta:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        projectId:
          type: string
          format: uuid
    AgentScheduleState:
      type: object
      additionalProperties: false
      required:
        - autonomyLevel
        - schedule
        - modelId
        - scheduledAt
      properties:
        autonomyLevel:
          type: string
          enum:
            - manual
            - scheduled
          description: scheduled when the schedule is on; manual when it is off.
        schedule:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/AgentSchedule'
        modelId:
          type: string
          nullable: true
          description: The model scheduled runs use.
        scheduledAt:
          type: string
          format: date-time
          nullable: true
          description: When the schedule was last turned on or changed.
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        reason:
          type: string
          description: >-
            Why the request was refused, for an error with more than one cause,
            such as a refused content-draft start.
        details:
          type: object
          additionalProperties: true
          description: >-
            Machine-readable facts about the refusal, such as shortfall_credits
            when an Agent Picks start is refused for insufficient_credits.
        status:
          type: integer
      required:
        - error
        - message
        - status
    AgentSchedule:
      description: >-
        When scheduled runs start: daily, weekly on dayOfWeek, or monthly on
        dayOfMonth, at time in timezone.
      oneOf:
        - $ref: '#/components/schemas/AgentScheduleDaily'
        - $ref: '#/components/schemas/AgentScheduleWeekly'
        - $ref: '#/components/schemas/AgentScheduleMonthly'
    AgentScheduleDaily:
      type: object
      additionalProperties: false
      required:
        - cadence
        - time
        - timezone
      properties:
        cadence:
          type: string
          enum:
            - daily
        time:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
          description: Run time as 24-hour HH:mm.
        timezone:
          type: string
          description: IANA timezone, such as Europe/London.
        modelId:
          type: string
          minLength: 1
          description: >-
            Optional. The modelId sent beside the schedule is the one scheduled
            runs use.
    AgentScheduleWeekly:
      type: object
      additionalProperties: false
      required:
        - cadence
        - dayOfWeek
        - time
        - timezone
      properties:
        cadence:
          type: string
          enum:
            - weekly
        dayOfWeek:
          type: integer
          minimum: 0
          maximum: 6
          description: 0 (Sunday) to 6 (Saturday).
        time:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
          description: Run time as 24-hour HH:mm.
        timezone:
          type: string
          description: IANA timezone, such as Europe/London.
        modelId:
          type: string
          minLength: 1
          description: >-
            Optional. The modelId sent beside the schedule is the one scheduled
            runs use.
    AgentScheduleMonthly:
      type: object
      additionalProperties: false
      required:
        - cadence
        - dayOfMonth
        - time
        - timezone
      properties:
        cadence:
          type: string
          enum:
            - monthly
        dayOfMonth:
          type: integer
          minimum: 1
          maximum: 28
        time:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
          description: Run time as 24-hour HH:mm.
        timezone:
          type: string
          description: IANA timezone, such as Europe/London.
        modelId:
          type: string
          minLength: 1
          description: >-
            Optional. The modelId sent beside the schedule is the one scheduled
            runs use.
  responses:
    BadRequestError:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFoundError:
      description: Not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimitExceededError:
      description: Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  headers:
    X-RateLimit-Limit:
      description: Maximum requests per window
      schema:
        type: integer
    X-RateLimit-Remaining:
      description: Requests remaining in current window
      schema:
        type: integer
    X-RateLimit-Reset:
      description: Unix timestamp when the window resets
      schema:
        type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key with dtk_live_ prefix. Obtain it from API Keys in the account
        sidebar. New keys start with all supported scopes selected for the
        chosen project, and you can narrow them to specific read/write scopes as
        needed.
    oauthBearer:
      type: http
      scheme: bearer
      description: >-
        Project-granted OAuth access token from the authorization server
        advertised at /.well-known/oauth-protected-resource/api/v2. Uses the
        same browser consent and current project permissions as MCP. Only
        operations explicitly listing oauthBearer accept these tokens.

````

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