> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Ask it with GET https://upstash.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash.com/docs/common/help/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash.com/docs/feedback?path=/docs/api-reference/qstash/roll-qstash-token&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.

# Roll QStash Token

> Makes the next token pair from [Get the Next QStash Token](/api-reference/qstash/get-the-next-qstash-token)
the current one. The old token and read-only token stop working.
The next call to Get the Next QStash Token creates a new pair.

`next_token_hash` must match the next token (or next read-only token) you deployed.
If it does not, the request is rejected with `409`, so a repeated or stale call
cannot retire the token you just moved to.


`POST /qstash/roll-token/{id}`

## OpenAPI

````yaml devops/developer-api/openapi.yaml post /qstash/roll-token/{id}
openapi: 3.0.4
info:
  title: Developer API - Upstash
  description: This is a documentation to specify Developer API endpoints based on
    the OpenAPI 3.0 specification.
  contact:
    name: Support Team
    email: support@upstash.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
  - url: https://api.upstash.com/v2
tags:
  - name: redis
    description: Manage redis databases.
    externalDocs:
      description: Find out more
      url: https://upstash.com/docs/devops/developer-api/introduction
  - name: teams
    description: Manage teams and team members.
    externalDocs:
      description: Find out more
      url: https://upstash.com/docs/devops/developer-api/introduction
  - name: vector
    description: Manage vector indices.
    externalDocs:
      description: Find out more
      url: https://upstash.com/docs/devops/developer-api/introduction
  - name: search
    description: Manage search indices.
    externalDocs:
      description: Find out more
      url: https://upstash.com/docs/devops/developer-api/introduction
  - name: qstash
    description: Manage QStash.
    externalDocs:
      description: Find out more
      url: https://upstash.com/docs/devops/developer-api/introduction
paths:
  /qstash/roll-token/{id}:
    post:
      summary: Roll QStash Token
      description: >
        Makes the next token pair from [Get the Next QStash
        Token](/api-reference/qstash/get-the-next-qstash-token)

        the current one. The old token and read-only token stop working.

        The next call to Get the Next QStash Token creates a new pair.


        `next_token_hash` must match the next token (or next read-only token)
        you deployed.

        If it does not, the request is rejected with `409`, so a repeated or
        stale call

        cannot retire the token you just moved to.
      operationId: rollQStashToken
      tags:
        - qstash
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: QStash user ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - next_token_hash
              properties:
                next_token_hash:
                  type: string
                  description: Hex-encoded SHA-256 hash of the next token or the next read-only
                    token
                  example: 3a6eb0790f39ac87c94f3856b2dd2c5d110e6811602261a9a923d3bb23adc8b7
      responses:
        "200":
          description: Token rolled, returns updated user information with the new tokens
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/QStashUser"
        "400":
          description: >
            The roll was refused: `next_token_hash` is missing, there is no next
            token to roll to

            (call Get the Next QStash Token first), the account is in the middle
            of another change,

            or your team role does not allow it.
          content:
            application/json:
              schema:
                type: string
                example: QStash user has no next token, get it from /v2/qstash/next-token before
                  rolling
        "404":
          description: QStash user not found
          content:
            application/json:
              schema:
                type: string
                example: QStash user not found
        "409":
          description: "`next_token_hash` does not match the current next token. Get the
            next token again; do not retry with the same hash."
          content:
            application/json:
              schema:
                type: string
                example: Your next QStash token has changed since it was shown, so your token
                  was not rolled. Get the next token again before rolling.
      security:
        - basicAuth: []
