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

# Rotate App Token

> Rotate the token for an existing application.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/morphik/openapi.documented.yml post /apps/rotate_token
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security: []
paths:
  /apps/rotate_token:
    post:
      summary: Rotate App Token
      description: Rotate the token for an existing application.
      operationId: rotate_app_token_apps_rotate_token_post
      parameters:
        - name: app_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Application ID to rotate
            title: App Id
          description: Application ID to rotate
        - name: app_name
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Application name to rotate
            title: App Name
          description: Application name to rotate
        - name: expiry_days
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            description: Number of days until the new token expires
            default: 5475
            title: Expiry Days
          description: Number of days until the new token expires
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
        - name: X-Morphik-Admin-Secret
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Morphik-Admin-Secret
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                title: Response Rotate App Token Apps Rotate Token Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Morphik from 'morphik';

            const client = new Morphik({
              apiKey: process.env['MORPHIK_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.cloud.rotateAppToken();

            console.log(response);
        - lang: cURL
          source: |-
            curl https://api.morphik.ai/apps/rotate_token \
                -X POST \
                -H "Authorization: Bearer $MORPHIK_API_KEY"
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````