---
title: "Regenerate token"
method: POST
path: "/api/users/service/{userId}/personal-access-tokens/{patId}/regenerate"
tags: ["Personal access token"]
---

# Regenerate token

`POST /api/users/service/{userId}/personal-access-tokens/{patId}/regenerate`

## Request

- The document declares no server URL.
- Auth: HTTP internal
- TypeScript: <https://skmtc.dev/gorules/apis/gorules-agent-api/docs/api/users/service/:userId/personal-access-tokens/:patId/regenerate/post.ts> (a function with typed inputs; its response is checked against the schema)

Note that any pipelines that depend on the token will stop functioning.

## Path parameters

- `userId` string, uuid, nullable, required
- `patId` string, uuid, required

## Request body

- object
  - `expiry` 'week' | 'month' | 'three_months' | 'year' | 'indefinite', required: New token expiration period (week, month, three_months, year, or indefinite)

## Response `200`

Regenerated personal access token with the new token value

- object: Regenerated personal access token with the new token value
  - `id` string, uuid, required: Unique identifier of the personal access token
  - `note` string, required: Description or note for the token
  - `permissions` string[], required: List of permissions granted to this token
  - `allProjects` boolean, required: Whether the token has access to all projects
  - `projects` object[], required: List of projects the token has access to
    - `id` string, uuid, required: Unique identifier of the project
    - `name` string, required: Name of the project
    - `key` string: Project key
    - `organisationId` string, uuid, required: Organisation ID the project belongs to
    - `version` string, required: Project version
    - `createdAt` string, required: Timestamp when the project was created
    - `updatedAt` string, required: Timestamp when the project was last updated
    - `protected` boolean: Whether the project is protected
  - `user` object, required: User who owns the token
    - `id` string, uuid, required: Unique identifier of the user
    - `email` string, email, required: Email address of the user
    - `firstName` string, nullable: First name of the user
    - `lastName` string, nullable: Last name of the user
    - `type` string, required: User type (e.g., member, admin, owner)
    - `status` string, required: User status (e.g., active, disabled)
    - `isService` boolean: Whether the user is a service account
    - `createdAt` string, required: Timestamp when the user was created
    - `updatedAt` string, required: Timestamp when the user was last updated
  - `createdAt` string, required: Timestamp when the token was created
  - `updatedAt` string, required: Timestamp when the token was last updated
  - `expiresAt` string, nullable: Timestamp when the token expires, null if indefinite
  - `token` string, required: The generated token value (only returned on create or regenerate)

---

[API](https://skmtc.dev/gorules/apis/gorules-agent-api.md) - [All operations](https://skmtc.dev/gorules/apis/gorules-agent-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gorules/apis/gorules-agent-api/revisions/52c0773fcd80?raw)