components:
  schemas:
    QStashUser:
      type: object
      properties:
        customer_id:
          type: string
          description: Customer identifier (email or team ID)
          example: example@upstash.com
        id:
          type: string
          format: uuid
          description: Unique identifier for the QStash user account
          example: 99a4c327-31f0-490f-a594-043ade84085a
        token:
          type: string
          description: Authentication token for QStash operations
          example: ZXhhbXBsZUB1cHN0YXNoLmNvbTpuYWJlcg==
        read_only_token:
          type: string
          description: Read-only authentication token for QStash operations
          example: ZXhhbXBsZUB1cHN0YXNoLmNvbTpuYWJlcg==
        has_next_token:
          type: boolean
          description: Whether a next token pair has been created and not rolled yet. See
            [Get the Next QStash
            Token](/api-reference/qstash/get-the-next-qstash-token).
          example: false
        active:
          type: boolean
          description: Whether the QStash account is active
          example: true
        state:
          type: string
          description: Current state of the QStash account (e.g. `active`, `passive`;
            other values may be returned)
          example: active
        modifying_state:
          type: string
          description: Transitional state while the console applies an async change (e.g.
            `suspended` during suspension). Omitted when no change is in
            progress.
          example: suspended
        last_plan_upgrade_time:
          type: integer
          format: int64
          description: Unix timestamp of the last plan upgrade
          example: 0
        max_message_size:
          type: integer
          description: Maximum message size in bytes
          example: 1048576
        max_requests_per_day:
          type: integer
          description: Soft limit for maximum requests per day
          example: 1000
        max_requests_per_day_hard:
          type: integer
          description: Hard limit for maximum requests per day
          example: 1000
        max_endpoints_per_topic:
          type: integer
          description: Maximum number of endpoints allowed per topic
          example: 100
        max_requests_per_second:
          type: integer
          description: Maximum requests per second (rate limit)
          example: 100
        max_dlq_size:
          type: integer
          description: Maximum dead letter queue size
          example: 1000000
        max_retries:
          type: integer
          description: Maximum number of retry attempts for failed messages
          example: 999
        max_topics:
          type: integer
          description: Maximum number of topics allowed
          example: 1
        max_schedules:
          type: integer
          description: Maximum number of schedules allowed
          example: 10
        max_events_size:
          type: integer
          description: Maximum size for events
          example: 10000
        max_dlq_retention_time_milis:
          type: integer
          format: int64
          description: Maximum retention time for dead letter queue in milliseconds
          example: 259200000
        max_delay:
          type: integer
          description: Maximum delay for scheduled messages in seconds
          example: 604800
        max_parallelism:
          type: integer
          description: Maximum parallel processing per endpoint
          example: 2
        max_global_parallelism:
          type: integer
          description: Maximum global parallel processing across all endpoints
          example: 10
        max_queues:
          type: integer
          description: Maximum number of queues allowed
          example: 10
        max_bandwidth_per_second:
          type: integer
          format: int64
          description: Maximum bandwidth per second in bytes
          example: 1048576
        prod_pack_enabled:
          type: boolean
          description: Whether production pack features are enabled
          example: false
        prometheus_enabled:
          type: string
          description: Whether Prometheus metrics export is enabled (`"true"` / `"false"`
            string as returned by the API)
          enum:
            - "true"
            - "false"
          example: "false"
        timeout:
          type: integer
          description: Request timeout in seconds
          example: 900
        type:
          type: string
          description: Account billing plan category
          enum:
            - free
            - paid
          example: free
        region:
          type: string
          description: Region where the QStash instance is deployed
          enum:
            - eu-central-1
            - us-east-1
          example: eu-central-1
        reserved_type:
          type: string
          description: >
            Fixed-tier or enterprise label when applicable. May be empty/absent
            for non-fixed plans.

            Known values include `qstash_fixed_1m`, `qstash_fixed_10m`,
            `qstash_fixed_100m`, `qstash_fixed`.

            Enterprise accounts may use the prefix `enterprise:` followed by an
            identifier (e.g. `enterprise:acme`).
          example: ""
        reserved_price:
          type: integer
          description: Reserved plan price (may be `0`)
          example: 0
        created_by:
          type: string
          description: Email of the user who created this account
          example: cahidarda@upstash.com
        creation_time:
          type: integer
          format: int64
          description: Unix timestamp of account creation
          example: 1781871358
        deletion_time:
          type: integer
          format: int64
          description: Unix timestamp of account deletion (`0` if not deleted)
          example: 0
        budget:
          type: integer
          description: Monthly spending budget limit in dollars. 0 means no limit.
          example: 0
        enterprise:
          type: object
          description: Present for enterprise accounts
          properties:
            enabled:
              type: boolean
              description: Whether enterprise features are enabled
              example: true
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
````
